Selenium IDE JavaScript functions

In addition to user-defined JavaScript commands introduced through user-extensions.js, the Selenium IDE allows the user to create JavaScript queries or functions directly in the Target field. For example, let's run a Google search by getting a random number between 1 and 100, as follows:

Selenium IDE JavaScript functions

The following HTML source tags let you convert the steps into runnable test scripts:

<tr> <td>store</td> <td>javascript{'Random number ' + Math.floor(Math.random() * 100);} </td> <td>search</td> </tr> <tr> <td>echo</td> <td>${search}</td> <td></td> </tr> <tr> <td>open</td> <td>/</td> <td></td> </tr> <tr> <td>type</td> <td>id=gbqfq</td> ...

Get Selenium Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.