- 开始使用
- 最佳实践
- 功能
- 技能
- CLI
- 示例
- 高级
- 帮助
使用 uipath-test 技能的 Playwright 测试自动化
使用 uipath-test 技能将现有 Playwright 套件引入 UiPath Test Manager,而无需更改代码。
借助 uipath-test 技能,受支持的编码智能体无需更改代码,即可将现有 Playwright 测试套件引入 UiPath Test Manager。
用简单的语言询问您的智能体,它会创建 Test Manager 项目,打包套件,将其上传到 Orchestrator,自动创建链接的测试用例,构建测试集,运行测试集,并报告通过、失败和跳过结果。
当测试失败时,您可以完全从终端要求智能体修复、重新打包、重新发布和重新运行。如果没有此技能,则将现有的 Playwright 套件引入 Test Manager 需要将测试重写为 UiPath 自动化 — 此流程会不变地打包您的 Playwright 代码。
先决条件
- 已安装 UiPath CLI (
uip) 并通过身份验证 (uip login)。此流程中使用的--playwright-project标志需要 CLI 版本 1.203.0 或更高版本。 - 为您的编码智能体 (
uip skills install --agent <agent>) 安装的 UiPath 技能,该智能体将安装uipath-test技能捆绑包。 - Playwright support enabled for your tenant. Without it, Test Manager never creates the test cases.
- Playwright installed locally in the project you want to bring into Test Manager: a
package.jsonwith@playwright/test, a lockfile (package-lock.json,yarn.lock,pnpm-lock.yaml, orbun.lock), and aplaywright.configfile. The skill packages your existing suite as-is and does not install Playwright for you. - An Orchestrator folder for the test runs with a Cloud Robots – Serverless machine and a member that can run unattended sessions, such as a robot account. The agent checks the folder and can create and assign the serverless machine. Without a member that can run unattended, executions are canceled or never produce results.
- Test Manager 将用于运行测试的机器人帐户在目标 Test Manager 项目中具有测试执行者角色。否则,系统将执行测试,但结果将永远不会到达 Test Manager。有关更多信息,请参阅《Playwright 测试自动化指南》中的“先决条件” 。
将套件导入 Test Manager
-
在 Playwright 项目的根文件夹中打开编码智能体。
-
要求其将套件导入 Test Manager:
“我编写了一些 Playwright 脚本来测试我的网站 [产品名称]。你能否帮助我使用 UiPath 的 Test Manager 服务运行这些测试?
-
在首次运行时回答有关智能体的设置问题:测试应进入哪个 Test Manager 项目(或是否创建新项目),以及哪个 Playwright 作用域(例如
regression、smoke或checkout-critical)以优先执行。 -
查看智能体报告的通过、失败和跳过摘要,包括哪些故障看起来像真实的断言不匹配,而与环境或基础架构问题相比。
结果:
Behind the scenes, the agent sets the default Orchestrator execution folder for the Test Manager project, packages the Playwright project into a .nupkg, and uploads it to the Orchestrator package feed.
Test Manager 会为每个发现的测试自动创建并自动链接一个测试用例。然后,智能体创建一个限定于所选 Playwright 项目的测试集、运行并轮询,直到执行完成。
修复失败的测试并重新运行
要求您的智能体修复并重新运行:
“修复失败的测试,然后重新运行冒烟测试集。”
智能体修复失败的测试代码,然后使用提升的包版本重新打包,重新上传并重新运行相同的测试集。Playwright 项目和作用域选择保留在测试集上,因此您无需重新指定它。
请勿让智能体使用 uip tm executions retry 在修复后重新运行。该命令对旧的包版本重新运行先前失败的执行,与此循环相反。相反,智能体会颠倒 --package-version,重新打包并重新上传,然后重新运行相同的测试集。
命令参考
智能体会自动从您的提示中选择这些命令 — 您无需自行输入。它们对于故障排除或在 CI 中编写相同流程的脚本非常有用。
| 步骤 | 命令 |
|---|---|
| 创建 Test Manager 项目 | uip tm project create --name "SwagLabs" --project-key SWAG --description "..." --output json |
| 设置默认执行文件夹 | uip tm project set-default-folder --project-key SWAG --folder-key <key> --output json |
| 打包 Playwright 项目 | uip tm pack --project-path . --type playwright --project-key SWAG --name SwagLabsPlaywright --package-version 1.0.0 -o .packages --output json |
| 上传到 Orchestrator | uip or packages upload ".packages/SwagLabsPlaywright.1.0.0.nupkg" --output json |
| 轮询提取的测试用例 | uip tm testcases list --project-key SWAG --output json |
| 运行测试集,并将其范围限定为 Playwright 项目 | uip tm testsets run --test-set-key SWAG:37 --playwright-project regression --output json |
| 轮询执行状态和结果 | uip tm report get --execution-id <id> --project-key SWAG --output json |
| 提取分类失败的详细信息 | uip tm executions testcaselogs list --execution-id <id> --project-key SWAG --only-failed --output json |
uip tm testcases list 不会采用 --limit 标志。
另请参阅
- 测试— 编码智能体可以使用 Test Manager 执行的操作的完整列表。
uip tm pack— 此流程中使用的打包命令的完整参考。uip tm testsets—testsets run和--playwright-project标志的完整引用。uip or packages— 有关将包发布到 Orchestrator 的完整参考。