def before_func(self): DriverUtil.get_driver() # 获取驱动对象 self.factory = PageFactory() yield # 结束操作 time.sleep(3) DriverUtil.quit_driver() # 退出驱动对象
def tearDownClass(cls): DriverUtil.quit_driver()
def tearDownClass(cls) -> None: DriverUtil.quit_driver() # 退出浏览器对象
import time import unittest from report.HTMLTestRunner.HTMLTestRunner import HTMLTestRunner from script.cart_case import TestCart from script.login_case import TestLogin from utils import DriverUtil suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestLogin)) suite.addTest(unittest.makeSuite(TestCart)) DriverUtil.kaiguan = False with open("./report/report.html", "wb") as f: runner = HTMLTestRunner(stream=f, title="tpshop商城测试用例", description="报告描述") runner.run(suite) DriverUtil.kaiguan = True DriverUtil.quit_driver()
def tearDownClass(cls): sleep(2) DriverUtil.quit_driver() # 退出浏览器对象
def tearDownClass(cls): time.sleep(3) DriverUtil.quit_driver() # 退出浏览器对象