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
Command Target Value
open http://docs.seleniumhq.org/
setSpeed 1000
store 1 MyVar
while storedVars.MyVar
<= 3
echo ${MyVar}
highlight css=img[alt="Selenium
Logo"]
store javascript{storedVars.MyVar++;}
endWhile
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.
No comments:
Post a Comment