如果任何一步测试失败,如何将测试结果发送给testrail?

2024-04-27 03:44:24 发布

您现在位置:Python中文网/ 问答频道 /正文

使用我们的公司框架发送testrail结果 api测试很简单 示例

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, '')

所以我要通过在responseArray中输入'qiwi'来验证这一点。 发送状态到测试轨rail.send_passed(self, case_id,comment)

但是我在UI测试中遇到了一个问题。你知道吗

示例

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

如何验证测试是否通过? 在我的例子中,如果页面上有self.getXpathElement("//li[contains(@class,'active')]//a"),测试就通过了。你知道吗

我不知道如何用rail.send\u通过/失败“或其他案例发送结果

如果测试在第2步失败,我不会向testrail发送任何东西。你知道吗

尝试

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

但我不能用这个方法来完成我的所有步骤,以防。你知道吗


Tags: testselfsendidtruedefcommentlogin