开发者

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'开发者_C百科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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜