For Example I have specified driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
in my code . So ideally if the element is not present it should fail the test after 50 seconds . But it takes around 2 minutes to fail the test with element not found exception . Can someone explain the concept of implicit wait clearly ?

- 1,915
- 1
- 19
- 37

- 11
- 3
-
1Can you share your code for element not found exception ? Do you have explicit wait as well ? Are you mixing both of them ? – cruisepandey Apr 16 '19 at 04:41
-
Actually i am using POM pattern and below is (part of code) of the test which i am testing : portal.clickCustomSetup(true); portal.clickCustomCorporation(true); portal.clickClientPortalSettings(true); In all three methods implicit wait is mentioned(which i think is wrong ) . it should be mentioned in only one place of the test . please clarify . When i remove all three implecit wait code ran faster and it threw exception in less time . portal.checkReceiptDetailsCheckBox(true, 'c'); – Automation Keeda Apr 16 '19 at 05:05
1 Answers
As you have mentioned that you are using implicit wait in three methods and you think it's wrong, well the answer is - yes it is wrong.
See what selenium developers have mentioned :
Implicit wait :
An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.
So for a single execution, once you have written :
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
you do not need to write it again . even if you do there will be no impact on webdriver.
Note that the implicit wait work at the web driver level.
I would suggest you to write implicit wait code under fixtures or setup instance.
In case if you are using TestNG, you can use @BeforeMethod
annotation and can write the implicit wait there.
Let me know if you have anymore concerns.

- 28,520
- 6
- 20
- 38