Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to loop tests in Selenium IDE?

I've been testing in Selenium IDE. It's pretty easy to use, and I have created some test cases with it. I've been searching Google, trying to find a way to repeat my tests automatically. I've seen a solution with gotolabel, while loops, etc. But I couldn't make any of them works. Can someone give me a tip on how to loop my test n times, or loop forever. I appreciate any help.

like image 670
Giordano Giuliano Avatar asked Jun 14 '12 12:06

Giordano Giuliano


People also ask

How do I run Selenium continuously?

If you want your test to run continuously in Selenium IDE then use infinite while loop command provided in IDE extension plug-in like ISFW IDE extension Plug in. You can also utilize define module command provided in ISFW plugin.

Can you run multiple selenium tests?

We can run multiple test cases using TestNG test suite in Selenium webdriver. To execute test cases simultaneously, we have to enable parallel execution in TestNG. A TestNG execution is driven by the TestNG xml file. To trigger parallel execution we have to use the attributes – parallel and thread-count.

Does Selenium RC support looping?

Selenium Integrated Development Environment (IDE)Selenium IDE does not support conditional statements, exception handling, loops, screenshot capture, etc. For automating complex use cases, a majority of developers and testers prefer to opt for Scripting testing instead of Record & Replay testing.


2 Answers

Do this:

  1. Download this js file: https://github.com/darrenderidder/sideflow/blob/master/sideflow.js
  2. Launch Selenium IDE from Firefox and open the options menu.
  3. 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 &lt; 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> 
like image 138
Prashant Vadher Avatar answered Sep 28 '22 03:09

Prashant Vadher


No need to install/download anything, the built-in times command does this very easily:

  1. Insert a new line at the beginning of your script, select times as its Command and 10 (for instance) as its Target.
  2. Scroll down to the bottom of your script, and add a new line with end as its command
  3. Press the "Run" button as usual.
  4. Your commands are executed 10 times.

In this example I click on a button 2000 times:

enter image description here

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.

like image 21
Nicolas Raoul Avatar answered Sep 28 '22 02:09

Nicolas Raoul