午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術文章
文章詳情頁

為什么python+htmltestrunner生成的測試報告有問題?

瀏覽:203日期:2022-08-29 08:18:37

問題描述

問題:一個百度首頁搜索的一個python+unittest測試,代碼執行成功,但是用HTMLTestRunner輸出的測試報告里面得內容有問題,具體問題是:測試條數,成功數,失敗數都為0代碼

?# -*- coding: utf-8 -*-from selenium import webdriverimport osimport timeimport unittestimport reimport HTMLTestRunnerfrom selenium.webdriver.support.wait import WebDriverWaitfrom selenium.webdriver.support import expected_conditionsfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.support.ui import Selectfrom selenium.common.exceptions import NoSuchElementExceptionfrom selenium.common.exceptions import NoAlertPresentExceptionclass LoginBaiDu(unittest.TestCase): def setUp(self):self.driver = webdriver.Chrome()self.driver.implicitly_wait(30)self.base_url = 'http://www.baidu.com'self.verificationErrors = []self.accept_next_alert = Trueprint(’Done-01’) def test_baidu(self):self.driver.get(self.base_url)self.driver.find_element_by_id('su').click()print(’Done-02’)time.sleep(2)jsClear='$('input[id=’kw’]').val('')'self.driver.execute_script(jsClear)print(’Done-03’)time.sleep(2)jsVal='$('input[id=’kw’]').val('selenium+python')'self.driver.execute_script(jsVal)time.sleep(1)self.driver.find_element_by_xpath('//input[@id=’su’]').click()print(’Done-04’)self.driver.close()print(’Done-05’) def tearDown(self):self.driver.quit()self.assertEqual([], self.verificationErrors)print('test down...') if __name__=='__main__':test=unittest.TestSuite()test.addTest(setUp)test.addTest(test_baidu)file_path='D:workspacePythonLearnsrcLoginBaiDuresult.html'file_result=open(file_path,’wb’)runner=HTMLTestRunner.HTMLTestRunner(stream=file_result,title=u'百度首頁測試',description=u'用例執行情況')runner.run(test)file_result.close()

生成的報告截圖:為什么python+htmltestrunner生成的測試報告有問題?

問題解答

回答1:

加測試用例的方式錯了要test=unittest.TestSuite() test.addTest(LoginBaiDu(’setUp’))test.addTest(LoginBaiDu(’test_baidu’))

或者直接加入類test= unittest.TestLoader().loadTestsFromTestCase(LoginBaiDu)

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 69久久久久| 天天透天天操 | wwwxxx国产 | 一区二区视频免费观看 | 成人小视频在线 | 中文国语毛片高清视频 | 我不卡一区二区 | 99热在线观看精品 | 日韩91视频 | 可以在线观看的av | 午夜毛片在线观看 | 欧美日韩一区三区 | 成人午夜免费观看 | 日在线视频| 操欧美老女人 | av在线资源 | 成人免费一区二区 | 黄色一级黄色片 | 欧美在线观看一区二区 | 九九热免费视频 | 免费日韩网站 | 久草香蕉视频 | 亚洲色图 欧美 | 欧美亚洲精品天堂 | 超碰在线观看免费版 | 国产理论片在线观看 | 在线看日韩av | 天天狠天天操 | 美女黄色在线观看 | 我要看18毛片 | 欧美黑吊大战白妞 | av一区二区三区在线观看 | 一级黄色性生活片 | 久久精品99国产国产精 | 91免费大全 | 处女av| 干一夜综合 | av在线播放一区二区 | 亚洲女同一区二区 | 免费黄色在线视频 | 韩日免费av |