How to create a random number

I need to create a homework test using the Selenium IDE and create a script to generate a random number. I struggle with what I need to print and which field to enter.

What should I enter ?: command goal Value

+4
source share
5 answers

alt text

alt text
(source: wisc.edu )

+19
source

I always use this to create an arbitrary username and email

storeEval > Math.round (Math.random() * 1357) > random type > id=UserName > selenium${random} 

and

 storeEval > Math.round (Math.random() * 1357) > random type > id=UserEmail > selenium${random}@am.com 

Hope they can help you.

+3
source

I often use this in my JUnit tests to generate random input values.

 int randNum = (int) (Math.random() * MAXVALUE); 
+1
source

This is what I use:

 Random rand = new Random(System.currentTimeMillis()); int num = rand.nextInt(range); 

Range is the maximum number you want to return. Num will be something between 0 and range.

0
source

you can use

 Random rndNum = new Random(); System.out.println("Num "+rndNum.nextInt()); 

for a single number such as: Num -1597641332

or try

 Random rndNum= new Random(); int rndNum1 = 0; for (int nbr = 1; nbr <= 3; nbr++) { rndNum1 = rndNum.nextInt(); System.out.println("Number: " + rndNum1); } 

for the plural of random numbers such as

Number: -1891834125 Number: -1541629941 Number: -129634738

0
source

Source: https://habr.com/ru/post/1309722/


All Articles