Selenium IDE "waitForCondition" Command Tutorials With Example

We can use  "waitForElementPresent" command to wait till element appears on page. One other command "waitForTextPresent" command to wait till text display on software application page. Sameway, "waitForCondition" command will wait for condition until targeted condition not match. This selenium
command is very useful to take action based on condition. Let we take one example scenario.

Scenario :
I have 1 software web application page with some input elements. There is one button and on completion of page load, button gets enabled after 10 seconds. Now suppose i want to click on button when button gets enabled then what will i do? "waitForElementPresent" command will not work in this situation because my targeted element is already there but disabled so i can't click on it. "waitForCondition" command will help you in this condition. Bellow is one practical example.

New Test
CommandTargetValue
openhttp://only-testing-blog.blogspot.com/2013/09/testing.html
waitForConditionselenium.browserbot.
getCurrentWindow().document.
getElementById('submitButton').
disabled == false
15000
pause1000i
clickid=submitButton

Run above test case in your selenium IDE. In above example, "waitForCondition" will wait for 15 seconds to get enabled 'Submit Query' button. If it will not enable in 15 seconds then selenium IDE will return "[error] Timed out after 15000ms" in execution log. This is just one example and you can use it for other conditions like element disable on software application page after 10 seconds too.

No comments:

Post a Comment