Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xpath select cell in table being in last row in fixed column position

Tags:

xpath

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.

like image 994
boserwolf Avatar asked May 08 '14 23:05

boserwolf


People also ask

How do you select the last row in selenium?

WebElement Lastrow =driver. findElement(By. xpath("//table[1]/tbody/tr["+lastRowcount+"]")); In first Line we get the Last Row count from the table.

How do I find the XPath of a column?

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.


1 Answers

You can also do this way using only last() function :

Xpath = ".//*[@=id='blah']//tr[last()]/td[5]"
like image 192
har07 Avatar answered Nov 23 '22 17:11

har07