Skip to content

Instantly share code, notes, and snippets.

@uluQulu
Created December 23, 2018 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uluQulu/abd5a1bbafe8e3643f45b557f5da94a6 to your computer and use it in GitHub Desktop.
Save uluQulu/abd5a1bbafe8e3643f45b557f5da94a6 to your computer and use it in GitHub Desktop.
Clash: implicit wait ⚔ explicit wait

There are some points to be taken into account:

1-) implicit wait has the highest priority
It currently is being controlled with page_delay parameter with the default value of 25

  • page_delay parameter is customizable by user
  • User can give it 1 seconds if likes

2-) What is implicit wait?

  • implicit wait sets the [max] time it can wait while finding elements

3-) What is explicit wait?
It waits for several cases;
Currently, our generic explicit_wait() function has these tracks:

  • "visibility of element located" |> implicit wait cannot guarantee the visibility, it rather does existence
  • "title contains" |> implicit wait can't do it
  • "page fully loaded" |> implicit wait can't do it
  • "staleness of" |> implicit wait can't do it

Clash: as you can see, they seem to do mainly ~the same thing (e.g. at "VOEL" track) in some portion that's why people suggest to use either one;
And let's consider the visibility of the element is not important for us and just existence is enough.
Okay let's see this situation below 👇🏼

Problem: user sets implicit wait (a.k.a page_delay) as 3 seconds;
And inside program there are crucial places WHERE it has to wait e.g. 9 seconds OR it has to wait ENOUGH TIME to find the required element;
Why are those crucial? - cos if they fail, the outcome will be HIGHLY WORSE (see some of the use cases of the explicit_wait() function);
But since implicit wait is set to 3 seconds, it will cause a misbehaviour.

Explicit wait solves it!
It goes to find that element and cannot find in 3 seconds (implicit wait timeouts) and returns;
explicit wait tries to find it again, second time 3 seconds flies and can't find it;
explicit wait goes to find again (7th second) and finds it;
👆🏼 extreme stabilitiy 🙌🏼💪🏼💪🏼

If there were no explicit wait, THAT less delay in implicit wait would cause an early/serious CRASH/FAILURE.

I wrote in some threads and just found this post of mine you can read more on my implicit wait foundings.


Cheers 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment