一、下载HTMLTestRunner.py
HTMLTestRunner 是 Python 标准库的 unittest 模块的一个扩展。它生成易于使用的 HTML 测试报告。HTMLTestRunner 是在 BSD 许可证下发布。
下载 地址:http://tungwaiyip.info/software/HTMLTestRunner.html(或者在我们群里下载)
Windows :将下载的文件放入...\Python27\Lib 目录下
二、生成报告
下面还是以百度为例,baidu.py代码如下:#coding=utf-8
from selenium importwebdriverfrom selenium.webdriver.common.by importByfrom selenium.webdriver.common.keys importKeysfrom selenium.webdriver.support.ui importSelectfrom selenium.common.exceptions importNoSuchAttributeExceptionimportunittest,time,reimportHTMLTestRunnerclassBaidu(unittest.TestCase):defsetUp(self):
self.driver=webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url= "http://www.baidu.com/"self.verificationErrors=[]
self.accept_next_alert=Truedeftest_baidu_search(self):
u"""百度搜索"""driver