Hi,
This is my first post, I am trying to get all the rows in a table, but I find the table using the code below i.e.
WebDocument webDocument = "/dom[@caption='Ranorex Test Page' and @state='complete']";
TableTag myTable = webDocument.FindSingle(".//table[@id='simpletable']");
IList<TrTag> rows = myTables.Find("./tbody/tr");
The part of the html is shown below
<table id="simpletable">
<thead>
<tr>
<td>rows</td>
<td>name</td>
<td>value</td>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td>
<td>First element </td>
<td>red</td>
</tr>
<tr>
<td>2</td>
<td>Second element </td>
<td>green</td>
</tr>
Table Identification
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Table Identification
Hi zshadow,
Welcome to our Forum
I’ve checked your code and found some mistakes.
You have mistakenly used the TrTag instead of the TdTag and you have forgotten to add <TdTag> in the Find()-Method. Please also have a look at the parameter of the Find()-method. I used // in order to find all TdTags within the Tbody of your table.
I’ve also added a for-each loop to write the content of the rows into the Ranorex Report. But this was only for verification purposes.
Please have a look at the corrected code below:
Regards,
Markus (S)
Welcome to our Forum
I’ve checked your code and found some mistakes.
You have mistakenly used the TrTag instead of the TdTag and you have forgotten to add <TdTag> in the Find()-Method. Please also have a look at the parameter of the Find()-method. I used // in order to find all TdTags within the Tbody of your table.
I’ve also added a for-each loop to write the content of the rows into the Ranorex Report. But this was only for verification purposes.
Please have a look at the corrected code below:
WebDocument webDocument = "/dom[@caption='Ranorex Test Page' and @state=’complete’]"; TableTag myTable = webDocument.FindSingle(".//table[@id='simpletable']"); IList<TdTag> rows = myTable.Find<TdTag>("./tbody//td"); foreach(TdTag row in rows) { Report.Info(row.InnerText); }If you have any further questions, please do not hesitate to ask.
Regards,
Markus (S)