# Web UI 测试自动化

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/go/llms.txt).

使用 Cypress 或 Playwright 测试应用程序的 Web 接口。 [测试自动化](https://plugins.jetbrains.com/plugin/20175-test-automation)插件添加了用于生成和检查定位器的编码辅助与工具。

测试自动化工具包括以下功能:

* 对 [Cypress](cypress.html) 和 [Playwright](playwright.html) 框架的丰富支持

* 用于 [运行测试](#run-tests)、 [查看结果](#review-test-results)和 [调试 Playwright 测试](#debug-tests)的工具

* 广泛的 [编码辅助](#editing-code)

* [定位器生成和验证](#generate-locators)

> **Note:**
> 无需   Test Automation   插件，即可运行 Cypress 和 Playwright 测试并调试 Playwright 测试。 [Cypress 测试不支持 IDE 调试器](cypress.html#debug_tests)。

如需了解有关测试自动化功能的更多信息，请参阅 [官方 Aqua 文档](https://www.jetbrains.com/zh-cn/help/aqua)。

Procedure: 安装 Test Automation 插件

1. 在   设置  对话框( `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)))中，选择   插件  。

2. 找到   Test Automation   插件并点击   安装  。

3. 点击   Apply  保存更改并关闭对话框。 如果出现提示，请重启 IDE。

## 测试自动化功能

### 测试识别

当您打开项目时，GoLand 会自动检测用 Cypress 或 Playwright 编写的测试。 可以通过点击装订区域中的 ![运行图标](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.run.run.svg) 图标运行识别出的测试，然后使用 IDE 的工具进行 [分析](#review-test-results)。

Cypress:

![查看测试](https://resources.jetbrains.com/help/img/idea/2026.3/aqua_cypress_run_tests.png)

Playwright:

![查看测试](https://resources.jetbrains.com/help/img/idea/2026.3/aqua_pw_run_tests.png)

### 编码辅助

提供的编码辅助功能包括智能代码补全、 [导航](navigating-through-the-source-code.html)、 [语法高亮显示](configuring-colors-and-fonts.html)、对框架特定函数和表达式的支持等。

例如，您可以在代码编辑器中开始输入定位器或其子字符串，自动完成功能将为您提供一个可选元素列表。 此外，所选元素将在   Web 检查器  中高亮显示，从而更容易选择正确的定位器。

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/aqua_locator_code_completion.mp4)

### 定位器生成与验证

Web 检查器   工具窗口允许查看 Web 应用程序并捕获自动化测试所需的页面元素。 在网页上选择所需元素时，GoLand 会生成一个唯一的 CSS 或 XPath 定位器，并帮助将其添加到源代码中。

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/aqua_locators_evaluator.mp4)

此外，GoLand 可以生成用于 Playwright 的 [基于角色的](playwright.html#role_based_locators_support)定位器。 这些定位器旨在反映元素的角色（例如，按钮或复选框），从而更容易识别。

![基于角色的定位器](https://resources.jetbrains.com/help/img/idea/2026.3/aqua_playwright_role_based_locators.png)

此外，   Web 检查器   可帮助验证代码中的定位器是否有效并指向网页上的正确元素。 点击代码编辑器中定位器旁边的 ![](https://resources.jetbrains.com/help/img/idea/2026.3/aqua-plugin.icons.inlayWebInspector.svg) 图标会打开   Web 检查器   并选择对应的元素，从而验证该定位器。

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/aqua_validating_locators.mp4)

> **Tip:**
> 有关   Web 检查器  的更多信息，请参阅 [Aqua 文档](https://www.jetbrains.com/zh-cn/help/aqua/web-inspector-overview.html)。

### 管理测试的运行 / 调试配置

运行/调试配置是一组启动属性，定义了要执行的内容以及在执行过程中应使用的参数和环境。

您可以为测试创建不同的 [配置](run-debug-configuration.html)集，并根据需要即时切换。

Cypress:

![管理测试运行配置](https://resources.jetbrains.com/help/img/idea/2026.3/aqua_cypress_run_debug_config.png)

Playwright:

![管理测试运行配置](https://resources.jetbrains.com/help/img/idea/2026.3/aqua_pw_run_debug_config.png)

### 测试执行详情

测试运行完成后，您将获得全面的结果，包括每个测试的日志和控制台输出，因此您可以轻松 [探索](viewing-and-exploring-test-results.html)它们。 您可以过滤结果，以便快速浏览失败或被忽略的测试，并分析它们的执行时间。

Cypress:

![查看测试结果](https://resources.jetbrains.com/help/img/idea/2026.3/aqua_cypress_failed_tests.png)

Playwright:

![查看测试结果](https://resources.jetbrains.com/help/img/idea/2026.3/aqua_pw_failed_tests.png)

### 调试器

[调试器](debugging-code.html)是一种用于测试和排查代码问题的工具。 它允许您逐步运行代码，并为您提供每一步发生的详细信息。

Playwright 测试的调试器开箱即用。 您可以设置 [断点](using-breakpoints.html)以暂停执行并分析代码。

> **Note:**
> GoLand 可以运行 Cypress 测试，但不支持使用 IDE 调试器调试这些测试。

## See also

### 参考

[运行测试](performing-tests.html) [调试](debugging-code.html) [探索测试结果](viewing-and-exploring-test-results.html) [运行/调试配置](run-debug-configuration.html)

### 外部链接

[Cypress](https://www.cypress.io/) [Playwright](https://playwright.dev/)

