Friday, February 8, 2019

Create Fake Test Data for Selenium Tests using Java Faker API

Test data is necessary in testing an application, in automation the test data will be either hard-coded or provided from the external sources like Excel, CSV, XML, Database and etc. If its live data that needs to be fetched from sources like Database we have to follow it, there is no other go.

But when we are providing the test data from external files for validating certain functionalities that data needs to be revised after some iterations. It takes lot of manual effort of tester to re-create the test data.

Java Faker API:

In order to reduce the manual effort in creating the test data, we use Java Faker API. Java Faker API is Java library which generates data related to different categories like Company, Internet, Human, Numbers, Food, Finance, Telephone and etc. this covers almost all the type of data that a typical software application would require.

Configure Java Faker API in Selenium Project:

Add Java Faker API maven dependency in the pom.xml (we are using Maven project) as shown below.

Create separate utility class that generates the fake data using Java Faker API library. In the below class we created methods that generate first name, last name, password, email and etc.

In the below Selenium test, we are automating facebook account create form. In this test we need to enter first name, last name, email Id and password.

We created an object to JavaFakerAPI utility class and called the required methods in the selenium tests.

Run this test many times and every time unique values will be generated and we can run this selenium test without changing the test data every time we execute it.

This is how we can reduce the manual effort in creating the new test data every time.

#HappyLearning #HappyTesting

10 comments:

  1. Valuable info.Thanks for sharing.Want to know same package will use selenium C#

    ReplyDelete
  2. Hi Venkat, I don't think its possible to use same for Selenium C#. If I found, will let you know.

    ReplyDelete
  3. After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
    Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in


    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune

    ReplyDelete
  4. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    Selenium Training in Electronic City

    ReplyDelete
  5. You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. where can i buy a fake id

    ReplyDelete
  6. Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. fake id online

    ReplyDelete
  7. I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. best fake id

    ReplyDelete
  8. I have to search sites with relevant information on given topic and provide them to teacher our opinion and the article. Scannable Fake Id

    ReplyDelete
  9. This is a great blog that explains how we can Create Fake Test Data for Selenium Tests. You can buy high quality Fake ID for Sale at great prices.

    ReplyDelete

Java Program 5: How to reverse given string and each word of it?

Let us understand the problem with an example, suppose "Learn Core Java" is the given string then the expected output should be &...