By using the MagicPod Web API(v1.0), you can retrieve information as json format about test cases and shared steps. However, currently it is not possible to retrieve the details of each step of a test case, including shared steps, in a single Web API call.
Instead, we provide a Python script to retrieve the contents of each step of a test case, including shared steps. Using this script, you can obtain 'human_readable_step' that includes the content of shared steps, as shown below.
Additionally, total_step_count represents the total number of steps including shared steps. However, please note that this count may not be exact, so please use it as a rough estimate.
{
"number": 4,
"name": "Hotel Reservation",
"url": "https://app.magicpod.com/<org_name>/<project_name>/4/",
"description": "Verify the ability to make hotel reservations",
"human_readable_steps": "Navigate to https://example.com/\nShared Step: Enter the number of nights\n Enter '1' into the 'Number of Nights' input area\nShared Step: Enter the number of guests\n Enter '2' into the 'Number of Guests' input area\n...",
...
"total_step_count": 5
}
Usage Instructions
1. Install Python
If Python is not installed on your machine, please install it.
2. Download the Python script
Download get_full_test_cases_from_api.py from the MagicPod GitHub repository by clicking the download button at the top right. Save it to your preferred location.
3. Execute the Python script
Set the location where you placed get_full_test_cases_from_api.py which you downloaded in the step 1 as the current directory, and execute the command as follows:
Retrieve specific test cases (including human_readable_steps of shared steps)
python3 get_full_test_cases_from_api.py -t <token> -o <org_name> -p <project_name> <test_case_number(s)>
Retrieve all test cases (including human_readable_steps of shared steps)
python3 get_full_test_cases_from_api.py -t <token> -o <org_name> -p <project_name>
Retrieve only the human_readable_steps of specific test cases.
python3 get_full_test_cases_from_api.py -t <token> -o <org_name> -p <project_name> <test_case_number> |
jq '.[].human_readable_steps' |
python3 -c 'import sys, json; [print(json.loads(l)) for l in sys.stdin]'
For example, with 'Organization name: example_company', 'Project name: example_pj', and 'Test cases to retrieve: 1, 2', you can retrieve information for test cases 1 and 2 using the following command.
python3 get_full_test_cases_from_api.py -t xxxxx -o example_company -p example_pj 1 2
Troubleshooting
-
Check the error messages when executing the command, and if necessary, modify the source code to resolve any issues. (We recommend utilizing AI tools like ChatGPT for assistance.)