Search Here!

Saturday, April 13, 2013

Selenium 2: WebDriver Waits and AJAX Wait

Different Wait Methods –

1. Explicit Wait (), Thread. Sleep (): it is not recommended, and should not use.

Reason(s):
1. You can never predict exact wait time.
2. It increases overhead.
3. It may not work with all computers.

2. ImplicityWait (): use it.

Reason(s):
1. Specifies the amount of time the driver should wait when searching for an element if it    is not immediately present.

3. pageLoadTimeout(): use it when website is slow.

Reason(s):
1. Sets the amount of time to wait for a page load to complete before throwing an error.

4. setScriptTimeout(): use it when you want to limit the test suite duration.

Reason(s):
Sets the amount of time to wait for an asynchronous script to finish execution before  throwing an error.

5. WebdriverWait(): use it with class Expected Conditions to handle AJAX calls.

Reasons:
1. elementSelectionStateToBe - An expectation for checking if the given element is
2. selected.elementToBeClickable - An expectation for checking an element is visible and enabled such that you can click it.
3. elementToBeSelected - An expectation for checking if the given element is selected.
4. frameToBeAvailableAndSwitchToIt - An expectation for checking whether the given 5. frame is available to switch to. 
5. invisibilityOfElementLocated  - An expectation for checking that an element is either invisible or not present on the DOM.
6. invisibilityOfElementWithText - An expectation for checking that an element with text is either invisible or not present on the DOM. many more...

No comments:

Post a Comment