Sunday, May 25, 2014

Test Automation: Waits in WebDriver



Waits are very important in test automation. Here are some usages of waits in WebDriver

1.     Suppose you click on a button and a popup appears. The appearance of the popup depends on the visibility of an element. If you inspect the element carefully, it will look something like the following



This is how you can solve this:



As you will notice, there are lots of other built in expected conditions that you may use as required.




2.     Suppose waiting for visibility of an element is not good enough. You have to wait for its attributes to have certain value. For example, you save an item and you have to wait for the save successful message. It appears as follows:


If the save goes wrong, system shows error message in the same element. It appears as follows:


So waiting for the visibility of element is not good enough here. You have to also verify the text. Here is what you can do:


3.     Suppose you have to select an option from a dropdown. And the value of dropdown depends on the value of another element. So before you select the option, you have to wait for it to be there. This is how  you can do it:


Try the above and have fun. Hopefully you will find this helpful.

No comments:

Post a Comment