fuelcell
fuelcell

Reputation: 35

xpath find text within a table

I am trying to find and select the text "Paris" within a dynamic table. When I run my selenium tests it can find the table and it can verify the text "Paris" exists however it cannot click Paris

I think it's something like this:

/html/body/div[class='yui-dt-liner']/td/tr[contains 'Paris']/div

Or:

//div[class='yui-dt-liner']/table/tr[contains text(), "Paris"]/div

But I can't get it to work. Any help will be appreciated.

Upvotes: 0

Views: 9424

Answers (1)

user357812
user357812

Reputation:

Besides the "cannot click Paris" part (very much a Selenium specific type of question), both expression you'd provide are not sintactically correct.

Probably, they should be:

/html/body/div[@class='yui-dt-liner']/table/tr/td[contains(.,'Paris')]/div 

And

//div[@class='yui-dt-liner']/table/tr/td[contains(.,'Paris')]/div 

Note: @ abbreviated form of attribute:: axis. Correct contains() function syntax. You should better use the string value of the element (. is the abbreviated form of self::node()) instead of the first text node child.

Upvotes: 3

Related Questions