色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

為什么python+htmltestrunner生成的測(cè)試報(bào)告有問(wèn)題?

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

問(wèn)題描述

問(wèn)題:一個(gè)百度首頁(yè)搜索的一個(gè)python+unittest測(cè)試,代碼執(zhí)行成功,但是用HTMLTestRunner輸出的測(cè)試報(bào)告里面得內(nèi)容有問(wèn)題,具體問(wèn)題是:測(cè)試條數(shù),成功數(shù),失敗數(shù)都為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'百度首頁(yè)測(cè)試',description=u'用例執(zhí)行情況')runner.run(test)file_result.close()

生成的報(bào)告截圖:為什么python+htmltestrunner生成的測(cè)試報(bào)告有問(wèn)題?

問(wèn)題解答

回答1:

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

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

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 成年人视频在线观看免费 | 一区二区三区成人 | 国内精品久久久久久久亚洲 | 97在线视频免费观看费观看 | 伊人狼人综合 | 日本a级精品一区二区三区 日本a级毛片免费视频播放 | 可以免费观看欧美一级毛片 | 国产一区亚洲一区 | 久久ri精品高清一区二区三区 | 中文字幕在线观看亚洲日韩 | 深夜国产成人福利在线观看女同 | 久久亚洲精品无码观看不卡 | 91国内精品久久久久影院优播 | 99视频国产精品 | 国产一级成人毛片 | 国产成人亚洲综合无 | 久香草视频在线观看免费 | 在线视频观看国产 | 久色福利 | 91精品国产综合久久久久久 | 欧美国产精品一区二区免费 | 男女性高爱潮免费的国产 | 免费播放欧美毛片欧美a | 在线免费一区二区 | 国内精品久久久久久中文字幕 | 国产精品亚洲专一区二区三区 | 国产91精品久久久久999 | 亚洲综合爱久久影院 | 91久色视频| 久久一区二区三区99 | 久久久亚洲欧洲日产国码二区 | 一级毛片视频免费观看 | 男女朋友做爽爽爽免费视频网 | 中文三级视频 | 视频一区 欧美 | 性视频福利在线看 | 欧美一级片免费观看 | 一级毛片在播放免费 | 亚洲精品欧美精品一区二区 | 毛片爽爽爽免费看 | 天堂影院jav成人天堂免费观看 |