Casting JSON data to Java objects
At this point, it would be good to recap some of the things we learned about designing JSON objects and how to use them in the test methods. Let's take each point separately and discuss.
JSON object
The JSON DataProvider designed earlier returns an array of objects. In simpler terms, we cast it at runtime to a JSONObject type when passed to the test methods. This JSONObject can then be used in any way the user wants—passing it to a Java object of a specific type, passing it to the Java builder class interface, assigning to local variables in the test method, and so on.
The main goal is to extract the data from the JSON file, convert it on the fly, and pass it into page object methods to perform the test.
But what about dynamic data? The tests and suites being built need to remain platform and environment independent. As most development is now done in Agile rather than Waterfall, each scrum team works on their own branch and environment, and once they merge...