SuperAPI AI 工具集

webapp-testing

测试与质量

查看项目

更新于 10-16 03:49

技能介绍

用途:用原生 Python Playwright 脚本测试本地 Web 应用,验证前端功能、调试 UI 行为并采集页面信息。

主要能力:提供辅助脚本 scripts/with_server.py 管理服务器生命周期并支持多服务器;可结合 Playwright 完成导航、截图、DOM 检查与元素定位。

使用方式:脚本先运行 --help 查看用法,不要先读源码,脚本体量较大,应作为黑盒直接调用。判断流程:若为静态 HTML,可直接读取文件确定选择器;失败或不完整则按动态应用处理。动态应用若服务器未运行,先执行 python scripts/with_server.py --help,再用辅助脚本加简化 Playwright 脚本;服务器已运行时采用“先侦察后操作”:导航并等待 networkidle,截图或检查 DOM,从渲染状态识别选择器,再执行操作。

单服务器示例:python scripts/with_server.py --server "npm run dev" --port 5173 -- python your_automation.py。多服务器示例:python scripts/with_server.py --server "cd backend && python server.py" --port 3000 --server "cd frontend && npm run dev" --port 5173 -- python your_automation.py。自动化脚本中只写 Playwright 逻辑,服务器由辅助脚本自动管理;使用 sync_playwright(),chromium 始终以 headless 模式启动,结束时关闭浏览器,选择器可用 text=、role=、CSS 或 ID,并加入 page.wait_for_selector() 或 page.wait_for_timeout() 等等待。

限制:动态应用在等待 networkidle 前不要检查 DOM。参考文件包括 examples/element_discovery.py、static_html_automation.py、console_logging.py。具体价格与平台支持暂未提供。