@ulrich @Timo @thecoder2012 @Plankton
What i can do a random javascript to generate a random number from 50 to 100 ?
I need to set min value and max value.
With executeScript_Sandbox i can genererate a randon number from 0
return Math.floor(Math.random()*11)
Random number between 0 and 10
How can I convert this to have a min value to start and a max value to choice random numbers ?
Thanks
ulrich
December 25, 2019, 9:01pm
2
return Math.floor(50 + Math.random()*50)
=> random number between 50…100
1 Like
Working like a charm, thanks
KBMTM
July 21, 2021, 12:25pm
4
Hello! I´m trying to generate a random number for the pause command. Between 3000 and 5000 (3 and 5s) for example. Is it possible by doing it in the target directly?
Thanks
Here the solution
{
"Name": "Random",
"CreationDate": "2021-7-21",
"Commands": [
{
"Command": "executeScript_Sandbox",
"Target": "var letters = ['3000','4000','5000']; var string = ''; for(var i = 0; i < 1; i++){string += letters[parseInt(Math.random() * 3)]}; return string;",
"Value": "v1",
"Description": ""
},
{
"Command": "echo",
"Target": "Random Value Is ${v1}",
"Value": "#shownotification",
"Description": ""
}
]
}
1 Like
Hi! I’m kinda new to UI Vision.
I have used it in the past, but now it’s getting more advanced.
I am not a developer of any kind, just a QA tester.
I am trying to generate a random number of 5 characters, and then use that random number to put into an invoice field. (this would be the invoice number).
How do I do this?
uiuser
July 11, 2024, 4:03pm
7
function generateRandomNumber() {
return Math.floor(Math.random() * 90000) + 10000;
}
1 Like
Thank you. This helped!
I realized that I had to take that number and store it as a variable, and then use that variable in the next line.
{
"Command": "executeScript_Sandbox",
"Target": "return Math.floor(Math.random()*100001)",
"Value": "randomInvoiceNumber",
"Description": ""
},
{
"Command": "type",
"Target": "id=LedgerJournalTransVendInvoice_3_InvoiceGroup_InvoiceBTCAP_input",
"Value": "${randomInvoiceNumber}",
"Description": ""
}
uiuser
July 11, 2024, 6:11pm
9
this will not guarantee 5 digit number.
I realized that.
Why is that true?
And how do I guarantee a 5 digit number?
uiuser
July 11, 2024, 6:53pm
11
return Math.floor(Math.random() * 90000) + 10000;