Winformアプリケーションでグリッド(ComponentOneのFlexGrid)があり、セルの列インデックスとその値を考慮して、そのグリッド内のセルを検索しようとしています。CodedUI:セルの検索が遅いのはなぜですか?
グリッドをループしてそのセルを見つけるために、以下の拡張メソッドを記述しました。
私は6列と64行を持つグリッド上でそのメソッドをテストしています。私のコードが(最後の行にあった)正しいセルを見つけるのに10分かかりました
私のアルゴリズムをスピードアップする方法はありますか?
注:私もTOPLEVELWINDOWにPlayBack.PlayBackSetting.SmartMatchOptionを設定しようとしましたが、何も変更していないようだ...
ありがとう!
public static WinCell FindCellByColumnAndValue(this WinTable table, int colIndex, string strCellValue)
{
int count = table.GetChildren().Count;
for (int rowIndex = 0; rowIndex < count; rowIndex++)
{
WinRow row = new WinRow(table);
WinCell cell = new WinCell(row);
row.SearchProperties.Add(WinRow.PropertyNames.RowIndex, rowIndex.ToString());
cell.SearchProperties.Add(WinCell.PropertyNames.ColumnIndex, colIndex.ToString());
cell.SearchProperties.Add(WinCell.PropertyNames.Value, strCellValue);
if (cell.Exists)
return cell;
}
return new WinCell();
}
編集
私は(例えば。私はもうwinrowを使用しない)以下のようになり、私の方法を変更し、これは速く3倍の周りのようです。しかし、3行6列の表のセルを見つけるのにまだ7秒かかるので、まだかなり遅いです...
私はこの回答に後で受け入れられるとマークして、他の人に推薦するようにしますより良い何か
public static WinCell FindCellByColumnAndValue(this WinTable table, int colIndex, string strCellValue, bool searchHeader = false)
{
Playback.PlaybackSettings.SmartMatchOptions = Microsoft.VisualStudio.TestTools.UITest.Extension.SmartMatchOptions.None;
int count = table.GetChildren().Count;
for (int rowIndex = 0; rowIndex < count; rowIndex++)
{
WinCell cell = new WinCell(table);
cell.SearchProperties.Add(WinRow.PropertyNames.RowIndex, rowIndex.ToString());
cell.SearchProperties.Add(WinCell.PropertyNames.ColumnIndex, colIndex.ToString());
cell.SearchProperties.Add(WinCell.PropertyNames.Value, strCellValue);
if (cell.Exists)
return cell;
}
return new WinCell();
}
編集#2: 私はAndriiの提案@ごとにFindMatchingControlsを使用して試してみた、と私はほとんどそこだし、セルの列インデックス(c.ColumnIndex)以下のコードでことを除いて、間違った値を持つ..
public static WinCell FindCellByColumnAndValue2(this WinTable table, int colIndex, string strCellValue, bool searchHeader = false)
{
WinRow row = new WinRow(table);
//Filter rows containing the wanted value
row.SearchProperties.Add(new PropertyExpression(WinRow.PropertyNames.Value, strCellValue, PropertyExpressionOperator.Contains));
var rows = row.FindMatchingControls();
foreach (var r in rows)
{
WinCell cell = new WinCell(r);
cell.SearchProperties.Add(WinCell.PropertyNames.Value, strCellValue);
//Filter cells with the wanted value in the current row
var controls = cell.FindMatchingControls();
foreach (var ctl in controls)
{
var c = ctl as WinCell;
if (c.ColumnIndex == colIndex)//ERROR: The only cell in my table with the correct value returns a column index of 2, instead of 0 (being in the first cell)
return c;
}
}
return new WinCell();
}
ベンダーに問い合わせてください。 – leppie
MSDNフォーラムの[UI Automation Testing](http://social.msdn.microsoft.com/Forums/da/vsautotest/threads)セクションでは、通常、Coded UIに関する質問に対して非常に広範な回答が提供されることに同意します。 –
@leppie:yep、フォーラムにメッセージを投稿しました。私はちょうど答えを待っています。 – David