Wednesday, February 13, 2008

Selenium IDE Flow Control - Goto and While Loops

tldr; https://github.com/73rhodes/sideflow

This extension provides goto, gotoIf and while loop functionality in Selenium IDE. Selenium IDE is a plugin for Firefox that automates the testing of web-based applications. There is an excellent flow-control extension at wiki.openqa.org/display/SEL/flowControl for the Selenium RC and TestRunner components, but it does not work with Selenium IDE (the Firefox plugin) directly. This makes it difficult to develop controlled test cases within Selenium IDE, and there are times when the frame-based TestRunner cannot be used (such as when the website under test employs a frame-buster script).

I've ported the existing control-flow extension to work in the Selenium IDE Firefox add-on. The image below shows a sample test case using goto, gotoIf and a while loop, all running successfully in Selenium IDE.



The file can be downloaded from Github and should be saved as "sideflow.js" to your hard drive. Then the Options settings in Selenium IDE should set the Selenium Core extensions to include the path of this file, similar to the image below.

I've published the extension on github.  Go ahead and download it from there. 


github.com/73rhodes/sideflow

Update 26 February, 2008:
This mod of the FlowControl extension works only with the Selenium IDE Firefox add-on. If you want to use the TestRunner component or Selenium RC, please use the original FlowControl extension.

Update 19 February 2011

I've moved the extension over to github


Update 7 July 2011
I've updated the example to use the newer syntax required in the latest versions of Selenium IDE.

Please note that if you are using Selenium RC, you should use the original flow-control plugin here: wiki.openqa.org/display/SEL/flowControl



Unfortunately I haven't had the time or the need to make this compatible with both Selenium RC and Selenium IDE.  Please feel free to fork the code on github and make a pull request if you would like to help out.

Update 24 July 2012
I added a "push" command to the plugin, with a simple example on the Github page. This allows you to easily create a collection of items and implement "for each"-style functionality to iterate over it. Here's the original announcement

208 comments:

«Oldest   ‹Older   201 – 208 of 208
John E. said...

I am trying to run my test suites through the command prompt while using extensions from user-extensions.js, but I keep getting one of two errors:

1 - unknown command 'gotoif'
2 - specified label 'NEXT81' is not found

These tests run perfectly through IDE, but once I try to execute from command prompt they fail at the 'gotoif' commands. PLEASE HELP ME!

Thanks,
John E.

Darren said...

As the blog post describes, this extension is a port of the original flow control extension for selenium RC. It is not compatible with Selenium RC and is only for use in Selenium IDE (the firefox plugin). If you want to use flow control on the command, use the original flow control library for Selenium RC. I don't know if it is still supported or works with the latest version of Selenium, however. You may want to consider alternatives like Mocha and Slimer.JS

Fabio Natale said...

Hey guys, can someone please help me?

I wanna create a while loop over all my testcases, but when my endWhile command is not in the same case there occurs following problem:
"There was an unexpected error. Msg: Error: non-matching while/endWhile found"

Does anyone have a solution for my problem?

sudha raman said...

hi nice article. what is the command for break the while loop in selenium like EXIT or BREAK.
for best selenium hands on practice selenium training in velachery

adam said...

I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.

adam said...

I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.

eu4 console commands said...

Explained very well for the beginners who donno anything about Selenium IDE.
Superb.. Keep it up.

xcom 2 cheats said...

Hi Selenium Tutorial,
I am new to JAVA and Selenium.
Thanks for your detailed explanation of the topics.

Thanks once again...

«Oldest ‹Older   201 – 208 of 208   Newer› Newest»

Productivity and Note-taking

I told a friend of mine that I wasn't really happy with the amount of time that gets taken up by Slack and "communication and sched...