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

Access reports after run_report/ api

I was following the docs in API Reports. After I generated a report thru run_report I was given a json response with 3 links:

"report_url": "",
"report_html": "",
"report_pdf": ""


How do I access them programmatically and download pdf for example? When I try to fetch any of them, it doesn’t work. It works only when I copy the link from the response and manually paste into the browser.

1 Like

i vote for this topic :+1:
i’m looking for the exact same functionality

So i got feedback today from gurock. Apparently the download really doesn’t work programmatically :man_facepalming:

So I helped myself with a workaround using python + selenium. I do not take responsibility nor do I provide support, but this is how I download the generated report now:

import requests
import base64
import pprint
from selenium import webdriver
from import By
from import WebDriverWait 
from import expected_conditions as EC 
import os.path
import sys
import time

username = 'username'
password = 'password'
download_path = os.path.dirname(sys.argv[0])

auth = str(
        bytes('%s:%s' % (username, password), 'utf-8')

headers = {'Authorization': 'Basic ' + auth}
headers['Content-Type'] = 'application/json'

# here also send_get from testrail api is possible
report = requests.get('', headers=headers)

chromeOptions = webdriver.ChromeOptions()
prefs = {"download.default_directory" : download_path}

# create a new Chrome session
driver = webdriver.Chrome(options=chromeOptions)

download_url = report.json()['report_pdf']
download_file = download_path + '\\testrail-report-' + download_url.rsplit('/', 1)[-1] + '.pdf'

# Navigate to the application home page
r = driver.get(download_url)

WebDriverWait(driver, 5).until(
    EC.presence_of_element_located((By.ID, 'name'))
eUsername = driver.find_element_by_id("name")
ePassword = driver.find_element_by_id("password")



count = 1
# wait maximum 30 seconds for download to complete
max_wait = 30
while count < max_wait:
    count = count + 1
    if os.path.exists(download_file):
        count = max_wait


Maybe you can use this as well.

Best regards!