Home > Blockchain >  How to declare WebDriver timeouts and how to manage their priority?
How to declare WebDriver timeouts and how to manage their priority?

Time:10-13

For the webdriver I set up at some early point of code

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

then later I declare something like that

WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(bla bla

or

new WebDriverWait(driver, 5).until(bla bla

and it seems it doesn't have effect I expect because it waits longer then 5 sec

What are the rulles for those timeouts?

CodePudding user response:

You should never mix implicit waits with explicit waits.
That means if you defined non-default value for implicitlyWait you should not use WebDriverWait in that driver session.
See the official recommendations saying Warning: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times. For example, setting an implicit wait of 10 seconds and an explicit wait of 15 seconds could cause a timeout to occur after 20 seconds.
Normally we always use WebDriverWait explicit waits only leaving implicitlyWait set to it default value 0.
You can see more explanations here and in more similar discussions.

  • Related