1

If explicitely wait is having default polling time i.e. 500ms then why don't it throws an exception after first 500ms if the condition is not satisfied?

What is the role of default polling time in explicite wait?

  • Can you show the code that confuses you? – Alexey R. Mar 10 '23 at 14:07
  • The exception is thrown by the driver but the webdriverwait ignores this exception and polls again... until timeout period is reached, condition is met, or an exception is thrown that it does not ignore. WebDriverWait is a pre-configured fluentwait. See here: https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/WebDriverWait.html – pcalkins Mar 10 '23 at 21:44

1 Answers1

0

I think you are mixing/getting confused between polling time and wait time.

Polling time: is the repeated time interval at which selenium tries to locate an element in the DOM

Wait time: is the maximum time it will wait trying to locate the element, after which it will throw timeout exception

In the below code, selenium tries to locate the element for 40s before it throws timeout exception. And in those 40s, it tries to locate/poll every 2s. If you do not add this line wait.pollingEvery(2, TimeUnit.SECONDS);, then by default it will try to locate/poll every 500ms(0.5s)

WebDriverWait wait = new WebDriverWait(driver, 40);
        wait.pollingEvery(2, TimeUnit.SECONDS);
        wait.until(ExpectedConditions.elementToBeClickable(element));

This is my understanding. Hope this helps.

Shawn
  • 4,064
  • 2
  • 11
  • 23