资讯详情

android-ui-journey-testing - SKILL

📅 2026/10/26 1:42:12 | 华诺云谱 👁 阅读
android-ui-journey-testing - SKILL
name: android-ui-journey-testingdescription: “XML-specified Android UI journey testing, interactive step execution, assertion verification, and JSON outcome reporting.”category: testingrisk: criticalsource: selfsource_type: selfdate_added: “2026-06-18”author: Owaistags: [android, journey-testing, ui-verification, testing, adb, automation]tools: [claude, cursor, gemini, antigravity]Android 用户界面旅程测试概览此技能概述了在 Android 应用上运行 XML 指定的用户旅程测试的标准工作流程。“旅程” 是一组按顺序排列的用户操作和状态断言旨在验证端到端功能。旅程 XML 作为应用行为的事实来源。执行器按顺序进行执行 UI 交互、检查状态断言并编写标准化的 JSON 结果报告。何时使用在根据 XML 测试规范评估 Android 应用程序的用户界面行为时使用。在自动化多步骤用户流程例如登录、结账、导航并验证预期时使用。在运行验证测试和生成标准化 JSON 测试报告时使用。在使用 ADB 命令调试物理设备或模拟器上的应用程序流程时使用。运作方式YesNo/CrashPassedFailedYesNoParse Journey XMLExecute Action / InteractionSuccess?Verify State Expectation / AssertionMark FAILED ExitMore Steps?Output JSON Summary第1步解析旅程规范读取并解析 XML 测试套件结构。根节点journey定义测试用例名称actions块包含测试步骤的顺序。journeynameSearch and Cart FlowdescriptionVerify that searching for an item and adding it to the cart succeeds./descriptionactionsactionSearch for soda/actionactionTap the first search result/actionactionVerify that the product detail screen is shown/action/actions/journey步骤 2顺序步骤评估按照指定的确切顺序处理每个action元素。测试步骤分为两组A. 互动操作点击、滑动、文本输入使用 ADB 执行物理 UI 交互。轻触轻触目标元素边界的中心adb shell input tapxy滑动/滚动从一个坐标滑动到另一个坐标持续时间为adb shell input swipex1y1x2y2duration_ms文本输入在活动输入字段中输入文本adb shell input textstring如果元素缺失或无法执行操作则该操作和流程将失败。B. 陈述断言期望验证以“verify”“check”或“ensure”开头的步骤表示状态断言。检查当前屏幕使用截图或uiautomator dump无需互动或滚动。确认所有子断言都已满足。例如“验证应用程序是否在主屏幕上并且徽标可见”如果主屏幕未显示或徽标缺失则会失败。步骤3处理失败和崩溃如果应用程序崩溃、退出、冻结或断言失败立即停止旅程执行。将失败的步骤标记为FAILED。将任何后续步骤标记为跳过。记录失败的确切原因。第4步生成JSON报告将执行结果格式化为标准化的 JSON 模式并写入输出日志。例子示例 1完整行程 XML 规范journeynameLogin and Profile EditdescriptionLogs into the app, navigates to settings, and changes user profile information./descriptionactionsactionVerify that the username input field is visible/actionactionTap the username input field/actionactionType testuser into the input/actionactionTap the password input field/actionactionType a redacted test password into the input/actionactionTap the Login button/actionactionVerify that the Home dashboard is visible and user profile photo is shown/action/actions/journey示例 2标准 JSON 结果报告{journey:Login and Profile Edit,results:[{action:Verify that the username input field is visible,status:PASSED,commands:[],comment:Username input detected at bounds [100,200][980,300] via UI dump.},{action:Tap the username input field,status:PASSED,commands:[adb shell input tap 540 250],comment:Tapped center coordinates of username input.},{action:Type \testuser\ into the input,status:PASSED,commands:[adb shell input text \testuser\],comment:Username typed successfully.},{action:Tap the password input field,status:PASSED,commands:[adb shell input tap 540 370],comment:Tapped center of password input.},{action:Type a redacted test password into the input,status:PASSED,commands:[adb shell input text \[REDACTED_PASSWORD]\],comment:Password typed successfully. The actual input value was not stored in the report.},{action:Tap the \Login\ button,status:PASSED,commands:[adb shell input tap 540 500],comment:Login button clicked.},{action:Verify that the Home dashboard is visible and user profile photo is shown,status:FAILED,commands:[],comment:Dashboard loaded but profile photo was missing from the UI header.}]}最佳实践✅计算点击中心点在解析元素边界如[x1,y1][x2,y2]时总是要计算中间坐标xcenterx1x22,ycentery1y22x_{center} \frac{x_1 x_2}{2}, \quad y_{center} \frac{y_1 y_2}{2}xcenter​2x1​x2​​,ycenter​2y1​y2​​✅包含睡眠缓冲在交互操作如按钮点击后总是添加短暂延迟例如 1-2 秒以在执行断言之前让布局和过渡渲染完成。✅快速失败在遇到第一个失败时立即停止测试。失败后继续测试会导致结果无效。✅安全记录精确命令在 JSON 输出列表中包含非敏感的原始命令例如adb shell input tap以进行诊断。对输入到密码、一次性密码、令牌、支付或个人数据字段的文本进行脱敏切勿在报告、CI 日志或共享文件中保存真实的秘密信息。限制解析器只会评估静态屏幕层级例如uiautomator dump。需要滚动的元素除非明确执行滚动操作否则会被标记为不可见。非标准的用户界面组件如自定义的 OpenGL 画布视图不能通过标准的可访问性树读取可能需要截图分析或硬编码的点击地图。通过 ADB 的按键事件和文本输入在所有模拟器镜像上不会触发标准软键盘事件这可能导致输入验证问题。相关技能android-cli- 通用 CLI 工具语法、软件包安装和设备查询。android_ui_verification- 用于常规界面检查的直接 ADB 脚本模板。
📝

华诺云谱内容团队

资深建站顾问 · 行业研究员

10年+企业数字化服务经验,专注智能建站、SEO优化与品牌营销,持续输出建站技巧、行业洞察与营销干货,已帮助5000+企业实现数字化增长。

你可能需要的服务

订阅华诺云谱资讯周报

每周一封,精选建站技巧、SEO与营销干货,直达邮箱。已有 8,000+ 企业主订阅,助你少走弯路。

↑