https://github.com/tungbq/robotparser
Covert robotframework output.xml result to output.json
https://github.com/tungbq/robotparser
docker python robotframework tools
Last synced: 7 months ago
JSON representation
Covert robotframework output.xml result to output.json
- Host: GitHub
- URL: https://github.com/tungbq/robotparser
- Owner: tungbq
- Created: 2024-02-03T02:18:13.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-28T05:27:16.000Z (over 1 year ago)
- Last Synced: 2025-03-28T19:09:03.651Z (7 months ago)
- Topics: docker, python, robotframework, tools
- Language: HTML
- Homepage:
- Size: 169 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# robotparser
Covert Robotframework output.xml result to output.json
## Context
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.
## Usage
### 1. Prerequisite
- `python`: You have `python` installed on your machine. See: https://www.python.org/downloads/
### 2. Clone the repository
Run `git clone git@github.com:tungbq/robotparser.git`
### 3. Run `robotparser` script directly on your machine
If you want to run the tool directly on your machine, follow below steps:
- Run
```
# Navigate to your cloned code
cd robotparser
# Install dependencies
pip install -r requirements.txt
# Start the script
python robotparser.py -i -o
```
- Options explaination
```
-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
```
- Example
```
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
```
### 4. Run the script in Docker (Optional)
If you want to run the script inside a Docker container, follow below steps:
- Build the docker image
```
cd robotparser
docker build -t robotparser:latest .
```
- Start `robotparser` inside container
Update the YOUR_ROBOT_SCRIPT_PATH which contains your target output.xml
```
cd 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`
### 5. Run robot demo to generate sample output.xml files
See [ROBOT_DEMO](./ROBOT_DEMO.md)