appium学习【二】:用try捕获异常后,用例的执行结果为pass
在代码中用try..except捕获异常截图后,HTMLTestRunner生成的测试报告中,用例的执行结果为pass
解决办法为:
在try..except后加raise,只要再加个raise就行了
def test_bangban_login(self): try: WebDriverWait(self.driver,10).until( EC.presence_of_element_located((By.ID,'com.cbwlkj.cyzb:id/contact_phone1')) ) self.driver.find_element_by_id('com.cbwlkj.cyzb:id/contact_phone1').send_keys('18602508223') time.sleep(5) except TimeoutException: print u'达人登录页面加载失败' funcName = sys._getframe().f_code.co_name print funcName pngfile = "E:\\appium_code\\png\\" + funcName + timestr + ".png" print pngfile self.driver.get_screenshot_as_file(pngfile) raise
执行结束后,生成的测试报告中,该条case的结果为error