Incompatible types when calling WebDriverWait() after upgrade to 4.3.0

5,776 views
Skip to first unread message

Frank Høvin

unread,
Sep 28, 2022, 3:49:38 AM9/28/22
to Selenium Users
After upgrading from 3.1.x to 4.3.0 I get the following error(s)

incompatible types: java.lang.Long cannot be converted to java.time.Duration

in Browser.java -> setBrowserTimeouts(), calling WebDriverWait:

standardWait.set(new WebDriverWait(driver.get(), waitTimeout));

waitTimeout is an int parameter. It seems to complain about the wrong format, but WebDriverWait still takes a long parameter for timout. Converting the calling line to Duration or Long doesn't work or help.

Any ideas?



ddlionx

unread,
Sep 28, 2022, 4:09:56 AM9/28/22
to seleniu...@googlegroups.com
Replace waitTimeout from an in to:

Duration.ofSeconds(long seconds)

Where seconds is the intended duration. 

Or make the input of the method Duration.ofSeconds(waitTimeout)

Whichever. 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/a68eb92c-94bc-425e-a5d0-9c66411ef3c5n%40googlegroups.com.

Frank Høvin

unread,
Sep 28, 2022, 4:37:00 AM9/28/22
to Selenium Users
If I replace the waitTimeout like this:

standardWait.set(new WebDriverWait(driver.get(), Duration.ofSeconds((long)waitTimeout)));

I get this error:

Required type:
long
Provided:
Duration

Frank Høvin

unread,
Sep 28, 2022, 4:45:09 AM9/28/22
to Selenium Users
Even the exact same line mentioned in the Selenium upgrade documentation doesn't work in my case:

driver.get().manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

This gives the error

implicitlyWait(long, java.util.concurrent.TimeUnit)' in 'org.openqa.selenium.WebDriver.Timeouts' cannot be applied to '(java.time.Duration)'

kadambari saran

unread,
Sep 28, 2022, 4:46:47 AM9/28/22
to seleniu...@googlegroups.com
Try 
private final TIMEOUT = 10;

TimeUnit.SECONDS.toSeconds(TIMEOUT) in wait condition.




Mallichetty Hemanth Kumar

unread,
Sep 28, 2022, 4:50:12 AM9/28/22
to seleniu...@googlegroups.com


driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);

Mallichetty Hemanth Kumar

unread,
Sep 28, 2022, 4:50:50 AM9/28/22
to seleniu...@googlegroups.com
WebDriverWait wait = new WebDriverWait(driver, 30);

Frank Høvin

unread,
Sep 28, 2022, 5:56:50 AM9/28/22
to Selenium Users
Sorry for being slow-witted here, but I'm not sure where?

Here's my entire method where the errors occur:

public static void setBrowserTimeouts(int scriptTimeout, int implicitWait, int waitTimeout) {
        if (driver == null) {
            throw new NullPointerException("Browser.init() må kjøres før man kan kalle driver-instansen");
        }
        driver.get().manage().timeouts().setScriptTimeout(scriptTimeout, TimeUnit.SECONDS);
        driver.get().manage().timeouts().implicitlyWait(implicitWait, TimeUnit.SECONDS);
        globalWaitTimeout = waitTimeout;
        standardWait.set(new WebDriverWait(driver.get(), waitTimeout));
    }
Reply all
Reply to author
Forward
0 new messages