0
我在Windows 8.1中使用Eclipse版本:Luna Release(4.4.0)。我有一个工作正常的硒(V 2.53)代码。当我使用Junit时无法通过ID查找元素
f.get("https://mail.yahoo.com");
f.findElement(By.id("login-username")).sendKeys("jj%jo.com");
WebElement element = f.findElement(By.id("login-username"));
String text = element.getAttribute("value");
System.out.println(text);
但是,当我在Project> BuildPath中添加Junit v4.12和TestNG时,代码无法找到该元素。
@Test
public void testFindUsername(){
f.findElement(By.id("login-username")).click();
f.findElement(By.id("login-username")).sendKeys("[email protected]");
}
Error: Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"login-username"} For documentation on this error, please visit:
如果其他人有这个问题,请让我们知道解决的办法。
谢谢
使一些等待后得到的URL – noor
得到它的工作,谢谢。 –