what is need of explicit wait if we can set implicit wait for more amount of time at once?

841 Views Asked by At

we declared implicit Wait of 10 secs but an element takes more than that, say 20 seconds and sometimes may appears on 5 secs, so in this scenario, Explicit wait is declared.

anytime implicit wait don't wait for the default time it will stop waiting once element is visible

2

There are 2 best solutions below

0
On

It's generally bad practice to mix your implicit and explicit waits -- rather, you should stick with doing one or the other, and not both, if possible.

Based on the problem you described -- you can increase your implicit wait to 30 seconds to account for long loading times, and the wait will be finished even if the element only takes 5 seconds to load.

I prefer explicit wait because I can perform negative wait too. Sometimes, I want to wait until a certain element is NOT visible on the page. With explicit wait, my wait is finished as soon as element disappears. However, with implicit wait, you will have to wait the full 30seconds to know if element has disappeared or not.

0
On

Differences between implicit wait and explicit wait in selenium webdriver :

Implicit Wait

Applied on entire page

Once you declared implicit wait it will be available for the entire life of web driver instance

Wait is suggested

Implicit Wait is applicable for all web elements that are on a web page

No conditions involved

Only checks for the presence of web elements

Explicit Wait

Applied on an element

It will be used if we want the execution to wait for some time until some condition achieved.

Wait is directly expressed

Explicit wait can applied against a single or multiple web elements

Involves conditions provided by ExpectedCondition class’s static methods

Waiting period with certain conditions.