2

I have been reading all the posts regarding implicit and explicit wait. I am really sorry to post this question once again, but none of the existing post gives an answer to my question or maybe I did not understand the concept properly.

I am able to understand the Explicit wait concept, but what I really don't understand is the statement "An implicit wait is to tell Web-driver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available." Does it mean that the Web-driver polls the DOM every 500 milliseconds to find the element (until it returns successfully) just like explicit wait does? If yes, how does it increase the execution time?

PS: My apologies for posting this question once again and as I told you, there are lots of articles which provide different information and it confuses me a lot.

shank087
  • 492
  • 8
  • 17
  • Please have a look at http://stackoverflow.com/questions/10404160/when-to-use-explicit-wait-vs-implicit-wait-in-selenium-webdriver – TechDog May 07 '16 at 11:10
  • @TechDog, does it take the whole implicit wait time or stops when it returns successfully just like explicit wait? – shank087 May 07 '16 at 12:39
  • As per my understanding, it stops when it returns successfully.... – TechDog May 07 '16 at 12:59
  • 1
    http://stackoverflow.com/questions/27831757/does-selenium-implicit-wait-always-take-the-entire-wait-time-or-can-it-finish-so?rq=1 – TechDog May 07 '16 at 13:05
  • awesome..thank you...I was looking for the same.. – shank087 May 07 '16 at 13:29
  • You have the same wonder with mine But it's seem no one has fully understood your question yet. I wonder about what it do precisely exactly in the DOM, yes how many msecond for 1 polling? I expect it to poll only 0.2 sec/1 polling time otherwise it will slow down the computer. – Zui Zui Aug 08 '23 at 05:41

2 Answers2

1

I think implicit wait is more concerned with the requirement like, we are okay if the element takes few seconds to come on to the screen. This is the time we have to put for implicit wait. The default wait time for implicit is zero. If we don't declare then it will throw Element Not Found Exception. (Better to give more seconds for less internet speed, slow application response)

I have created one scenario practically where we can confirm that implicit wait checks DOM continuously (you can call polling):

execute the post condition like verifying the text without performing the prior condition like submitting the button. Since we have not clicked on button through script-selenium cannot find the element, still it will not throw Element Not Found Exception and it waits for the 5min(implicit wait set) to complete.

Then, I will click on button within 1min shows the text on the web page. Immediately, the step is passed and went ahead with the rest of execution. This confirms that - implicit wait is polling DOM intermittently or else it should wait for 5min to check the element(But that didn't happen).

Coming to the polling interval - this is some where less than a second as per my observation

-2

Implicit Wait will force driver to wait for specified amount of time when any element on the page is not immediately visible. So, implicit wait will wait implicitly for specified time, for all the elements which are not immediately visible, hence increasing the execution time drastically. After the specified time is passed, if the element is visible, then it will start execution. There is no polling in implicit wait.

Whereas in explicit wait, it will wait till a condition is satisfied. If the condition is satisfied, it will stop waiting and starts execution. In this type, it will poll for 500 milli seconds to check for the condition.

Hope this clarifies your question.

k.s. Karthik
  • 731
  • 6
  • 16
  • Implicit wait waits within the max set time limit, till it finds the element, unlike Thread. sleep(), it does not wait for the complete duration of time – user2044296 Jul 08 '22 at 08:46