开发者

Selenium, XPath-Nodesets and PHPUnit

开发者 https://www.devze.com 2023-03-11 04:23 出处:网络
using an expression like (//div[@class=\'nav\']//a)[5] to retrieve a specific element with Selenium (triggered through phpunit) never suceeds for some reason.

using an expression like (//div[@class='nav']//a)[5] to retrieve a specific element with Selenium (triggered through phpunit) never suceeds for some reason.

The Xpath is valid, using other Xpath expressions works fine, but once the Xpath contains brakets the Selenium server (2.0rc2) starts returning ERROR: Element (//div[@class='nav']//a)[5] not found. even it that element is present.

Is this a limitation of the PHP-Webdriver for Selenium, is there some kind of workaround (to get the nth element within a node-set)?

开发者_如何学编程

Cheers


From topic Can't get nth node in Selenium i see you can try prepending xpath= to your expression to get it work.


This was the final solution: xpath=(//div[@class='nav']//a)[position()=5]

Not sure why [5] didn't work, might still be an issue within phpunit

Cheers

0

精彩评论

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