Getting variables from url parameters in Selenium IDE

Are you using paramaterized url’s and would you like to get it’s value to later use in Selenium IDE?

If you have an url like this: http://localhost:8318/#type=page&id=331 and you would like to get the value from id. It’s actually quite simple!

Just use JavaScript! Using this one-line regex you’ll get the result:
new RegExp(‘&id=([0-9]+)’).exec(‘http://localhost:8318/#type=page&id=331’)[1]

So this should get you started:

<tr>
<td>storeLocation</td>
<td>url</td>
<td></td>
</tr>

<tr>
<td>storeEval</td>
<td>new RegExp(‘&amp;id=([0-9]+)’).exec(‘${url}’)[1]</td>
<td>varId</td>
</tr>

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

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.