6

I have to create a test for homework using Selenium IDE and create a scenario to generate a random number. I'm struggling with what I need to type and what field to type in.

What should I type in?: Command Target Value

Yi Zeng
  • 32,020
  • 13
  • 97
  • 125
angel malave
  • 97
  • 1
  • 1
  • 2

5 Answers5

20

alt text

alt text
(source: wisc.edu)

  

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
3

i always use this to create random username and e-mails

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

i hope they can help you

Mai Hanafy
  • 91
  • 7
1

I use this often in my JUnit tests to create random inputs values.

int randNum = (int) (Math.random() * MAXVALUE);
Jens Erat
  • 37,523
  • 16
  • 80
  • 96
usernz
  • 107
  • 1
  • 6
0

This is what I use:

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

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

Scott Helme
  • 4,786
  • 2
  • 23
  • 35
0

you can use

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

for a single number like: 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 multiple number of random numbers like

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

selva
  • 1,175
  • 1
  • 19
  • 39