Subscribe Join 180,000+ subscribers and receive articles from our blog about software quality, testing, QA and security. Subscribe

[Query] Is there a way to mimic the export testplan functionality present on the testrail UI via python code

I see that all the details that I would need for my automated reporting are present in the excel that we can export from the test plan.

I was wondering if there is an API, or a way to get this exported via python.


Hi @Shar,

you can use the provides RestAPI, there is also an example to do so via Python (haven’t used it, but…).

Then you can pic up the data via one of these endpoinds. Probably you need calls for the runs/planentries in advance.


@kwirth There doesnt seem to be an equivalent rest end point for exporting the test plan to CSV. When I try to do the same via requests and mimic the export functionality, I am stuck with gettinng the CSRF token. It seems to be sent as the body is the form field, but I am unable to get it from the auth/login API. (Only session_id seems to be available over there and In cache).

Yes, there is no endpoint to download a csv. I was thinking about using Python to access the Rest-API to fetch the data and compose it like you need.

It is also possible to fetch the csv automated by using Selenium.

Using the original requests is not my style. Probably somebody else has an idea…