| | |
| | | import pytest |
| | | import json |
| | | import os |
| | | from selenium import webdriver |
| | | from selenium.webdriver.chrome.options import Options |
| | | from selenium.webdriver.chrome.service import Service |
| | | from webdriver_manager.chrome import ChromeDriverManager |
| | | |
| | | |
| | | @pytest.fixture |
| | | @pytest.fixture(scope="session") |
| | | def driver(request): |
| | | options = Options() |
| | | options.debugger_address = "127.0.0.1:9222" |
| | | # 初始化webdriver |
| | | driver = webdriver.Chrome(options=options) |
| | | request.addfinalizer(driver.quit) |
| | | return driver |
| | | |
| | | |
| | | @pytest.fixture(scope="session") |
| | | def data_read(request) -> dict: |
| | | """ |
| | | 读取测试使用的数据 |
| | |
| | | """ |
| | | # 获取当前项目根路径 |
| | | root_path = os.getcwd() |
| | | if "\\testcase" in root_path: |
| | | root_path = root_path[0:root_path.rfind("\\testcase")] |
| | | # 获取到要获取数据的键 |
| | | key = request.param |
| | | # 读取数据 |