org.openqa.selenium.InvalidSelectorException

时间:2014-10-16 17:59:54

标签: java selenium

我正在尝试运行程序。没有testng它工作正常。但是,当我使用TestNG运行时,它可以顺利运行所有登录方案,但是当它注销XPath时它会说

FAILED: Testloginpager
org.openqa.selenium.InvalidSelectorException: The xpath expression '//a[contains(text(),'Log out')]' cannot be evaluated or does notresult in a WebElement (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 5.19 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html

但我在Mozilla中尝试了相同的XPath,发现它是该注销Web元素的正确路径。

1 个答案:

答案 0 :(得分:0)

可能是报价?

我没有使用xPath,所以我没有经历过这种情况,但可能会尝试双引号"而不是单引号。

或者你可以试试这个:

而不是By.xpath()。使用:

By.linkText("Log out");