Selenium IDE "waitForAlert" and "waitForAlertPresent" commands with example

As you know, there are many waitfor commands available in selenium IDE to handle wait conditions of software web applications. Each and every one has different purpose. "waitForAlert" and "waitForAlertPresent" commands are related to alerts. You can view more alert related commands list with
example on selenium IDE commands page 1 and page 2. Now let me describe you selenium IDE "waitForAlert" and "waitForAlertPresent" commands with examples.

"waitForAlert" Command
"waitForAlert" command will wait till targeted alert displayed on page. Once targeted alert displayed on page, "waitForAlert" command will automatically accept that alert and then go for executing next command.

New Test
CommandTargetValue
openhttp://only-testing-blog.blogspot.com/2014/01/new-testing.html
waitForAlertNow you can click on submit query button!
clickAndWait//input[@id='submitButton']

In above example, "waitForAlert" command will wait for alert to appear on page and once alert appears on page, it will accept alert and go for executing next command.

"waitForAlertPresent" Command
"waitForAlertPresent" command will only wait for the alert to appear on the page but it will not accept alert by it self. This is the main difference between "waitForAlert" and "waitForAlertPresent" commands.

New Test
CommandTargetValue
openhttp://only-testing-blog.blogspot.com/2014/01/new-testing.html
waitForAlertPresent

verifyAlertNow you can click on submit query button!
clickAndWait//input[@id='submitButton']
In above example, "waitForAlertPresent" command will wait for alert to appear on page but it will not accept it. Nest "verifyAlert" command will accept it and will go for executing next command.

No comments:

Post a Comment