How to loop tests in Selenium IDE?
Do this:
- Download this js file: https://github.com/darrenderidder/sideflow/blob/master/sideflow.js
- Launch Selenium IDE from Firefox and open the options menu.
- Upload the .js file to the "Selenium Core extensions (user-extensions.js)" field.
The js file provides goto, gotoIf and while loop functionality in Selenium IDE. The example below shows a simple loop:
<tr>
<td>getEval</td>
<td>index = 0;</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>index < 10;</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>index</td>
<td>value</td>
</tr>
<tr>
<td>echo</td>
<td>${value}</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index++;</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
as stated in the answer above, install the user extension, which will add loop functionality to Selenium IDE tests. The example below shows a simple loop:
<tr>
<td>getEval</td>
<td>index = 0;</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>index < 10;</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>index</td>
<td>value</td>
</tr>
<tr>
<td>echo</td>
<td>${value}</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index++;</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
No need to install/download anything, the built-in times command does this very easily:
- Insert a new line at the beginning of your script, select
times
as itsCommand
and10
(for instance) as itsTarget
. - Scroll down to the bottom of your script, and add a new line with
end
as its command - Press the "Run" button as usual.
- Your commands are executed 10 times.
In this example I click on a button 2000 times:
To loop forever, just replace 10
with an extremely large number, that will take centuries to execute, which probably is as good as forever if you are running Selenium IDE.