Webdriver Script : Webdriver Wait Commands

There are different type of Webdriver Wait commands which are useful for an effective scripting and can avoid using the Thread.sleep() comamnds.

After searching, I have created a sample script explaining the types of wait commands. Mainly commands are categorize in two parts :

1. Using WebDriver.manage().timeouts()

- implicitlyWait : The ImplicitWait will tell the webDriver to poll the DOM for a certain duration when trying to find the element, this will be useful when certain elements on the webpage will not be available immediately and needs some time to load. By default it ill take the value to 0, for the life of the WebDriver object instance through out the test script.

- pageLoadTimeout : Sets the amount of time to wait for a page load to complete before throwing an error. If the timeout is negative, page loads can be indefinite.

- setScriptTimeout : Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error. If the timeout is negative, then the script will be allowed to run indefinitely.

2. Using support.ui

- FluentWait : Each FluentWait instance defines the maximum amount of time to wait for a condition, as well as the frequency with which to check the condition. Furthermore, the user may configure the wait to ignore specific types of exceptions whilst waiting, such as NoSuchElementExceptions when searching for an element on the page.

- ExpectedConditions : Models a condition that might reasonably be expected to eventually evaluate to something that is neither null nor false. Examples would include determining if a web page has loaded or that an element is visible. Note that it is expected that ExpectedConditions are idempotent. They will be called in a loop by the WebDriverWait and any modification of the state of the application under test may have unexpected side-effects.