【发布时间】:2017-10-04 22:00:12
【问题描述】:
实际上我尝试在登录页面中检查用户名和密码是否正确。 所以我编写了即将登录的代码。当注销按钮可见时检查用户是否有效。
但我的说法无效
driver.findElement(By.id("username")).sendKeys(sUsername);
driver.findElement(By.id("password")).sendKeys(sPassword);
driver.findElement(By.name("login")).click();
boolean logvisibile = driver.findElement(By.xpath(".//*[@id='account']/ul/li[2]/a")).isDisplayed();
Thread.sleep(1000);
if(logvisibile == true)
{
System.out.println("Succesfull");
}else
{
System.out.println("Failed");
}
}
**输出:
失败:测试(“testuser_1”,“Test@123”) org.openqa.selenium.NoSuchElementException:无法定位元素: {“method”:”xpath”,”selector”:”.//*[@id='account']/ul/li[2]/a”} 命令 持续时间或超时:10.06 秒有关此错误的文档, 请访问:http://seleniumhq.org/exceptions/no_such_element.html**
【问题讨论】: