Obviously, I can set the wait time. Is there a way to find out what the implicit wait time is set to in selenium? (C# specifically)
(The idea is to disable the ImplicitWait, do something, then reset it to whatever the time was before.)
Obviously, I can set the wait time. Is there a way to find out what the implicit wait time is set to in selenium? (C# specifically)
(The idea is to disable the ImplicitWait, do something, then reset it to whatever the time was before.)
As in docs (http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp) :
"An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance."
If you use the Page Objects pattern, keep the implicitlywait time in a field of the PageBase class, additionally, you would like to create some methods to reset or retrieve that value.
Sorry that the following example is in Java:
class PageBase {
private WebDriver driver;
private long implicitlyWaitTimeInSeconds;
public PageBase(WebDriver driver, long timeout) {
driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
implicitlyWaitTimeInSeconds = timeout;
this.driver = driver;
}
public void setImplicitlyWaitTime(long timeout) {
driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
implicitlyWaitTimeInSeconds = timeout;
}
public long getImplicitlyWaitTime() {
return implicitlyWaitTimeInSeconds;
}
...
}
class HomePage extends PageBase {
...
}
This can print real timeout value (plus calculating time, usually within 100ms) in Java but the idea is clear:
public void getCurrentWaitTimeout() {
long milliseconds = java.time.ZonedDateTime.now().toInstant().toEpochMilli();
driver.findElements(By.cssSelector(".nonExistingElement"));
milliseconds = java.time.ZonedDateTime.now().toInstant().toEpochMilli() - milliseconds;
log.info("Current waiting timeout is {} milliseconds", milliseconds);
}
So you can always call such a method to be sure you know actual timeout, not the value you tried to set.