我試圖讓函數等待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提供 –