Dashboard > Selenium > ... > Contributed User-Extensions > flowControl
Selenium Log In View a printable version of the current page.
flowControl
Added by Andrey Yegorov, last edited by Andrey Yegorov on Sep 21, 2007  (view change)
Labels: 
(None)

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://forums.openqa.org/thread.jspa?messageID=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 )

Unknown macro: { htmlTestRunner.currentTest.initialiseLabels(); }

I was not able to jump back to a label using gotoIf or gotoLabel. Would it be possible to add this feature? I need it!

Thanks,

JPT

Posted by JPT at May 04, 2006 10:44

me too, gottolabel does not work, it shows the following error:

[error] Unexpected Exception: message -> gotoLabels has no properties, fileName -> file:C:\Program Files\Mozilla Firefox\components\user-extensions.js, lineNumber -> 72, stack -> gotoLabel("test1","")@file:C:\Program Files\Mozilla Firefox\components\user-extensions.js:72 call([object Object],"test1","")@:0 ([object Object],[object Object])@chrome://selenium-ide/content/selenium/selenium-commandhandlers.js:193 ()@chrome://selenium-ide/content/selenium/selenium-executionloop.js:65 ()@chrome://selenium-ide/content/selenium/selenium-executionloop.js:32 ()@chrome://selenium-ide/content/selenium/selenium-executionloop.js:28 executeCommand("http://www.google.com/",[object Object])@chrome://selenium-ide/content/selenium-runner.js:252 ([object Object])@chrome://selenium-ide/content/debugger.js:81 ()@chrome://selenium-ide/content/treeView.js:396 ("cmd_selenium_exec_command")@chrome://selenium-ide/content/treeView.js:78 doCommand("cmd_selenium_exec_command")@:0 goDoCommand("cmd_selenium_exec_command")@chrome://global/content/globalOverlay.js:93 onxblkeypress([object KeyboardEvent])@chrome://selenium-ide/content/selenium-ide.xul:0 @:0 , name -> TypeError

please help 

Posted by RALPH at May 20, 2006 02:46

did you use Selenium version 0.7 or 0.6? The only version extension was tested with is 0.6.

Chris:

 Could you post the hacked version? Thanks.

Posted by Ai Li at Jun 19, 2006 16:34

Hack fix added as attachment.  GotoIf works if the label you're jumping to comes after the call for it.  I haven't been able to get it to work with a label that is earlier in the test.  While not included (couldn't hack it).

Newer version of my hack fix uploaded.  Adds the while command back in.  Multiple while loops within a test are supported, nested whiles are not.  Also, since I forgot to state it with the previous version, this fix for gotoIf the extension no longer deletes your results.  While loops do appear to destroy results however.

 And for anyone who is trying to make this work with the include extension, at the end of the doInclude function add:

gotoLabels = initialiseGotoLabels();
whileLabels = initialiseWhileLabels();

Yet another new version uploaded.  Fixed loss of results using while and bug that would cause the same with goto if the include extension was used anywhere other than the first line of a test.

Hi Chris,

Thanks for all the great work you're doing. I am trying to get your addon to work with Selenium 0.7.1 and I get an error at line 22 of the goto.js file. Apparently, the HtmlTest object no longer exists in this version of Selenium. Either that, or I am missing a dependency somewhere. Would you know what's going on here?

Thanks in advance, Wouter van Reeven

I uploaded version wich worked with core 0.7.1

Hi Andrey,

Thank you so much for your extremely fast response! I downloaded and tried the new version of goto.js and it does indeed work. Great stuff! Many thanks again!

Greets, Wouter

Hi Andrey,

This goto action is a great addin. But after I download the newest goto.js but can't use it.
The javascript error is:

1. in line 22, HtmlTest is not defined.
2. in line 29, initialiseTestLoop is not defined.

How to solved this.

Thanks in advance,
Mingjian

What version of Selenium are you using?

attached version for selenium core 0.8.

For Selenium Core .8 - I am referencing the goto_sel08.js file directly in my "Selenium Core extensions" path. On load of Selenium IDE, I get error message:
"Failed to load user-extensions.js!
files=

Unknown macro: {path to file}
\goto_sel08.js
error=ReferenceError: HtmlRunnerTestLoop is not defined
[OK]"

Sorry for my ignorance. What am I missing? I had previously loaded the zip file, and ran into issue with .8 core - commands were recognized but then I got errors on gotolabel.

Best Regards,
-Rob

Rob,

I have never used Selenium IDE and so far not planning to.
I tested extension with Selenium Core and it worked.

There are a chances that something in S-IDE requires changes or extension needs to be updated to work under S-IDE.
At this moment I am leaving detailed troubleshooting & fixing of this problem to parties interested in making it work with S-IDE.

got the error below with Selenium IDE:

error loading Selenium IDE extensions: ReferenceError: HtmlRunnerTestLoop is not defined

Dear Andry & All,

This is a great extension save my life a lot.

But I came across an owsome problem, when I tried to use it with include command (another powerful user extension).

<tr>
	<td>include</td>
	<td>transaction/withdrow.html</td>
	<td></td>
</tr>
<tr>
	<td>gotoIf</td>
	<td>${moneyInHand} < ${price}</td>
	<td>skipBuy</td>
</tr>
<tr>
	<td>include</td>
	<td>../transaction/Buy.html</td>
	<td></td>
	<td>Buy the good</td>
</tr>
<tr>
	<td>label</td>
	<td>skipBuy</td>
	<td></td>
</tr>

When the condition in 'gotoIf' satisfies it jumps to an incorrect row. This happens since the table extends by including few additional rows from 'transaction/Withdrow.html' script.

Is there anyone who tried a work arrond this problem?

Sumith

Work around for above issue has been sorted out in http://forums.openqa.org/thread.jspa?threadID=5833 - Sumith

I've tried to add the extension goto_sel08.js and I also got the error below with Selenium IDE:
error loading Selenium IDE extensions: ReferenceError: HtmlRunnerTestLoop is not defined

Can someone tell me, what the gotoif statement is all about?

/corrrect caption/i.test( storedVars.pagetext )

what means correct caption?

in the examplefiles provided with the package they use gi.test(...) and the description here says i.test(...) what is right?

"/corrrect caption/i" is a regular expression (look for RegExp in javascript's documentation)
test() is a method of RegExp object

you can translate that code as
var re = new RegExp( "corrrect caption", "i" );
re.test( storedVars.pagetext )

I added descriptions of parameters on this wiki page.
hope it helps.

Hi Andrey,

Please can you put some light on this error? I found that lot of person struck with this problem. Otherwise provide some alternative solution for loop.

For Selenium Core .8 - I am referencing the goto_sel08.js file directly in my "Selenium Core extensions" path. On load of Selenium IDE, I get error message:
"Failed to load user-extensions.js!
files= \goto_sel08.js
error=ReferenceError: HtmlRunnerTestLoop is not defined
OK "

Thanks,
Mahesh

Posted by Mahesh at Feb 27, 2007 23:04

The issue in above post (comment) is addressed in http://forums.openqa.org/message.jspa?messageID=19612#19612.

When I download the user attachment "ZIP Archive selenium-goto.zip" it does not have the files to run the practice tests called "./tests/html/test_click_page1.html" Why not? It is tougher to learn from tests that do not run!

But this is a cool plugin.

Posted by nick at Mar 14, 2007 10:16

I was wondering if is there any way to set a timeout to a set of instructions, so we can use the gotoif command until we get what we expect.
For instance:
----------------
(set timeout here)
label label1
...
gotoif 'condition' labelEnd
gotolabel label1
label labelEnd
(step fails if doesn't reach labelEnd before timeout)
----------------
Or any other way to do that?

Thanks,

btw, great extension!

Posted by Ivan at May 30, 2007 15:59

Ivan,

I think what you want to do can be easily implemented as:

[timestamp = store current time]
[do necessary step]
[assert (current time - timestamp) < expected_execution_time ]

That worked, thanks!

Posted by Ivan at May 31, 2007 11:04

Hello,

I am a bit confused now. Can the flowControl extension be used in Selenium IDE? It gives me an error:

[error] Unexpected Exception: message -> currentCommandRow is not defined

Also, I am not sure what I should do with goto_sel08.js file, as when I try to load it, it gives me an error.

Any help will be appreciated.

Posted by goggyy at Jun 24, 2007 16:00

> Can the flowControl extension be used in Selenium IDE?

according to the following thread it can:
http://forums.openqa.org/thread.jspa?messageID=20977

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

I need to wait for "some text" will appear on the page and then the test must go on.

label testlabel
gotoif 'condition' testlabel

If "some text" doesn't apeear on the page and the 'condition' is true, it have to go to the "testlabel" upper and assert the 'condition' again.

What kind of condition must I write to assert that "some text" is not presented on the page?
How it will look like?

Thanks a lot!

> If "some text" doesn't apeear on the page and the 'condition' is true, it have to go to the "testlabel" upper and assert the 'condition' again.

I suggest to use waitForCondition (seehttp://openqa.org/selenium-core/reference.html ).

for example (I did not test the code):
waitForCondition | javascript

Unknown macro: {selenium.isTextPresent( "some text" )}
| 60

I am a newbie working with selenium IDE. All I want is to loop through a defined set of pages infinitely. I have firefox 2.0.4 installed with the latest selenium IDE version 0.8.7. I installed one of the selenium extensions which enables the gotoLabel command from:

http://wiki.openqa.org/display/SEL/flowControl

But after running the test, I get the following error when the test reaches the "goto" command:

[error] Unexpected Exception: message -> gotoLabels has no properties, fileName -> file:///C:/Selenium-goto/user-extensions.js, lineNumber -> 72, stack ->
gotoLabel("start","Title")@file:///C:/Selenium-goto/user-extensions.js:7
2 apply([object Object],[object Array])@:0 ("start","Title")@chrome://selenium-ide/content/selenium/scripts/htmluti
ls.js:60 ([object Object],[object
Object])@chrome://selenium-ide/content/selenium/scripts/selenium-command
handlers.js:307
()@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop
.js:112
(-10)@chrome://selenium-ide/content/selenium/scripts/selenium-executionl
oop.js:78 apply([object Object],[object Array])@:0 (-10)@chrome://selenium-ide/content/selenium/scripts/htmlutils.js:60 @:0 , name -> TypeError=20

Please let me know what should be done to get the test working. There's an above post regarding the same, asking to use Selenium 0.6. Does that still hold valid? Thanks a lot!

Posted by Sonik at Jun 27, 2007 11:09

> Clease let me know what should be done to get the test working.

according to the following thread it can:
http://forums.openqa.org/thread.jspa?messageID=20977

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

> There's an above post regarding the same, asking to use Selenium 0.6

version for S-Core 0.8.0 is available

> I suggest to use waitForCondition (seehttp://openqa.org/selenium-core/reference.html ).
>
> for example (I did not test the code):
> waitForCondition | javascript
> Unknown macro:
Unknown macro:
Unknown macro:

Unknown macro: {selenium.isTextPresent( "some text" )}

> | 60

The problem is that I don't need to use the "timeout" option. I need to wait 'till the condition will be false not after 30, 60 or more seconds. The "timeout" in my situation must be unlimited.

I will write conditions which I need in words such as [condition]:

label testlabel1
gotoif [verify that an "error message" present on the page] testlabel2
gotoif [verify that "some text" doesn't present on the page] testlabel1
label testlabel2

Andrey, do you speak russian? Can you write me to my e-mail miniok@mail-dot-ru? Or to ICQ 6665503.

Thanks!

Mikhail,

try something like

label testlabel1
gotoif selenium.isTextPresent( "error message" ) testlabel2
gotoif !selenium.isTextPresent( "some text" ) testlabel1
label testlabel2

p.s. yes, I do speak Russian. However, generally I am not available for 'private consultations', language does not matter. Forums are more reliable place to get answers (I just cannot guarantee that I will read/answer questions within somewhat acceptable for you timespan).

Andrey, thanks a lot!

But can you help me please in installation of the plugin?
I'm using Selenium Core 0.8.2 .
I have put "goto_sel08.js" file into the "scripts" directory and have added the contents of the "user-extensions.js" (from "selenium-goto.zip") to my "user-extensions.js" file.
Then have restarted the server.

When I write the test like:

1. label testlabel
2. gotoif "condition" testlabel

it doesn't go to the label. It allways goes straight. 1, then 2... and so on.

Please, write me, how to install the plugin correctly!

Thanks!

selenium-goto.zip contains extension compatible with selenium 0.6.0
I believe that you need to use goto_sel08.js which works with selenium 0.8.0 (unless you are using old s-core 0.6.0)

there are self tests for the extension in the zip file that you can use as example and to test the extension.

I am trying to run TestSuite-goto
but selenium core gives me error as
Selenium failure. Please report to selenium-dev@openqa.org, with error details from the log window. The error message is: 'gotoLabels' is null or not an object

I don't know how to add user extensions. i have added user-extentions.js & goto_sel08.js in ..core/scripts/ folder is it write or please tell me correct method

Please help me in this issue

Posted by Sachin at Feb 06, 2008 00:55; last updated at Feb 06, 2008 01:13

Great extension... I also needed a version that would work within Selenium IDE (as opposed to the TestRunner).

So... there's a version of Flow Control for Selenium IDE at http://51elliot.blogspot.com/2008/02/selenium-ide-goto.html

It works for basic goto, gotoIf and while loops within Selenium IDE.

Hope this helps.

Posted by Darren at Feb 22, 2008 15:13

Hi All,

I read all the comments and really got confused ...
Can some one please tell me latest version in which while,and gotolabel works... and also where to put goto.js and goto_sel08.js files?

Thanks,
Jay

Posted by Jayant at Feb 26, 2008 12:08

Hi ALL,
GotoLabel part is working for me for core8.0 version but when i am using 'while' command...it passed this step , performs first open statement and fails at the second command. For example in below script my script gives a "Permission denied error" at clicking Gmail link:

<tr>
<td>store</td>
<td>0</td>
<td>var1</td>
</tr>
<tr>
<td>store</td>
<td>2</td>
<td>var2</td>
</tr>
<tr>
<td>while</td>
<td>$

Unknown macro: {var1}
<=$
Unknown macro: {var2}
</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>http://www.google.co.in/</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>3000</td>
<td></td>
</tr>

<tr>
<td>clickAndWait</td>
<td>link=Gmail</td>
<td></td>
</tr>
v
<tr>
<td>store</td>
<td>javascript

Unknown macro: {storedVars.var1++}
</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>

Please help
Thanks in advance
Jay

Posted by Jayant at Feb 26, 2008 13:40

Hi !

I'm working with selenium core 0.8 . I downloaded the goto_sel08.js and put it into core/scripts. Also I downloaded the .zip file and copy only the tests and the test suite into /test directory. All the tests failed and all have the same error " Unknown command : " for gotolabel, goto, assertNoFailureOnNextAndGoto and while commands.

Could anyone tell me whats wrong ???

Many Thanks

Posted by Cynthia Ramos at Feb 27, 2008 14:38; last updated at Feb 27, 2008 15:09

Hi !

I found my own error . I didn't change the name of the goto_sel08.js to user-extensions.js.
Now it works !!

Thanks

I used this file for my test script. And I put this file into core\scripts but when i run test script by Selenium Core. The 'While' loop doesn't identify. and change its name to user-extension.js the error javascript is displayed. How can i use this file with selenium Core?Please help me

Posted by zeld at Jul 04, 2008 06:40

I am trying to use this with the latest version 1.0b2, but doesnt seem to work? I am trying to use the GOTOLABEL command as per in the samples/tests that come along in the zip. Please the error I get below. To me this looks like a compatibility issue - useless a more experienced person thinks differently.

  1. [info] Executing: |gotolabel | label | |
  2. [error] Unexpected Exception: message -> Specified label 'label' is not found., fileName -> chrome://selenium-ide/content/tools.js -> file:///C:/Documents%20and%20Settings/Developer/Desktop/Selenium/selenium-goto/Selenium/GoTO%20Ext%20-IDE/user-extensions.js, lineNumber -> 81, stack -> Error("Specified label 'label' is not found.")@:0 ("label","")@chrome://selenium-ide/content/tools.js -> file:///C:/Documents%20and%20Settings/Developer/Desktop/Selenium/selenium-goto/Selenium/GoTO%20Ext%20-IDE/user-extensions.js:81 ("label","")@chrome://selenium-ide/content/selenium/scripts/htmlutils.js:60 ([object Object],[object Object])@chrome://selenium-ide/content/selenium/scripts/selenium-commandhandlers.js:309 ()@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:112 (30)@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:78 (30)@chrome://selenium-ide/content/selenium/scripts/htmlutils.js:60 , name -> Error

Anyideas?
Regards.

Posted by nisarg at Aug 14, 2008 11:19
Site running on a free Atlassian Confluence Community License granted to OpenQA. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.6 Build:#812 Aug 06, 2007) - Bug/feature request - Contact Administrators