Verify that the item can be clicked without an explicit wait time

As stated by Selenium Documentation , we should never mix explicit and implicit wait times:

WARNING. Do not mix implicit and explicit expectations. This can lead to unpredictable waiting times. For example, setting an implicit wait of 10 seconds and an explicit wait of 15 seconds can cause a timeout after 20 seconds.

I set an implicit wait time of 5000 ms. At the end of some interaction with the browser, I just want to check if the necessary links are available.

I know that this can be done using ExpectedConditions, but this implies an explicit wait time, as in the example below.

protected PageNewDocument isElementClickable(WebElement element)
{
    (new WebDriverWait(driver, 1)).until(ExpectedConditions.elementToBeClickable(element));
    return this;
}

, ?

+4
1

. true. , .

private static WebDriverWait wait = new WebDriverWait(driver, 60);
private static JavascriptExecutor js  = (JavascriptExecutor) driver;

public static void waitForPageLoaded() {
            wait.until(new ExpectedCondition<Boolean>() {
                public Boolean apply(WebDriver driver) {
                    Boolean res = (js.executeScript("return document.readyState").equals("complete"));
                    System.out.println("[DEBUG] waitForPageLoaded: " + res);
                    return res;
            }
    });
}
0

All Articles