From a0cb6f876023af084003710a73b62c652644920a Mon Sep 17 00:00:00 2001 From: longpeng Date: Mon, 30 Jun 2025 00:07:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96UI=E6=B5=8B=E8=AF=95=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=A7=BB=E9=99=A4=E7=94=A8=E6=88=B7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8F=82=E6=95=B0=EF=BC=8C=E6=94=AF=E6=8C=81=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E4=BC=9A=E8=AF=9D=E5=A4=8D=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workers/python/activities.py | 2 +- workers/python/ui_tests.py | 11 +---------- workflows/workflow.go | 9 ++++----- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/workers/python/activities.py b/workers/python/activities.py index ecdf948..1517fea 100644 --- a/workers/python/activities.py +++ b/workers/python/activities.py @@ -135,7 +135,7 @@ class TestActivities: # 调用实际的UI测试逻辑,执行浏览器自动化测试并返回本地文件路径 ui_test_success, log_output, screenshot_path, html_report_path = await execute_ui_test_case( - req.test_case_id, req.url_path, req.browser_type, req.headless, scalar_map_to_dict(req.user_data) + req.test_case_id, req.url_path, req.browser_type, req.headless ) # 填充基本测试结果 diff --git a/workers/python/ui_tests.py b/workers/python/ui_tests.py index a7f53f6..72d1844 100644 --- a/workers/python/ui_tests.py +++ b/workers/python/ui_tests.py @@ -9,7 +9,7 @@ from typing import Optional _browser_sessions = {} _playwright_instance = None -async def execute_ui_test_case(test_case_id: str, url_path: str, browser_type: str, headless: bool, user_data: dict, browser_session_id: Optional[str] = None): +async def execute_ui_test_case(test_case_id: str, url_path: str, browser_type: str, headless: bool, browser_session_id: Optional[str] = None): """ 实际执行UI测试的函数。 支持浏览器会话复用。 @@ -54,15 +54,6 @@ async def execute_ui_test_case(test_case_id: str, url_path: str, browser_type: s page = await browser.new_page() - # 模拟登录(如果需要) - if user_data: - log_output.append(f"Attempting to log in with user: {user_data.get('user')}") - await page.goto(f"{base_url}/login") - await page.fill('input[name="username"]', user_data.get('user', '')) - await page.fill('input[name="password"]', user_data.get('pass', '')) - await page.click('button[type="submit"]') - await page.wait_for_url(full_url) - await page.goto(full_url) log_output.append(f"Navigated to: {full_url}") diff --git a/workflows/workflow.go b/workflows/workflow.go index d414aa9..51c1251 100644 --- a/workflows/workflow.go +++ b/workflows/workflow.go @@ -82,11 +82,10 @@ func TestRunWorkflow(ctx workflow.Context, input *pb.TestRunInput) (*pb.TestRunO // 构造 UI 测试的请求参数 // 包含浏览器配置和测试页面信息 uiTestInput := &pb.UiTestRequest{ - TestCaseId: "ui-example-1", // UI 测试用例标识 - UrlPath: "/dashboard", // 要测试的页面路径 - BrowserType: "chromium", // 使用的浏览器类型 - Headless: true, // 是否使用无头模式运行浏览器 - UserData: map[string]string{"user": "test", "pass": "password"}, // 测试用的用户数据 + TestCaseId: "ui-example-1", // UI 测试用例标识 + UrlPath: "/dashboard", // 要测试的页面路径 + BrowserType: "chromium", // 使用的浏览器类型 + Headless: true, // 是否使用无头模式运行浏览器 } // 声明变量用于接收 UI 测试的结果