You want to read and run each element of the .side file in Java, convert this python code in Java. You will be able to catch each step and do selenium method as you want, log each step etc...
import json
with open("your_file.side", "r") as f:
side_dict = json.load(f)
then you can catch all elements with a code like this :
for test in side_dict["tests"]:
if test["name"] == test_case_name:
for command in test["commands"]:
target = command["target"]
print(f"""command : {command["command"]}""")
print(f"target : {target}")
Maybe this code will run in java :
import java.io.FileReader;
import java.io.IOException;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
public class SideFileParser {
public static void main(String[] args) throws IOException, ParseException {
JSONParser parser = new JSONParser();
Object obj = parser.parse(new FileReader("your_file.side"));
JSONObject jsonObject = (JSONObject) obj;
JSONArray testsArray = (JSONArray) jsonObject.get("tests");
for (Object testObj : testsArray) {
JSONObject test = (JSONObject) testObj;
String testName = (String) test.get("name");
if (testName.equals(test_case_name)) {
JSONArray commandsArray = (JSONArray) test.get("commands");
for (Object commandObj : commandsArray) {
JSONObject command = (JSONObject) commandObj;
String target = (String) command.get("target");
System.out.println("command : " + command.get("command"));
System.out.println("target : " + target);
}
}
}
}
}