verify
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVerify UI Changes
验证UI变更
Use the Shiplight MCP browser tools to visually verify that your code changes look and behave correctly in a real browser.
使用Shiplight MCP浏览器工具,在真实浏览器中直观验证代码变更的外观和行为是否符合预期。
When to use
适用场景
Use after making UI changes to confirm they render correctly. This is useful for:
/verify- Checking layout, styling, or component changes visually
- Verifying interactive behavior (clicks, form inputs, navigation)
- Pre-commit sanity checks on UI work
- Debugging visual regressions
在进行UI变更后使用命令,确认渲染效果是否正确。适用于:
/verify- 直观检查布局、样式或组件变更
- 验证交互行为(点击、表单输入、导航)
- UI工作提交前的 sanity 检查
- 调试视觉回归问题
When NOT to use
不适用场景
Skip when changes don't affect UI rendering:
/verify- Backend-only changes (API logic, database, config)
- Dependency version bumps with no UI impact
- Documentation, comments, or test-only changes
当变更不影响UI渲染时,无需使用:
/verify- 仅后端变更(API逻辑、数据库、配置)
- 无UI影响的依赖版本更新
- 文档、注释或仅测试代码的变更
Steps
操作步骤
The following steps are a general guideline — adapt based on what makes sense for the specific changes:
-
Understand what changed — analyze the code changes and build a verification plan:
- What files/components changed
- What pages and interactions to check
- Pass/fail criteria (what "correct" looks like)
This is the most important step — it determines your test coverage. Balance thoroughness with cost. -
Start the dev server (if not already running) — check if the app's dev server is running. If not, start it in the background using the appropriate command (e.g.,
npm run dev). Wait a few seconds for it to be ready.yarn dev -
Open a browser session — callwith the
new_sessionpointing to the page you want to verify. If you want to generate a report afterwards, setstarting_url. Multiple concurrent sessions are supported — you can open several to compare different pages or states.record_evidence: true -
Inspect the page — callto get the DOM tree with element indices and a screenshot. Always read the DOM file first — it provides the element indices needed for
inspect_pageand consumes far fewer tokens. Only view the screenshot when you specifically need visual information (layout, colors, images), as screenshots consume significantly more tokens than DOM.act -
Interact and verify — useto simulate user actions based on the element indices from
act. Useinspect_pagewith verify actions to assert expected UI state (e.g. text is visible, element exists).act -
Check for errors — callto check for any JavaScript errors that may have been introduced.
get_browser_console_logs -
Report findings — summarize what you verified:
- What pages/components were checked
- Whether the UI renders correctly
- Any console errors or visual issues found
- Screenshots showing the verified state
-
Close the session — callwhen done. It returns
close_sessionandlocal_video_path.local_trace_path -
Generate the report — if the session was started with, call
record_evidence: truewith the local paths:generate_html_reportjson{ "session_id": "<session_id>", "local_video_path": "<local_video_path from close_session>", "local_trace_path": "<local_trace_path from close_session>", "title": "...", "summary": "...", "checks": [...] }Show the returnedto the user so they can open and review it.file_path -
Upload the report for sharing — when the user wants a shareable link (e.g. to attach to a PR), andis available:
upload_html_reportjson{ "report_path": "<file_path from generate_html_report>", "local_video_path": "<local_video_path from close_session>", "local_trace_path": "<local_trace_path from close_session>" }This uploads the video, trace, and report HTML to Shiplight cloud, patches the HTML with cloud URLs, and returns a permanent shareable.report_url
以下为通用指南,可根据具体变更调整:
-
明确变更内容 —— 分析代码变更并制定验证计划:
- 哪些文件/组件发生了变更
- 需要检查哪些页面和交互
- 判定标准(“正确”的效果是什么样的)
这是最重要的一步——决定了测试覆盖范围。需在全面性和成本之间找到平衡。 -
启动开发服务器(若未运行)—— 检查应用的开发服务器是否已启动。若未启动,使用对应命令在后台启动(例如、
npm run dev)。等待几秒直至服务器就绪。yarn dev -
打开浏览器会话 —— 调用,将
new_session指向需要验证的页面。若后续需要生成报告,设置starting_url。支持多并发会话——可打开多个会话以对比不同页面或状态。record_evidence: true -
检查页面 —— 调用获取带元素索引的DOM树和截图。请优先查看DOM文件——它提供了
inspect_page命令所需的元素索引,且消耗的token远少于截图。仅当需要获取视觉信息(布局、颜色、图片)时才查看截图,因为截图消耗的token远多于DOM。act -
交互与验证 —— 根据返回的元素索引,使用
inspect_page模拟用户操作。结合验证型act操作断言预期UI状态(例如文本可见、元素存在)。act -
检查错误 —— 调用检查是否引入了JavaScript错误。
get_browser_console_logs -
报告验证结果 —— 总结验证内容:
- 检查了哪些页面/组件
- UI渲染是否正确
- 发现的任何控制台错误或视觉问题
- 展示验证状态的截图
-
关闭会话 —— 完成后调用,它会返回
close_session和local_video_path。local_trace_path -
生成报告 —— 若启动会话时设置了,使用本地路径调用
record_evidence: true:generate_html_reportjson{ "session_id": "<session_id>", "local_video_path": "<local_video_path from close_session>", "local_trace_path": "<local_trace_path from close_session>", "title": "...", "summary": "...", "checks": [...] }将返回的告知用户,以便他们打开查看报告。file_path -
上传报告用于分享 —— 当用户需要可分享链接(例如附加到PR)且可用时:
upload_html_reportjson{ "report_path": "<file_path from generate_html_report>", "local_video_path": "<local_video_path from close_session>", "local_trace_path": "<local_trace_path from close_session>" }此操作会将视频、追踪文件和报告HTML上传至Shiplight云,用云URL修补HTML,并返回永久可分享的。report_url
Apps that require login
需要登录的应用
If the app requires authentication, log in once and save the session so future sessions skip the login step:
- Open a browser session with at the app's login page.
new_session - Ask the user to switch to the browser and log in manually. Wait for them to confirm.
- Call to save cookies and localStorage to
save_storage_state(e.g.~/.shiplight/<site_url>/storage-state.json).~/.shiplight/http_localhost_3000/storage-state.json - For all future sessions, pass the same path as to
storage_state_pathto restore the authenticated state instantly.new_session
If a saved storage state file already exists, use it automatically. If authentication fails with a saved state (page redirects to login, auth errors in console), the state is likely expired — ask the user to log in again and re-save.
若应用需要认证,只需登录一次并保存会话,后续会话可跳过登录步骤:
- 在应用的登录页面调用打开浏览器会话。
new_session - 请用户切换到浏览器手动登录。等待用户确认登录完成。
- 调用将cookie和localStorage保存至
save_storage_state(例如~/.shiplight/<site_url>/storage-state.json)。~/.shiplight/http_localhost_3000/storage-state.json - 后续所有会话中,将同一路径作为传入
storage_state_path,即可立即恢复认证状态。new_session
若已存在保存的存储状态文件,自动使用该文件。若使用保存的状态认证失败(页面重定向到登录页、控制台出现认证错误),则状态可能已过期——请用户重新登录并重新保存状态。