0

I implemented a loop with a counter to check elements are found repeatedly until 5 seconds or whatever Time I set. Why because I knew for one that selenium still has to poll/Scan the dom to find the element. I am not sure if selenium automatically is notified if there is a mutation in the dom itself.

I believe Implicit and explicit wait also does the same as I tried. It has to do repeated find operations till given timeout value to find if a element exists. But I rather wanted granular control over how quickly I perform the repeated scan so I can find it faster.

My Question is

  1. is my assumptions correct ?.
  2. Does implicit and explicit wait does repeated find, delayed by a certain default wait time before it does the find operation again?
  3. Does it mean theoretically we can deprecate Explicit wait and implicit wait due the availability of fluent waits.?
  4. Is there a default polling time in Implicit and explicit waits?.
2
  • Search for "fluent wait" Commented Mar 21, 2019 at 13:37
  • I am interested if Explicit wait is gonna have default polling time in built [ which is 0?]
    – Hi X Dmf
    Commented Mar 21, 2019 at 16:53

3 Answers 3

1

Implicit wait implementation is itroduced in webdriver itself so how exactly it is implemented depends on the particulat webdriver manufacturer. When you set implicit wait in your code it just sends the request to webdriver saying: "Hey, set up this timeout and apply to every element that is looked up within the session". Default value is 0. So you can just make an experiment with creating some dynamic page that would add elements to DOM with certain frequency and check how the implicit wait is working in your particular webdriver.

Explicit wait (at least in Java binding) is implimented using FluentWait class where you can set up the frequency you would poll your DOM for certain conditions met. There is also WebdriverWait class that extends FluentWait where some predefined frequency (2 times a second) is used.

5
  • Wow really ? Explicit wait in Java is Fluent wait with default polling time ? is that what you mean?
    – Hi X Dmf
    Commented Mar 21, 2019 at 14:44
  • It is both. Explicit means you wait for certain element explicitly. It is just the term that define an aproach. With no any concrete implementation behind it. If you will implement your own that would work on demand for a target element that would also be Explicit wait.
    – Alexey R.
    Commented Mar 21, 2019 at 15:08
  • If I were to repeatedly find elements in a loop with no wait time, I believe it should be called as Fluent wait with customized Polling time as 0. Correct me if I am wrong. However I am not able to navigate to actual Explicit wait where we can see it repeatedly scanning dom to find an element with 0 wait times between consecutive scan and prove that its a extension of Implicit wait..
    – Hi X Dmf
    Commented Mar 21, 2019 at 16:40
  • @AlexeyR I suggest you post an example of a fluent wait so the OP can understand how the polling does indeed differ from the wait time. Commented Mar 21, 2019 at 16:55
  • I have plenty of examples of Fluent/Explicit/Implicit wait. I was looking for actual source code which has default polling times ..
    – Hi X Dmf
    Commented Mar 21, 2019 at 18:49
0

Implicitwait : We cannot define frequency of polling Explicitwait : can define frequency of polling

Reference : https://stackoverflow.com/a/27854319

Suggestion : explore how fluentwait is implemented and how its used . Fluent wait provides more customisation and more control to you compared to explicitwait

2
  • user37723 + Alexey "If you want to specify the polling time, then you should probably start using Explicit Waits." this is in that link you gave above. Which I dont think is correct I think you are confused about polling time vs Wait time/timeout.
    – Hi X Dmf
    Commented Mar 21, 2019 at 16:42
  • Polling should represent a next scan delayed by a certain time interval. How does first of all selenium know if a element is present or not unless it scans the dom repeatedly ? so there is a wait time maxout and there is a time interval which should be the polling time. Fluent wait has polling time, not Explicit wait. Which should mean according to your definition, a default polling time should exist for Explicit wait
    – Hi X Dmf
    Commented Mar 21, 2019 at 16:43
0
  1. Explicit wait -- Try to Find, if not found, Wait until some time (My specified time) and error out ( unsaid assumption, keep polling meanwhile, with default time, which cannot be modified by users )
  2. Implicit wait -- Try to Find, if not found, Wait for some time (Using my specified time) and try to find it again and error out
  3. Fluent -- Try to Find, if not found, Wait and keep checking every few (Using my specified) seconds until this (user specified my own max) time and then error out

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.