0
所以與硒3.4我以前的工作wait.until
s不工作(被新方法取代)。我似乎無法得到新的方法工作。硒3.4如何使用改變wait.until
我使用
import com.google.common.base.Function;
舊代碼:
public boolean waitForURLToMatch(String expectedURL, int waitTime){
WebDriverWait wait = new WebDriverWait(driver, waitTime);
wait.until(EcpectedConditions.urlMatches(expectedURL));
}
新代碼:
public boolean waitForURLToMatch(String expectedURL, int waitTime){
WebDriverWait wait = new WebDriverWait(driver, waitTime);
wait.until(new Function<WebDriver, boolean>){
@Override
public boolean apply(WebDriver driver) {
return driver.getCurrentUrl().equals(expectedURL);
}
}
}
新的代碼在Eclipse中的錯誤: Syntax error on tokens, InterfaceHeader expected instead
關於我出錯的地方有什麼想法?
['urlMatches']](https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html#urlMatches-java.lang.String-)將檢查正則表達式,使用'urlToBe'或'urlContains'。此外,如果你沒有使用任何明確的番石榴函數庫的功能,那麼就沒有必要更新那個了。那裏提到的錯誤已經在最新版本中修復 – Madhan
@Madhan感謝您的回覆,我將如何使用urlToBe或urlContains,直到方法已被更改,謂詞已被刪除,現在只有直到(Function <?super WebDriver,V> isTrue)。 我不確定我提到過的任何錯誤嗎? – AutomationTester
在'wait.until()'中使用'ExpectedConditions'。 – Madhan