I have a bunch of old test scripts that were written for the old Selenium IDE. I'm trying to update them to run with the new Selenium, but I'm having a really hard time figuring out what to do with bits of javascript and the new syntax.
For example, I have something like:
(command)STORE (Target) javascript{Math.floor(Math.random()*100000)} (Value) ReportNumber
But all Selenium does is store the javascript expression as a variable if I use that old Syntax. I saw that the new IDE wants us to instead use Run Script but I need to run the javascript and save it as a variable and none of the attempts I've made thus far have worked. Has anyone figure out HOW to use and run javascript successfully, and to save it as a variable. Examples if you have them, please!!
You now need to use the execute script command instead, like this:
execute script | return Math.floor(Math.random()*100000) | ReportNumber
The "target" of the execute script command is the JavaScript to execute, and the "value" is the name of variable you want Selenium to put the result into. The return in the JavaScript is not optional!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With