Implicit wait

Implicit wait is a way to tell the Appium driver to poll the DOM (Document Object Model) for a certain amount of time before throwing an exception to the effect that it can't find the element on the page. The default timeout value is set to 0 seconds. Once we set the implicit wait to a specified time, it persists for the life of the webdriver object instance. How to set an implicit wait is explained here:

appiumDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

So, what this implies is letting the driver instance wait for a maximum of 10 seconds before throwing the NoSuchElement exception. We need to be watchful about the implicit usage. The Appium boilerplate generally gives us the code with the implicit wait implementation, so note the preceding line in the HomePageWebSteps class file, as shown:

appiumDriver = new AppiumDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
appiumDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

Increasing the implicit wait timeout should be used judiciously as it will have an adverse effect on the overall test execution time, especially when used with slower locator strategies, such as xpath.

This just removes a lot of indeterministic wait from the code. Implicit wait is most suited when there is a variation in app response time due to network speed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.96.86