Sunday, 14 July 2013

Example of "while" and "endWhile" Loop Commands In Selenium IDE With Use Of User Extension

How to use "while" and "endWhile" command in selenium IDE
"while" command is not supported by default in selenium IDE. Selenium IDE also not supporting any conditional(if condition) commands by default. To get support of "while" loop as a Advanced Selenium IDE feature, You need to attach user extension with selenium IDE. You can read my post about how to attach user extension with selenium IDE.

I shared user extension file for "while" loop command. Click here to download selenium IDE user extension file for "while" and "endWhile" Commands and save it in your hard drive(only in .js format)
with name "user-extension.js" and attach it with selenium IDE as shown in bellow figure.

After attaching selenium IDE user extension file, You need to restart your selenium IDE window to get its effect. Once you restart your selenium IDE, you are ready to use "while" and "endWhile" command with selenium IDE. Copy-paste bellow given example script for "while" command in your selenium IDE and run it to view how it works.

New Test
whilestoredVars.MyVar <= 3
highlightcss=img[alt="Selenium Logo"]

(Note : You can look at this selenium IDE tutorial posts to be master in just 7 days).

In above example, look at command execution sequence carefully. "while" loop will be rotated 3 times and execute all inner(commands between "while" and "endWhile") commands for 3 times. Here syntax, "storedVars.MyVar <= 3" with "while" command will check value of "MyVar" every time and keep running until it becomes <=3.  Inner javascript ("javascript{storedVars.MyVar++;}") will increase the value of variable "MyVar" every time by 1 which was set to 1 initially. Above script will high lite selenium logo on selenium site for 3 times.

Subscribe To Get Post Updates Via Email

Enter your email address:

Delivered by FeedBurner