I am new to Selenium. I am working with c#. There is a table like this . I saw it using FireBug.
<table>
<tbody>
<tr class="v-table-row-odd"></tr>
<tr class="v-table-row"></tr>
<tr class="v-table-row-odd"></tr>
<tr class="v-table-row"></tr>
<tr class="v-table-row-odd"></tr>
<tr class="v-table-row"></tr>
</tbody>
</table>
And the issue here is I am not knowing how to get the number of rows in a table which changes dynamically. Is there any way??
Tried xpathCount but got some exception issues..
decimal numOfRows = selenium.GetXpathCount("xpath=/html/body/div/div/div[2]/div/div[3]/div/div[2]/div/div/div[2]/div/div/div/div/div[7]/div/div/div[2]/div/table/tbody/tr");
I also tried xpathCount like this
selenium.GetXpathCount("xpath=/html/body/div/div/div[2]/div/div[3]/div/div[2]/div/div/div[2]/div/div/div/div/div[7]/div/div/div[2]/div/table/tbody");
But both raised exceptions. Can anyone help me out in this regard.
Thank You
If it’s the only table with rows marked with those class names, you could just use:
If not, then you need to find a better way of locating the
table. Something is not quite right with your (very long) XPath selector which starts from the very top of the document. There’s nothing inherently wrong about this, but with a dynamic webpage it is very hard to get right.Instead, you need to locate an element closer to your
tableand then filter within that. If for instance, if one of yourdivs has anameattribute, you could use//div[@name='someName']//tr. For more information about using XPath selectors, see here.