Using our company framework to send testrail results It was easy with api tests Example
rail = TestRail(project_id=23, debug=True, debug_run_id=484)
def test_payment_system(self):
payload = {"system": "qiwi"}
response = requests.get(urlpayment, params=payload, headers=self.beareradmin)
responseArray = response.json()
system = responseArray['items'][0]['payment_system']
if 'qiwi' in system:
rail.send_passed(21893, 'passed')
else:
rail.send_failed(21893, '')
So i have verifying that by string 'qiwi' in responseArray.
And sending status to test rail rail.send_passed(self, case_id,comment)
But i have a problem in UI tests.
Example
def test_loginok(self):
self.browser.get(login)
self.getXpathElement(login_mail).click()
self.getXpathElement(login_mail).send_keys('auto@test.com')
self.getXpathElement(login_password).click()
self.getXpathElement(login_password).send_keys('qwerty')
self.getClassElement(button_sign_in).click()
self.getXpathElement("//li[contains(@class,'active')]//a")
How to verify that test is passed or failed?
In my case test is passed if self.getXpathElement("//li[contains(@class,'active')]//a")
is present on the page.
I dont know how to create "if/else with rail.send_passed/failed" or another case to send result
And if test will failed on step #2 self.getXpathElement(login_mail).click()
i wont send anything to testrail.
Tried
def check(self, xpath):
try:
self.find elem by xpath(xpath)
except NoSuchElementException
return False
Returne True```
As ```r = check("//li[contains(@class,'active')]//a")
if r == True:
rail.send_passed(case_id, 'comment')
else:
rail.send_failed(case_id, 'comment')
But i cant use this method to all my steps in case.