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

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

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

瀏覽:182日期: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 編程
相關文章:
主站蜘蛛池模板: 欧美性猛交xxxx乱大交少妇 | 特黄一级视频 | 欧美成人一区二区三区 | 国产黄色片在线免费观看 | 王语嫣跪趴高撅翘臀含白浆 | 色女视频| 婷婷俺也去 | 在线观看av资源 | 无遮挡黄色 | www日韩在线 | 日韩另类视频 | 精品麻豆视频 | 一级特黄aa大片欧美 | 亚洲黄色一级大片 | 超碰人人在线 | 欧美精品一区二区免费 | 天天操天天干天天摸 | 欧美精品亚洲精品 | 国产精品成人一区 | 高跟肉丝丝袜呻吟啪啪网站av | 欧美日韩午夜 | 欧美韩日国产 | 国产欧美大片 | 天天干在线播放 | 国产无遮挡又黄又爽在线观看 | 欧美黄视频在线观看 | 四虎免费看黄 | 国产精品爱啪在线线免费观看 | 国产丰满美女做爰 | 国产无遮挡又黄又爽在线观看 | 色无极亚洲影院 | 国产精品一区二区不卡 | 在线免费观看中文字幕 | 中文字幕亚洲精品在线 | 蜜臀久久99精品久久一区二区 | 色一情一乱一乱一区91 | 成人免费在线播放 | 欧美日韩亚洲国产综合 | www.久久久久.com | 婷婷激情综合网 | 国产一区二区三区免费播放 |