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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.