LambdaTest Community

Find answers, support, and inspiration from other users

Questions
LambdaTest Community
Answered

how to repeat Selenium test script forever

I need to re-run my Selenium test script for unlimited number of times (infinite loop) - how I do that and what language should I use ? thanks

Up Vote Down Vote 0 Votes
Posted 5 months ago

Answers


Selenium supports lots of programming languages. See here for the full list:

http://seleniumhq.org/about/platforms.html#programming-languages

Just pick one of them and write an infinite loop that does what you need.

You could also use the Selenium Firefox plugin to do an initial recording of your script and then convert it to your language of choice.

OR

You can just write your task which you want to perform in loop. Put while loop to repeat your task number of times.

Here is the code to make a counter and create a while loop in Selenium script

<tr>
<td>getEval</td>
<td>index = 0;</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>index &lt; 40;</td>
<td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=page</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>id=correct</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>id=action</td>
    <td></td>
</tr>
<tr>
<td>getEval</td>
<td>index++;</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
Up Vote Down Vote 0 Votes
Posted 4 months ago
181 Views
1 Answer
5 months ago