Page 1 of 1

XPATH with a table and containing keyword

Posted: Tue Oct 17, 2017 12:45 pm
by Grumish
Hi guys,

I have few tabs in my html and one of these tabs contains a table. Problem is that the position of specific tab changes.
Normally I would use for example:
//div[@id='TabbedPanels1']/div/div[6]/table/tbody/tr[2]/td[3]

as in this case the tab im interested in is 6th from left (div[6]).
But now instead of div[6] i need to put 'contains "name"' but I have no idea how to combine that with my code. I'd appreciate any help!

thanks

Re: XPATH with a table and containing keyword

Posted: Tue Oct 17, 2017 2:33 pm
by Costin
Hi Grumish,

If I correctly understood, you want to select a table cell from some "div" node(s) that is/are grandchild(ren) of the "div" element whose id is 'TabbedPanels1'.

You could try something like:

Code: Select all

//div[@id='TabbedPanels1']/div/div[contains(., 'name')]/table/tbody/tr[2]/td[3]
if you need to select from all the "div" grandchildren nodes that contain 'name'
and

Code: Select all

//div[@id='TabbedPanels1']/div/div[contains(., 'name')][1]/table/tbody/tr[2]/td[3]
if you need to select only from the 1st grandchildren node containing "name"

I hope this helps!
Costin