Steps :

Can you suggest the approach or share some sample script

1.Read data from JSON file - Method to Provide Data (JsonReader.getdata) - Get file location & File Name

2.In @Test(dataprovider='JSON File Data') -> Pass All values as Method Argument - Send all values one by One ( Xpath , Elementname , Sendkeys) - Fill the UI Header form with Values from JSON and Clickon Save

3.Write it in Excel file

  • 1
    What have you tried to do? Where is it giving you problems?
    – Kate Paulk
    Commented May 14, 2019 at 18:50
  • Akshay, you find some answer satisfiable, I would recommend marking it as accepted. It really motivates the community to continuing answering. Commented May 15, 2019 at 6:43

1 Answer 1


1 - Read data from JSON

Google has a very good Java library to parse JSON in a structured way: GSON

The types you would use the most are JSONObject and JSONElement.

2 - Use the data in a test

I would suggest having in your dataprovide only the name of the JSON file. In the test, you can call a factory that would read the JSON file and generate a POJO object.


@Test(dataprovider='JSON File Data')
public .... myTest(String jsonFileName) {
   TestDataModel testData = TestDataFactory.createTestDataFromJSON(jsonFileName);

TestDataModel will represent the JSON file:


  "userName": "Mario",
  "password": "Luigi"

POJO with a bit of Lombok:

public class TestDataModel {

@Getter @Setter
public final String userName;

@Getter @Setter
public final String password;


TestDataFactory and ExcelLogger will do the dirty work of interacting with the file system and performing the serialization/deserialization part.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.