Python 如果在任何步骤上测试失败,如何将测试结果发送到testrail?
使用我们的公司框架发送testrail结果 使用api测试很容易 范例 所以我在responseArray中通过字符串'qiwi'验证了这一点。 并将状态发送到测试轨道Python 如果在任何步骤上测试失败,如何将测试结果发送到testrail?,python,unit-testing,selenium,user-interface,testrail,Python,Unit Testing,Selenium,User Interface,Testrail,使用我们的公司框架发送testrail结果 使用api测试很容易 范例 所以我在responseArray中通过字符串'qiwi'验证了这一点。 并将状态发送到测试轨道rail.send\u passed(self,case\u id,comment) 但是我在UI测试中遇到了一个问题 范例 def test_loginok(self): self.browser.get(login) self.getXpathElement(login_mai
rail.send\u passed(self,case\u 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.getxpatheElement(//li[contains(@class,'active')]//a”)
,则测试通过
我不知道如何创建“if/else with rail.send\u passed/failed”或其他案例来发送结果
如果测试在第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')
但是我不能用这个方法来完成我的所有步骤,以防失败
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')