【发布时间】:2016-01-06 19:55:20
【问题描述】:
我有这个 HTML 代码:
<ul id="globe-welcome" class="fr nav welcome">
<li class="guest" style="display: list-item;">
<a class="loginlnk">LOGIN</a></li></li></ul>
我想选择带有文本Auto 的标签选项标识的WebElement。我试过这个:
driver.findElement(By.xpath("//a[contains(@class,'loginlnk')]"))
我遇到了这个错误:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"/select[@id=category]/option[@id=cat2]"}
Command duration or timeout: 1.52 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
我尝试了另一个 xpath。
什么是正确的语法?有人可以帮我吗?
【问题讨论】:
标签: javascript java selenium xpath