There are too many commands starting with "verify" and "assert" text. Both these commands are same excluding one difference and that difference is after execution of "verify" command if condition is match or not match selenium will execute next commands but in case of execution of "assert" command if condition
returns false then selenium will stop remaining command's execution.
returns false then selenium will stop remaining command's execution.
Let me show you that difference with "verifyAlert" and "assertAlert" commands with examples. You can view "assertAlertNotPresent" and "assertAlertPresent" commands example here. Both these commands are also very useful in software testing using selenium IDE.
"verifyAlert" command
New Test | ||
Command | Target | Value |
open | http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert | |
selectFrame | view | |
click | css=input[type="button"] | |
verifyAlert | Hello! I am an alert box!1 | |
selectWindow | null | |
assertTitle | Tryit Editor v1.6 |
In this example, verifyAlert will verify alert message text with text "Hello! I am an alert box!1". Here it will show error message in log because real text of alert box is "Hello! I am an alert box!". but even after error selenium will execute remaining 2 commands. Here it will not show you error in log if given text "Hello! I am an alert box!" at place of "Hello! I am an alert box!1" with verifyAlert command.
"assertAlert" command
Same as verifyAlert command, "assertAlert" will also verify text and take action on alert box but if alert text not matches then it will stop execution. See bellow given example.
New Test | ||
Command | Target | Value |
open | http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert | |
selectFrame | view | |
click | css=input[type="button"] | |
assertAlert | Hello! I am an alert box!1 | |
selectWindow | null | |
assertTitle | Tryit Editor v1.6 |
In this example, assertAlert command will show error because alert text "Hello! I am an alert box!1" is not matching with real alert text "Hello! I am an alert box!" and it will not execute remaining 2 commands.
Nice post with great details. Thanks for sharing. Like it.
ReplyDeleteemergency alert software
Can any one let me know how to create user defined alert in selenium IDE and how to record vertical and horizontal scroll in selenium IDE....
ReplyDeleteTo generate alert In selenium IDE, you can see bellow given link
Deletehttp://software-testing-tutorials-automation.blogspot.in/2013/11/selenium-ide-runscript-command-example.html
Not get your second question properly about vertical and horizontal scroll. Please describe your scenario