Any API to get Zephyr Test Content with Python?

Frank Fu July 13, 2020

I know there's jira library for python: <JIRA 2.0> to search issues or get page content from Jira.

But is there any library I can use to get the content from plugin: Zephyr in Jira?

I tried to use requests library to analysis the contents from html, but login cookies is complicated and the contents in Test Details seems hidden or in somewhere instead of main page. So I wonder if there's any good method to grab the test cases? Thanks.

1 answer

0 votes
Frank Fu July 14, 2020

Now I've found another way to grab the test case content by ZAPI.

Before actions, you need to make sure you've installed ZAPI. Check that in:

https://<jira-server>/rest/zephyr/1.0/application.wadl

 

You can get html content by using format like this:

improt requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

"""
Replace your cookies. The reason why I don't like this method cause
it's complicated for me to get dynamic cookies in different users.
"""
header = {'Cookie': cookie,}
url = "https://<jira-server>/rest/zapi/latest/teststep/testid"
html = requests.get(url, verify=False, headers=header)
# You need to parse the content by yourself cause it's messy strings

 

You can find testID through API defined in JIRA library.

from jira import JIRA

jira = JIRA(basic_auth={username, password},
options={'server':%jira-server%, 'verify':False,})
cases = jira.search_issues('project=%your project% AND
type=Test ORDER BY created ASC'
,fields='', maxResults=100)
print(cases)

 

More detailed answers you can find in below path:

https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Zephyr-Jira-plugin-REST-API/qaq-p/167486

Hope ATLASSIAN will provide more APIs in JIRA library.  If you've any better methods or ideas, please share with us, thanks :)

Bernhard Sessner May 23, 2022

Hi, check this out - could be useful for you:

https://bitbucket.org/melectrification/python-zephyr/src/master/

Suggest an answer

Log in or Sign up to answer