New to Telerik Test Studio? Start a free 30-day trial
HTML Table Searching and Paging
I would like to search an HTML table for specific content and continue through the pages until it is found.
Solution
This is possible with a coded solution. The example below is against this Telerik demo site.
C#
HtmlTable table = Find.ByExpression<HtmlTable>("id=Grid", "|", "tagIndex=table:1");
HtmlSpan next = Find.ByExpression<HtmlSpan>("class=k-icon k-i-arrow-e");
HtmlAnchor a = Find.ByExpression<HtmlAnchor>("title=Go to the next page");
string search = "10275";
bool found = false;
bool disabled = false;
while (false == found && false == disabled)
{
foreach (HtmlTableRow row in table.AllRows)
{
foreach (HtmlTableCell cell in row.Cells)
{
if (cell.TextContent == search)
{
Log.WriteLine("Match found: " + cell.TextContent);
cell.MouseClick(MouseClickType.LeftDoubleClick);
System.Threading.Thread.Sleep(1000);
found = true;
break;
}
}
if (true == found)
{
break;
}
}
a.Refresh();
disabled = a.BaseElement.Content.Contains("disabled");
if (true == found || true == disabled)
{
break;
}
next.Click();
System.Threading.Thread.Sleep(1000);
table.Refresh();
}