How to generate random test data?


At times it is required that we use unique test data for every single run of an automation script. For Ex – for testing a user registration page we would need a username which already does not exists in the database. Though there are various ways to overcome this unique username issue but we will see one which is the simplest one. The idea behind this is to use current date and time to generate a no. which we know would be unique. The function given below can be used to convert date and time into the random number we need

Note: The function can still generate same random numbers in case used on multiple machines where time is not in sync or both scripts get the time using Now function at the same time (slimmest possible chance of that happening)

Have questions related to this article? Want to request a new article? Use our forums to post your questions


  1. Suscribe to Email

    Enter your email address:

    Delivered by FeedBurner