У меня есть несколько методов расширения, которые я использую для решения содержимого в таблицах (ручное кодирование, а не с помощью диктофона) -
Этого метод расширения для таблицы получает первую строку в таблице, которая содержит запрошенный текст в одном из своих клеток или контролирует
public static HtmlRow GetRow(this HtmlTable table, string cellContent)
{
if((UITestControl)table == (UITestControl)null)
throw new ArgumentNullException("table");
if(cellContent.Length > 80)
cellContent = cellContent.Substring(0, 80); //Our table cells only display the first 80 chars
//Locate the first control in the table that has the inner text that I'm looking for
HtmlControl searchControl = new HtmlControl(table);
searchControl.SearchProperties.Add(PropertyNames.InnerText, cellContent);
//Did we find a control with that inner text?
if(!searchControl.TryFind())
{
//If not, the control might be an HtmlEdit with the text
HtmlEdit firstTableEdit = new HtmlEdit(table);
//Get all of the HtmlEdits in the table
UITestControlCollection matchingEdits = firstTableEdit.FindMatchingControls();
//Iterate through them, see if any have the correct text
foreach (UITestControl edit in matchingEdits)
{
if(cellContent == ((HtmlEdit)edit).Text)
searchControl = (HtmlControl)edit;
}
}
//We have(hopefully) found the control in the table with the text we're searching for
//Now, we spiral up through its parents until we get to an HtmlRow
while (!(searchControl is HtmlRow))
{
searchControl = (HtmlControl)searchControl.GetParent();
}
//The control we're left with should be an HtmlRow, and should be an Ancestor of a control that has the correct text
return (HtmlRow)searchControl;
}
После того, как вы сможете получить правильную строку, она становится относительно легко получить правильный контроль в этой строке (или правильный контроль в данной клетке в том, что строка)
В вашем бывшем достаточно, у вас есть кнопка в 6-м столбце строки.У кнопки, вероятно, есть некоторые свойства, связанные с ней, но даже без них, если мы сможем правильно ограничить наш поиск, она все равно будет работать. Предположим, наши таблицы с именем UITableCustomers - Объявите новую кнопку и ограничить его только 6 (индекс 5) ячейки в строке, содержащей «John Smith»
Mouse.Click(new HtmlInputButton(UITableCustomers.GetRow("John Smith").Cells[5]));
Очевидно, что этот вызов идет на провал, если данный текст не существует в элементе управления в таблице.
Извините, я чувствую, что вы полностью не поняли вопрос –