Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,535
Community Members
 
Community Events
165
Community Groups

Any API to get Zephyr Test Content with Python?

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

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 :)

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you