SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

Selenium IDE "assertAlertNotPresent" and "assertAlertPresent" commands examples

"assertAlertNotPresent" and "assertAlertPresent" are assertion commands of selenium IDE. Both are works with alert box appears when you take some action. Both works opposite to each other as assertion. Both these commands are completely different than "assertAlert" and "assertNotAlert" commands. Let me
describe you them with example.

"assertAlertNotPresent" Command
"assertAlertNotPresent" command will becomes pass successfully if there is not any alert on page of your software web application during its execution. If there is any alert present on page during its execution then it will return '[error] true' in execution log and selenium IDE will abort execution.

"assertAlertPresent" Command
Opposite to "assertAlertNotPresent" command, "assertAlertNotPresent" command will be executed without any error if there is any alert message present on web application page. Else it will return "[error] false" in execution log.

New Test
CommandTargetValue
openhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_alert
assertAlertNotPresent

assertAlertPresent


Execute above example. In above example, "assertAlertNotPresent" will becomes pass but "assertAlertPresent" will return '[error] false' in error log because there is not any alert present on page.

New Test
CommandTargetValue
openhttp://www.w3schools.com/js/tryit.asp?filename=tryjs_alert
selectFrameview
clickcss=input[type="button"]
assertAlertPresent

assertAlertNotPresent


Now in this example, "assertAlertPresent" command will be pass successfully but "assertAlertNotPresent" will return '[error] true' in log because there is alert present on page during its execution.

In this way, you can assert and stop execution if expected alert appears on page or expected alert not appears on page at some stage of your software regression testing phase.

No comments:

Post a Comment