Access table rows
Posted: Thu Feb 21, 2013 10:55 am
I have a <table> on a webpage that can have a variable amount of table rows, and I would like to know how I could iterate through these and pull out the data inside each.
In addition, the table's ID tag is a GUID, so essentially the table has no identifying information. So the only way I can access the table is to keep a reference to the first row in the Ranorex repository, then backtrack to the table tag and go from there.
The current XPath I am using:
As you can see I am skipping over the table id with a regex, and then finding the first row with a regex that matches data with 'aaa' or 'bbb'.
To sum up, some pseudo code for what I am trying to do:
Is this possible with the API?
ps. I'm open to using other ideas, but this is the only way I found that might work (new to Ranorex API)
In addition, the table's ID tag is a GUID, so essentially the table has no identifying information. So the only way I can access the table is to keep a reference to the first row in the Ranorex repository, then backtrack to the table tag and go from there.
The current XPath I am using:
Code: Select all
//table[@id~'.*']/tbody/tr[1]/td[@title~'.*(aaa|bbb).*']
To sum up, some pseudo code for what I am trying to do:
Code: Select all
if (repo.tableData.Exists)
{
var table = repo.tableData.ParentRow.ParentTable;
var listOfInvalidCellsFound;
loop (rows in table)
{
loop (cells in row)
{
if (aaabbbRegex.IsMatch(cell.Text))
listOfInvalidCellsFound.Add(cell.Text);
}
}
}
ps. I'm open to using other ideas, but this is the only way I found that might work (new to Ranorex API)