@pytest.fixture(scope="class")
def setup_driver(self):
# 在测试类开始前初始化 WebDriver
path = "D:\AutoTest\webdriver\chrome\chromedriver.exe" # 指定chromedriver 需要和应用文件的chrome同-版本
options = webdriver.ChromeOptions()
# options.add_argument('headless')
options.binary_location = "D:\CET\Common\PecExplorer\PecExplorer.exe" # 打包后的Electron应用文件路径path
driver = webdriver.Chrome(options=options)
# 设置隐式等待时间为10秒
# driver.implicitly_wait(20)
yield driver
driver.quit()
使用WebDriver的时候,传入setup_driver
def test_Event(self, setup_driver):
driver = setup_driver