I have a html table like:
<table ..... class="cars">
<tr class="item-odd">
...
</tr>
<tr class="item-even">
</tr>
</table>
How could I get the table rows using xpath?
//tr[contains(@class, ???)
can I use OR in there somehow to say item-odd|item-even
Number of columns of the web table in Selenium are calculated using XPath (//*[@id='customers']/tbody/tr[2]/td). XPath of the rows and columns are obtained using the inspect tool in the browser to handle tables in Selenium for automated browser testing.
You can get the rows like this:
//table[@class='cars']/tr
To get the item-odd rows, you would do this:
//table[@class='cars']/tr[@class='item-odd']
Yes, you can use or
, e.g.:
//table[@class='cars']/tr[@class='item-odd' or @class='item-even']
See http://www.w3.org/TR/xpath for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With