Selenium get value of current implicit wait

For those who came here from google. In 2018 it seems like there is a method to get those timeouts at least in javascript (I know question was about java):

const {implicit, pageLoad, script} = await driver.manage().getTimeouts();

Hope this will help.


Unfortunately there's no getter for that.

http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html

There isn't for explicit waits either.

http://selenium.googlecode.com/svn/trunk/docs/api/java/com/thoughtworks/selenium/Wait.html


I know I'm a couple years late, and @JaneGoodall is not wrong -- there is no built-in function for that. But it's not impossible!

It's not very difficult to create your own versions of the WebDriver interface and browser-specific driver class. And then, you can put whatever code you want into the driver!

Example:

MyDriver.java (specialized version of WebDriver, not quite mandatory but a very good idea):

public interface MyDriver extends WebDriver {
    void setWait(int timeout);
    int getWait();
}

MyChrome.java (specialized version of ChromeDriver -- works the same for any browser)

public class MyChrome extends ChromeDriver implements MyDriver {
    int timeout = 0;
    public void setWait(int timeout) {
        this.timeout = timeout;
        this.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
    }
    public int getWait() {
        return timeout;
    }
}

And now, to use it, MyProgram.java:

public class MyProgram {
    MyDriver driver = new MyChrome();
    driver.setWait(10);
    assert(driver.getWait() == 10);
}

I hope this is helpful!