<div class="myclass">
<span>...</span>
<div>
<table>
<colgroup>...</>
<tbody>
<tr>...</tr>
<tr>
<td>
<input ...name="myname" ...>
</td>
</tr>
<tr>...</tr>
<tbody>
</table>
</div>
</div>
this is my html code ... I have attribute "name" ..so I can access tag ...but from this line I want to access top element.
One way is that I write driver.find_element_by_xpath('..')
6-7 times to get that parent but I dont know how many steps I have to go above. I simply want a xpath expression or similar thing to access top .
I'm using Selenium webdriver with python
Instead of targeting a deeper level element and going up in the tree, you can select the higher level element and test for a descendant node attribute:
.//div[@class="myclass"][.//input[@name="myname"]]
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