【发布时间】:2016-09-01 05:44:18
【问题描述】:
这是一个我无法通过 xpath 或 CSS 选择器点击的下拉菜单。
我的 HTML 代码:-
<button class="userInfo dropdown-toggle btn btn-default" data-reactid=".0.0.0.1:$=11:$1.1" type="button"> <span class="sr-only" data-reactid=".0.0.0.1:$=11:$1.1.0">Toggle dropdown</span> <span class="caret" data-reactid=".0.0.0.1:$=11:$1.1.1"/> <span data-reactid=".0.0.0.1:$=11:$1.1.2" style="letter-spacing:-.3em;"/>
我尝试过的代码:-
driver.findElement(By.xpath(".//*[@data-reactid='.0.0.0.1:$=11:$1.1']")).click();
但我收到错误提示:-
找不到这样的xpath
【问题讨论】:
-
-
我试过 driver.findElement(By.xpath(".//*[@data-reactid='.0.0.0.1:$=11:$1.1']")).click();但错误说它找不到这样的xpath
-
元素是否在 iframe 中?如果是,则需要切换驱动程序以访问框架
-
因为你的xpath没有问题,我也在网页中本地测试过它并且可以工作
标签: xpath css-selectors click webdriver dropdown