flowControl

attached zip file contains required js code (working with selenium 0.6) + tests/examples.
Separate js files are attached for selenium versions > 0.6

Examples of implemented commands:

gotolabel / label

Unconditional jump

gotolabel testlabel1  
.... ....  
label testlabel1  

gotolabel parameters:

  1. a label to jump to

gotoIf / label

Conditional jump

gotoIf /corrrect caption/i.test( storedVars.pagetext ) testlabel1
.... ....  
label testlabel1  

gotoIf parameters:

  1. javascript expression
  2. label to jump to if javascript expression evaluated as true

(obsolete) assertNoFailureOnNextAndGoto / assertNoErrorOnNextAndGoto / label

this command is dropped in extension for Selenium Core v.0.8+

Jump if following command passed

assertNoFailureOnNextAndGoto testlabel1  
verifyText element correct page
open ./pageneeded.html  
label testlabel1  

while/endWhile

Cycle

store 0 loop2
while storedVars.loop2 < 2  
store javascript{storedVars.loop2++}  
endWhile    

while parameters:

  1. javascript expression.

FAQ

Q: Can the flowControl extension be used in Selenium IDE?

A: according to the following thread it can: http://clearspace.openqa.org/message/20977#20977

however, I do not use S-IDE and therefore will recommend to ask guys on corresponding (S-IDE) forum

Q: I am using this extension along with 'include' extension and getting error like "'While' is not found"". What do I do?

A: add following code at the end of IncludeCommand.prototype.doInclude function. (as per http://forums.openqa.org/thread.jspa?threadID=10163 )

if( htmlTestRunner.currentTest.initialiseLabels )
{ htmlTestRunner.currentTest.initialiseLabels(); }

NOTE:This answer refers to the IncludeCommand.prototype.doInclude function, which did not work for me.  Farther down in this forum there's a reference by Jerry Qianto putting this code in the Selenium.prototype.doInclude function, which did work for me.  In addtion, since I was using IDE, changed the code to:

if( this.initialiseLabels )
{ this.initialiseLabels(); }

You will also need to add this at the end of doEnd$Template$ so that goto's after includes to work.

 

Additional Sources:

File: 

AttachmentSize
Plain text icon flowControlIDE.js.txt3.97 KB
Plain text icon flowControRC.js.js.txt4.24 KB

Type: 

User-Extension

1 Comment

Interesting comment:

Interesting comment:
 

Since many people work on both Core and IDE, they need a unified version for flowControl extensions.
IDE version: http://51elliot.blogspot.com/2008/02/selenium-ide-goto.html
The simplest way to combine IDE version and this Core version is writing below code in your user-extensions.js.
var sel_locstr = window.location.href;   if(sel_locstr.indexOf("selenium-ide.xul") != -1){ //IDE mode          // paste IDE extension here }else{    // paste Core extension here }
Enjoy!