Pages

Selenium IDE "gotoif" "gotoLabel" and "label" commands with example

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.

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.

The error you guys are getting could be because there is no space in the label TRYAGAIN. If you look at the error result "TRY AGAIN" has a space. Check you have the label correctly written with no space.

Is there a way to introduce a variable in a label name? For example, if you store a unique identifier as a variable, is it possible to incorporate that variable into a label name. for example (and I'm not concerned about format accuracy in most of this)store | 123456 | Xgotoif | X < 99999999 | ${X}blahstore | new number X+1 | Xlabel | ${X blah} |

would be extremely handy. I've played with it some to no avail. Is it possible?