Covert Robotframework output.xml result to output.json
You utilize the Robot Framework for testing your application, and while the test results currently exist in XML format, you require a JSON result file for additional data processing. Look no further – this script is designed to assist you in effortlessly converting an XML test result file into a JSON format.
python
: You have python
installed on your machine. See: https://www.python.org/downloads/
Run git clone [email protected]:tungbq/robotparser.git
robotparser
script directly on your machineIf you want to run the tool directly on your machine, follow below steps:
# Navigate to your cloned code
cd robotparser
# Install dependencies
pip install -r requirements.txt
# Start the script
python robotparser.py -i <input-outputxml-file> -o <output-json-file>
-i, --input-file Specify the input XML file generated by robot test (e.g., robot-result/output.xml)
-o, --output-file Specify the output JSON file (e.g., output/output.json)
-h, --help Display this help message
python3 robotparser.py -i samples/input/hello_robot.xml -o output/hello_robot.json
python3 robotparser.py -i samples/input/output_5_0.xml -o output/output_5_0.json
python3 robotparser.py -i samples/input/output_5_0.xml -o output/output_5_0.json
python3 robotparser.py -i samples/input/robot_demo_keyword_driven.xml -o output/robot_demo_keyword_driven.json
If you want to run the script inside a Docker container, follow below steps:
cd robotparser
docker build -t robotparser:latest .
robotparser
inside containercd robotparser
YOUR_ROBOT_SCRIPT_PATH="/home/user/testing/robot_result/"
# Mount your robot sccipt path to docker container. Note that `/app` is the workspace of docker container
docker run --rm --name my_robotparser \
-v ${YOUR_ROBOT_SCRIPT_PATH}:/app \
robotparser:latest \
-i /app/your_robot_filename_in.xml \
-o /app/your_robot_filename_out.json
One completed, we can find the JSON result under YOUR_ROBOT_SCRIPT_PATH
See ROBOT_DEMO