http://tungwaiyip.info/software/HTMLTestRunner.html
下载,将下载后的文件放在python的Lib目录下

 # -*- coding:utf-8 -*-

 import HTMLTestRunner
import unittest
from selenium import webdriver class ResultDemo(unittest.TestCase): def setUp(self):
self.driver = webdriver.Firefox()
self.url = 'http://www.51testing.com' def test_login(self):
driver = self.driver
driver.get(self.url) driver.find_element_by_id('username').clear()
driver.find_element_by_id('username').send_keys('xxxxxx') driver.find_element_by_id('userpass').clear()
driver.find_element_by_id('userpass').send_keys('xxxxxx') driver.find_element_by_id('dologin').click() driver.find_element_by_id('xspace-seccode').clear()
input_seccode = raw_input('请输入验证码,并按 Enter 键:')
driver.find_element_by_id('xspace-seccode').send_keys(input_seccode)
driver.find_element_by_id('securitysubmit').click() def tearDown(self):
self.driver.quit()
#pass if __name__ == "__main__":
testsuite = unittest.TestSuite()
#添加测试用例到测试集中
testsuite.addTest(ResultDemo("test_login")) #生成测试报告文件
file_name = "D:/result.html"
fp = file(file_name, 'wb') renner = HTMLTestRunner.HTMLTestRunner(stream=fp, title='测试结果', description='测试报告')
renner.run(testsuite)

HTMLTestRunner 自动化测试报告-LMLPHP

05-02 06:55