Selenium, XPath-Nodesets and PHPUnit
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
精彩评论