AaronCC
AaronCC

Reputation: 53

Chrome Selenium IDE random number generator

I saw similar topics but nothing exact.

When I used Firefox and the IDE I was able to use StoreEval | Math.round (Math.random() * 99999999999) to create a random number of a specific length. I have now moved to Chrome to use the IDE and "StoreEval" is no longer an option. I have tried all the new "store" options available but end up with the below warning in the logs and the number is not created:

"Warning implicit locators are deprecated, please change the locator to id=Math.round (Math.random() * 99999999999"

Any ideas on what I need to use/change? I will admit I am not exactly sure what "please change the locator to" means.

Thanks!

Upvotes: 3

Views: 9968

Answers (1)

Adrien Arcuri
Adrien Arcuri

Reputation: 2400

You must use execute script command in the last version of Selenium IDE.

  1. Right click on any command, and select "Insert New Command"
  2. Insert the following. The result will be stored in myRandomNumber

    Command : execute script
    
    Target : return Math.random()
    
    Value : myRandomNumber
    
  3. You can then reference this variable in the Value of any Command, using ${myRandomNumber}

Note: You can also see your generated random number. To do so, add another Command:

Command : echo

Target : ${myRandomNumber}

Upvotes: 13

Related Questions