Selenium 4 and WebDriver implicitlyWait

In out Selenium projects we use Implicit waits and fluent waits. Basically, we use Implicit waits until we need something explicit. E.g., for normal findElements() calls we depend on the implicit wait, but when waiting for an element to disappear after clicking some button we use a fluent wait. (See code below).

The problem is that lately I’m seeing a number of timeouts when calling implicityWait(n). This seems new. Maybe even in Selenium 4.3. Cannot say for sure, but it has certainly become bothersome. To be clear, “occasionally” means a couple of times over a couple of hundred tests (each calling implicitlyWait dozens of times).

public void waitUntilElementDisappear(By locator, int waitTime) throws Exception, TimeoutException {
    Logger.log(String.format("Waiting [%ds] for [%s] to disappear", waitTime, locator));
    try {
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(waitTime));
    } catch (TimeoutException e) {
        Logger.log("Caught timeout exception");
        throw e;
    } catch (Exception e) {
        Logger.log(String.format("Caught exception message:[%s]", e.getMessage()));
        throw e;
    } finally {

The issue occurs only in the finally block. (DEFAULT_WAIT is usually 180).

Any suggestions?

Read more here: Source link