Saturday, 18 October 2014

How to generate unique random numbers in Selenium in Java?

In software testing projects, we usually need to enter the test data such that data is unique. So you may use below code to create such random unique numbers in Selenium.

//Create a date object
Date d1 = new Date( );

//Create formatting object
SimpleDateFormat formatting = new SimpleDateFormat ("yyyyMMddhhmmss");

//Create unique numbers 
System.out.println("Unique Number is " + formatting.format(d1));

In above code, we have used system date to create unique numbers. By changing the

What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com

No comments:

Post a Comment

Buy Best Selenium Books

Contributors