Thursday, February 10, 2011

Generating Random String in Selenium IDE

Following is the Selenese command to generate random String in Selenium IDE. It will generate a random string of length 3. It can be varied by changing the length in the for loop.



<tr>
    <td>store</td>
    <td>javascript{var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXTZ'; var randomstring = ''; for (var i=0; i&lt;3; i++) { var rnum = Math.floor(Math.random()*chars.length); randomstring += chars.substring(rnum,rnum+1); }}</td>
    <td>randomstring</td>
</tr>

<tr>
    <td>echo</td>
    <td>${randomstring}</td>
    <td></td>
</tr>

No comments:

Post a Comment