Chrome Selenium IDE random number generator

送分小仙女□ 提交于 2020-07-21 03:50:45

问题


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!


回答1:


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}


来源:https://stackoverflow.com/questions/52894485/chrome-selenium-ide-random-number-generator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!