国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

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

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

瀏覽:77日期: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 編程
相關文章:
主站蜘蛛池模板: 亚洲成年人在线观看 | 日本加勒比系列 | 亚洲a级在线观看 | 在线播放国产真实女同事 | 91精品国产综合久久欧美 | 337p粉嫩大胆噜噜噜鲁 | 欧美高清性刺激毛片 | 国产精品久久久久久一区二区 | 99精品国产在热久久 | 人成精品视频三区二区一区 | 亚洲 欧美 成人 | 亚洲综合图片人成综合网 | 深夜一级毛片 | 欧美精品hdvideosex4k | 国产精品成人亚洲 | 日韩美女一区 | 亚洲加勒比久久88色综合1 | 在线免费看黄色 | 亚洲国产一区二区三区最新 | 国产嫩草影院在线观看 | 亚洲成人天堂 | 2019在线亚洲成年视频网站 | 亚洲综合第一页 | 91久久国产成人免费观看资源 | 99久久免费国产精品 | 欧美激情特级黄aa毛片 | 免费男女视频 | 六月丁香婷婷天天在线 | 日韩理论在线 | 亚洲人成网址在线播放a | 欧日韩美香蕉在线观看 | 亚洲国产成人麻豆精品 | 亚洲国产精品一区二区九九 | 午夜手机视频 | 欧美亚洲一区二区三区四 | 六月伊人| 中文字幕一级 | 成年女人aaaaa毛片 | 欧美一及片 | 手机看片日本 | 久久久国产一区二区三区丝袜 |