不废话了,直接上图。 附上下载地址: https://download.csdn.net/download/cjh365047871/10389650
样式1
样式2
样式3
样式4
run.py
import time import unittest from HTMLTestRunner import HTMLTestRunner test_dir='./test_case' discover=unittest.defaultTestLoader.discover(test_dir,pattern="*test*.py") if __name__=="__main__": report_dir='./test_report' now=time.strftime("%Y-%m-%d %H-%M-%S") report_name=report_dir+'/'+now+'result.html' with open(report_name,'wb')as f: runner=HTMLTestRunner(stream=f,title="Test Report",description="test baidu") runner.run(discover) f.close()
test_baidu.py
import unittest from selenium import webdriver from time import sleep class TestBaidu(unittest.TestCase): def setUp(self): self.driver=webdriver.Chrome() self.driver.implicitly_wait(10) self.driver.get("http://www.baidu.com") def test_baidu(self): driver=self.driver driver.find_element_by_id("kw").clear() driver.find_element_by_id("kw").send_keys("Selenium 自学网") driver.find_element_by_id("su").click() sleep(3) title=driver.title self.assertEqual(title,"Selenium 自学网_百度搜索") driver.find_element_by_partial_link_text("Selenium自动化").click() sleep(5) def tearDown(self): self.driver.quit()后续会收集一些其他样式进行补充