wcbes
February 24, 2023, 5:50pm
1
I need to generate a new random email each time I run my script. I know the script by itself works, but when I attempt to add the returned number into testaccount+<###>@gmail.com it fails. It doesn’t like my plus signs, but I’m pretty sure those are standard?
Command: execute script
Target: return {“testaccount+”+Math.floor(Math.random()*99999)+“@gmail.com ”;}
Value: Var1
The error I get is: Unexpected token ‘+’
I would love it if someone could explain the correct way to do this.
uiuser
February 25, 2023, 10:52pm
3
{
"Command": "executeScript",
"Target": " return \"testaccount\" + Math.floor(Math.random()*99999).toString() + \"@gmail.com\";",
"Value": "Var1",
"Description": ""
}
1 Like
With ui vision 6.2.6 for firefox working like a charms
I do not use ui vision for Chrome and i can not test it
Macro code:
{
"Name": "AAAA",
"CreationDate": "2023-2-26",
"Commands": [
{
"Command": "executeScript",
"Target": " return \"testaccount\" + Math.floor(Math.random()*99999).toString() + \"(AT)gmail.com\";",
"Value": "Var1",
"Description": ""
},
{
"Command": "echo",
"Target": "${Var1}",
"Value": "blue",
"Description": ""
}
]
}
[status]
Playing macro AAAA
[info]
Executing: | executeScript | return "testaccount" + Math.floor(Math.random()*99999).toString() + "(AT)gmail.com"; | Var1 |
[info]
Executing: | echo | ${Var1} | blue |
[echo]
testaccount51227(AT)gmail.com
[info]
Macro completed (Runtime 0.74s)
The solution written by @uiuser works perfectly accept it as a solution
wcbes
February 27, 2023, 2:43pm
6
Thanks for the help. I am still getting failed: invalid or unexpected token .
Command: execute script
Target: return "testaccount" + Math.floor(Math.random()*99999).toString() + "@gmail.com ";",
Value: Var1
Selenium IDE chrome. Am I misinterpreting something you wrote?
wcbes
February 27, 2023, 3:34pm
8
I downloaded that and tested there. Same error.
Executing: | executeScript | return "testaccount" + Math.floor(Math.random()*99999).toString() + "@gmail.com ";", | Var1 |
Line 8: Error in executeScript code: Invalid or unexpected token
wcbes
February 27, 2023, 3:59pm
10
No, but I have included screenshot.
uiuser
February 27, 2023, 4:33pm
11
use this
return "testaccount" + Math.floor(Math.random()*99999).toString() + "@gmail.com";
wcbes
February 27, 2023, 4:44pm
12
Really appreciate your patience. That worked. Thanks.
1 Like