我正在尝试运行程序。没有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元素的正确路径。
答案 0 :(得分:0)
可能是报价?
我没有使用xPath,所以我没有经历过这种情况,但可能会尝试双引号"
而不是单引号。
或者你可以试试这个:
而不是By.xpath()
。使用:
By.linkText("Log out");