Below code will help to get the data from table cell…

BrowserWindow browser = BrowserWindow.Launch(new System.Uri(“http://YourWebApplicationURL.com”));

HtmlTable table = new HtmlTable(browser);
//Below line will identify the table object.
table.SearchProperties.Add(“Id”, “Table_ID”);

for (int i = 1; i <= 1; i++)
{
for (int j = 1; j <= 8; j++)
{
HtmlCell cell = new HtmlCell(table);
cell.FilterProperties[HtmlCell.PropertyNames.RowIndex] = i.ToString();
cell.FilterProperties[HtmlCell.PropertyNames.ColumnIndex] = j.ToString();

//Below statement will get the value of row 1 and cell 1

if (i == 1 && j == 1)
{
Cell1 = cell.InnerText.ToString();
}

}
}
if (Cell1.Trim().Equals(“12345678”))
{
Console.WriteLine(“Pass”);
}
else
{
Console.WriteLine(“Fail”);
}

Advertisements

4 thoughts on “How to read html table cell data with CodedUI (C#)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s