Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would suggest to perform direct looping through child controls - according to my experience searching controls with complicated search crieteria in Coded UI often works slow.</p> <p><strong>Edit:</strong></p> <p>To improve performance it is better to remove counting table's children and looping through rows. Also to avoid exception when finding control without row number you can use <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.uitesting.uitestcontrol.findmatchingcontrols.aspx" rel="nofollow">FindMatchingControls</a> method, like in following:</p> <pre><code> public static WinCell FindCellByColumnAndValue(this WinTable table, int colIndex, string strCellValue, bool searchHeader = false) { Playback.PlaybackSettings.SmartMatchOptions = Microsoft.VisualStudio.TestTools.UITest.Extension.SmartMatchOptions.None; WinCell cell = new WinCell(table); cell.SearchProperties.Add(WinCell.PropertyNames.ColumnIndex, colIndex.ToString()); cell.SearchProperties.Add(WinCell.PropertyNames.Value, strCellValue); UITestControlCollection foundControls = cell.FindMatchingControls(); if (foundControls.Count &gt; 0) { cell = foundControls.List[0]; } else { cell = null; } return cell; } </code></pre> <p>When table field will be searched directly in the table it will save time for counting child controls in table. Also searching without <code>for</code> loop will save time for search of field for each iteration of row number that does not match.</p> <p>As row number is iterated through all available values in your extension - it is not essential search criterion in the long run. In same time each iteration through a row number value invokes additional control search request - eventually multiplying method's execution time by the number of rows in grid.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload