As described in my previous post("while" and "endWhile" commands with example), selenium IDE software testing tool not supporting any conditioning and looping commands and to get support of "gotoif" "gotoLabel" and "label" commands, you have to attach user extension with selenium IDE software automation testing tool. This is Advanced Selenium IDE feature. Click here to download user extension and attach it with selenium IDE and restart selenium IDE software testing tool's window. Now you can use "gotoif" "gotoLabel" and "label" commands with selenium IDE software automation.
"gotoif" Command in selenium IDE
As name suggest, "gotoif" command will jump on defined label if condition match. And if not found conditional match then it will execute immediate next command.
Using "gotoLabel" command in Selenium IDE
"gotoLabel" will simply jump on targeted label. It not requires any conditional match to jump on label.
Use of "label" command with "gotoif" and "gotoLabel" command
"label" command used for catching jump which is fired from "gotoif" or "gotoLabel" commands.
Let we learn all three commands with example as bellow.
|echo||YOUR BOTH URLs ARE NOT SAME|
|echo||YOUR BOTH URLs ARE SAME NOW|
Run above example in your selenium IDE software testing tool and see command execution sequence very carefully. Let me describe execution process step by step.
- "storeLocation" command will store current opened URL "https://www.google.com/" in variable "CurrentURL".
- "store" command will store "http://www.bing.com/" in variable "TempURL"
- Now "gotoIf" command will check and compare value of variable "CurrentURL" and variable "TempURL" and jump on defined label "NOTSAMEURL" if not found same value in both the variables. In our example, "CurrentURL" contains "https://www.google.com/" and "TempURL" contains "http://www.bing.com/" so that condition does not match and execution pointer will jump on label "NOTSAMEURL" and will execute next 2 commands "echo" to print "YOUR BOTH URLs ARE NOT SAME" in log and pause command.
- Next command "gotoLabel" will move pointer at label = "TRYAGAIN".
- Now "store" command will store "https://www.google.com/" in variable "TempURL"
- Once again, next command "gotoIf" will check and compare value of variable "CurrentURL" and variable "TempURL" and now value of both the URLs are same so it will not jump on defined label but will execute next command "gotoLabel" to jump on label = "SAMEURL".
- Last command will print "YOUR BOTH URLs ARE SAME NOW" and your test will be completed.
Try above example with different scenarios. Let me know by posting comment bellow this post if any face any issue.