How can I use XPath to click a button in a table in a specific position? The column is constant and it is always the last row. I have the id of the table, but the cell contains a delete button, whose value is dynamic - a generated hash value.
Xpath = ".//[@=id='blah']/tbody/tr[5]/td[5]" # <- this xpath fails.
This is for automation - python using the selenium.
WebElement Lastrow =driver. findElement(By. xpath("//table[1]/tbody/tr["+lastRowcount+"]")); In first Line we get the Last Row count from the table.
Let's select an element in the web table and find its XPath. For Chrome, right-click and inspect the given element to find its XPath. To find the XPath of a UI element in Firefox, right-click on the desired element, go to “Inspect Element” to open the inspector which will help identify its XPath.
You can also do this way using only last()
function :
Xpath = ".//*[@=id='blah']//tr[last()]/td[5]"
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