亚洲免费在线视频-亚洲啊v-久久免费精品视频-国产精品va-看片地址-成人在线视频网

您的位置:首頁(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)文章:
主站蜘蛛池模板: 成人看片黄a免费 | 污美女网站www在线观看 | 久草在线网址 | 久久精品二区 | 亚洲午夜综合网 | 一级毛片大全 | 亚洲一级在线观看 | 成人免费视频网站 | 天堂av影院 | 精品国产欧美另类一区 | 久久免费精品国产视频 | 免费在线观看的毛片 | 日本红怡院在线 | 黄色毛片免费 | 国产成人精品实拍在线 | 精品视频在线观看一区二区三区 | 国产精选在线播放 | 极品丝袜高跟91白沙发在线 | 国产在线精品成人一区二区三区 | 特黄特色三级在线播放 | 亚洲日本韩国在线 | 亚洲人成亚洲精品 | 国产欧美一区二区精品性色 | 大学生一级一片第一次欧美 | 美女福利视频国产 | 国产主播福利片在线观看 | 欧美日本一区亚洲欧美一区 | 国产成人免费午夜在线观看 | 欧美色操| 美女白浆视频 | 小屁孩cao大人免费网站 | 久久99精品这里精品3 | 成年人网站黄 | 国产亚洲欧美ai在线看片 | 国产精品3| 偷柏自拍亚洲欧美综合在线图 | 97青草香蕉依人在线播放 | 国产成人综合亚洲 | 久久精品男人的天堂 | 一区二区三区 亚洲区 | 亚洲字幕波多野结衣作品 |