2017-04-26 42 views
-1
public boolean WaitForPageToLoad(){ 

final ExpectedCondition<Boolean> pageLoadCondition = new ExpectedCondition<Boolean>() { 
     public Boolean apply(final WebDriver driver) { 
      return ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete"); 
     } 
    }; 

    final WebDriverWait wait = new WebDriverWait(this.driver, this.defaultTimeoutinSeconds); 
    final boolean IsPageLoad = wait.until(pageLoadCondition); 

    if (!IsPageLoad) { 
     log.logInfo("Page doesn't load after " + this.defaultTimeoutinSeconds + " seconds"); 
    } 
    return IsPageLoad; 
} 

上面的代碼工作在硒2.53.1,但是當我升級到硒3.1.X,上面的代碼是不兼容的。 Plaese任何轉換上面的代碼,使其與硒3兼容。我得到以下錯誤
在類型FluentWait直到(功能)的方法是不適用的參數(新ExpectedCondition(){})等到頁面加載完全使用硒3?

+0

[wait.until(ExpectedConditions)不工作更多的硒(可能的重複http://stackoverflow.com/questions/42421148/wait-untilexpectedconditions-doesnt-work更多在硒) – JeffC

+0

你谷歌錯誤?這已經被問及幾次回答。 – JeffC

回答

0

此代碼的工作對我來說Selenium3

driver = (new Driver(Driver.Browser.SAFARI)).getDriver(); 

driver.navigate().to("http://www.epochconverter.com/"); 

waitForLoad(driver); 

static void waitForLoad(WebDriver driver) { 
    new WebDriverWait(driver, 50).until((ExpectedCondition<Boolean>) wd -> 
    ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete")); 
} 
相關問題