An open API service indexing awesome lists of open source software.

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

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)