Thursday, February 10, 2011

Selecting All values from a drop down list box

To select all values from the drop down list box we use "storeSelectOptions" command. Following is the example for the same.

Example for "storeSelectOptions" Selenese command:

Just copy paste the following script into your Selenium IDE and use "Google.com" as the base URL.

<tr>
    <td>open</td>
    <td>/</td>
    <td></td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>link=Advanced search</td>
    <td></td>
</tr>
<tr>
    <td>storeSelectOptions</td>
    <td>tbs</td>
    <td>test</td>
</tr>
<tr>
    <td>echo</td>
    <td>${test}</td>
    <td></td>
</tr>

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>