From 3b84cce1ee43215b9f398148fda19f4b1025856b Mon Sep 17 00:00:00 2001 From: yj <2077506045@qq.com> Date: 星期三, 24 七月 2024 17:46:00 +0800 Subject: [PATCH] 测评系统自动测试 --- testcase/conftest.py | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) diff --git a/testcase/conftest.py b/testcase/conftest.py index 84df2a8..af175ca 100644 --- a/testcase/conftest.py +++ b/testcase/conftest.py @@ -5,9 +5,28 @@ 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" + # options.add_argument('--headless') + # options.add_argument('--no-sandbox') + # options.add_argument('--disable-gpu') + # options.add_argument('--disable-dev-shm-usage') + # options.add_argument('window-size=1200x600') + # 鍒濆鍖杦ebdriver + driver = webdriver.Chrome(options=options) + request.addfinalizer(driver.quit) + return driver + + +@pytest.fixture(scope="session") def data_read(request) -> dict: """ 璇诲彇娴嬭瘯浣跨敤鐨勬暟鎹� @@ -16,9 +35,14 @@ """ # 鑾峰彇褰撳墠椤圭洰鏍硅矾寰� root_path = os.getcwd() + print(root_path) + if "testcase" in root_path: + root_path = root_path.replace('testcase', '') # 鑾峰彇鍒拌鑾峰彇鏁版嵁鐨勯敭 key = request.param + file_path = os.path.join(root_path, "data", "test_data.json") + print("file_path:", file_path) # 璇诲彇鏁版嵁 - with open(root_path + r"\data\test_data.json", "r", encoding="utf-8") as f: + with open(file_path, "r", encoding="utf-8") as f: values = json.load(f) return values[key] -- Gitblit v1.9.1