Software Development and QA Tips

Dev and QA Tips How To Automate Dynamic UI From JSON in Selenium?

How To Automate Dynamic UI From JSON in Selenium?

Dynamic UI Automation | By Timothy Joseph | April 4, 2022

How To Automate Dynamic UI From JSON in Selenium?

JSON is a format of keeping your data in a customized way that allows you to fetch data from JSON files, dynamically, at run time as per requirement. For automating dynamic UI from JSON in Selenium, a synchronized mapping between Json Objects & UI objects is required. Data in JSON is stored as Key-Value pairs and through the index of a particular attribute in JSON, we can fetch the corresponding value. These fetched values from Json then can be used dynamically in your automation selenium test script.

Additionally, please refer to the below code to fetch data from JSON File(DummyJsonFile.json) and use it in your automation script:

"organization" : "QASource",
var employeeDetails = [{
"Name" : "Mike",
"Role" : "QA Manager",
"Gender" : "Male"
"Name" : "Paul",
"Designation" : "Team Lead",
"Gender" : "Male"

High Level Code:

JSONParser jsonParser = new JSONParser();
FileReader reader = new FileReader("DummyJsonFile.json");
Object parsedObject = jsonParser.parse(reader);
JSONObject employeeObject = (JSONObject) parsedObject;
String getOrganizationName = (String) employeeObject.get("organization");

Note: Alternative way is to use Pseudo WebDriver elements and use in automation script.

Watch the API Testing Webinar Now


This publication is for informational purposes only and nothing contained in it should be considered legal advice. We expressly disclaim any warranty or responsibility for damages arising out of this information and encourage you to consult with legal counsel regarding your specific needs. We do not undertake any duty to update previously posted materials.