我试图让函数等待Selenium中的元素。Selenium webdriver java等待元素存在
private WebElement waitIsClickable(By by, int n) throws Exception{
WebDriverWait wait= new WebDriverWait(driver,/*seconds=*/ n);
wait.until(ExpectedConditions.elementToBeClickable(by));
return driver.findElement(by);
}
但是,当我想用它:
waitIsClickable(By.id("logIn"), 20).click();
我得到一个错误:
Error:(1057, 20) java: method waitIsClickable in class Functions cannot be applied to given types; required: org.openqa.selenium.By,int found: org.openqa.selenium.By reason: actual and formal argument lists differ in length
int参数将被装箱到很长时间。这不是问题(再次查看错误消息)。 – Guy
@Guy哦,你是对的错误状态预计两个参数,而找到一个。感谢指出.. :) –
@Guy但调用参考看起来不错,因为OP提供 –