我现在被困在这上面一段时间了,所以我想我应该寻求帮助。我试图使用页面工厂机制(在构建的findElement API中使用的)来定位一个元素的名称。元素在网页上,但仍然找不到它。有人能指出我做错了什么吗?谢谢。
@FindBy(how = How.NAME, using = "userName")
private WebElement userName;
public WebElement getUserName() {
return userName;
}
homepage.getUserName().sendKeys("test");发布于 2017-02-03 04:22:03
你的代码看上去很好。但是,您可能需要在sendKeys之前添加一个等待,因为可能到那时页面还没有加载。
WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0,0,5));
wait.Until(By.Id("login"));希望能帮上忙!
https://stackoverflow.com/questions/42008834
复制相似问题