diff --git a/mumu-pytest/config.png b/mumu-pytest/config.png new file mode 100644 index 0000000..4c45b26 Binary files /dev/null and b/mumu-pytest/config.png differ diff --git a/mumu-pytest/config_interface.png b/mumu-pytest/config_interface.png new file mode 100644 index 0000000..5d1f92c Binary files /dev/null and b/mumu-pytest/config_interface.png differ diff --git a/mumu-pytest/start_page.png b/mumu-pytest/start_page.png new file mode 100644 index 0000000..e352d09 Binary files /dev/null and b/mumu-pytest/start_page.png differ diff --git a/mumu-pytest/test_flomo_ai_config_and_start.py b/mumu-pytest/test_flomo_ai_config_and_start.py new file mode 100644 index 0000000..b4b4ed0 --- /dev/null +++ b/mumu-pytest/test_flomo_ai_config_and_start.py @@ -0,0 +1,117 @@ +""" +Flomo-ai 应用配置和启动页面测试 +""" + +import pytest +import pyautogui +import os +import time + + +def test_flomo_ai_config_and_start(emulator): + """ + 测试 flomo-ai 应用的配置和启动页面 + + 1. 检查是否有 config.png,有就通过,没有测试失败 + 2. 点击 config.png + 3. 检查界面是否有 start_page.png,有就通过,没有测试失败 + 4. 点击 start_page.png + """ + # 确保模拟器正在运行,如果未运行则启动 + if not emulator.is_running(): + print("模拟器未运行,正在启动...") + emulator.start() + time.sleep(10) # 等待模拟器启动完成 + + # 将模拟器窗口置顶 + emulator.bring_to_front() + time.sleep(5) # 增加等待时间,确保应用完全加载 + + # 将模拟器窗口置顶 + emulator.bring_to_front() + time.sleep(3) + + script_dir = os.path.dirname(__file__) + + # 1. 检查是否有 config.png + config_image_path = os.path.join(script_dir, "config.png") + if not os.path.exists(config_image_path): + pytest.fail(f"config.png 图片文件不存在: {config_image_path}") + + print("正在查找 config.png 图片...") + print(f"图片路径: {config_image_path}") + print(f"图片存在: {os.path.exists(config_image_path)}") + + config_location = None + for i in range(15): + try: + # 尝试不同的 confidence 值 + for confidence in [0.9, 0.8, 0.7, 0.6]: + config_location = pyautogui.locateOnScreen(config_image_path, confidence=confidence) + if config_location: + print(f"第 {i+1} 次尝试在 confidence={confidence} 时找到 config.png") + break + if config_location: + break + else: + print(f"第 {i+1} 次尝试未找到 config.png") + except Exception as e: + print(f"第 {i+1} 次尝试出现异常: {e}") + time.sleep(1) + + if not config_location: + # 截图保存当前屏幕状态用于调试 + screenshot_path = os.path.join(script_dir, "debug_config_not_found.png") + pyautogui.screenshot(screenshot_path) + print(f"未找到 config.png,已保存调试截图: {screenshot_path}") + pytest.fail("未找到 config.png 图片") + + print(f"找到 config.png,位置: {config_location}") + + # 2. 点击 config.png + center = pyautogui.center(config_location) + pyautogui.click(center) + print(f"已点击 config.png,位置: {center}") + time.sleep(3) # 等待配置页面加载 + + # 3. 检查界面是否有 start_page.png + start_page_image_path = os.path.join(script_dir, "start_page.png") + if not os.path.exists(start_page_image_path): + pytest.fail(f"start_page.png 图片文件不存在: {start_page_image_path}") + + print("正在查找 start_page.png 图片...") + print(f"图片路径: {start_page_image_path}") + + start_page_location = None + for i in range(15): + try: + start_page_location = pyautogui.locateOnScreen(start_page_image_path, confidence=0.7) + if start_page_location: + print(f"第 {i+1} 次尝试找到 start_page.png") + break + else: + print(f"第 {i+1} 次尝试未找到 start_page.png") + except Exception as e: + print(f"第 {i+1} 次尝试出现异常: {e}") + time.sleep(1) + + if not start_page_location: + # 截图保存当前屏幕状态用于调试 + screenshot_path = os.path.join(script_dir, "debug_start_page_not_found.png") + pyautogui.screenshot(screenshot_path) + print(f"未找到 start_page.png,已保存调试截图: {screenshot_path}") + pytest.fail("未找到 start_page.png 图片") + + print(f"找到 start_page.png,位置: {start_page_location}") + + # 4. 点击 start_page.png + center = pyautogui.center(start_page_location) + pyautogui.click(center) + print(f"已点击 start_page.png,位置: {center}") + time.sleep(3) # 等待页面响应 + + # 验证测试成功 + assert config_location is not None, "config.png 未找到,测试失败" + assert start_page_location is not None, "start_page.png 未找到,测试失败" + + print("Flomo-ai 配置和启动页面测试通过!") \ No newline at end of file