From e5e44754c88e7e23e5253da37645082a3b388070 Mon Sep 17 00:00:00 2001 From: wehub-resource-sync Date: Mon, 13 Jul 2026 10:28:24 +0000 Subject: [PATCH] docs: make Chinese README the default --- README.md | 923 +++++++++++++++++++++++++++--------------------------- 1 file changed, 463 insertions(+), 460 deletions(-) diff --git a/README.md b/README.md index de61567..802b60e 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,41 @@ + +> [!NOTE] +> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。 +> [English](./README.en.md) · [原始项目](https://github.com/microsoft/playwright-mcp) · [上游 README](https://github.com/microsoft/playwright-mcp/blob/HEAD/README.md) +> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。 + ## Playwright MCP -A Model Context Protocol (MCP) server that provides browser automation capabilities using [Playwright](https://playwright.dev). This server enables LLMs to interact with web pages through structured accessibility snapshots, bypassing the need for screenshots or visually-tuned models. +一个基于 [Playwright](https://playwright.dev). 的 Model Context Protocol(MCP)服务器,提供浏览器自动化能力。该服务器使 LLM 能够通过结构化的可访问性快照与网页交互,无需截图或依赖视觉调优模型。 -### Playwright MCP vs Playwright CLI +### Playwright MCP 与 Playwright CLI -This package provides MCP interface into Playwright. If you are using a **coding agent**, you might benefit from using the [CLI+SKILLS](https://github.com/microsoft/playwright-cli) instead. +本包为 Playwright 提供 MCP 接口。若你使用的是**编程代理(coding agent)**,使用 [CLI+SKILLS](https://github.com/microsoft/playwright-cli) 可能更合适。 -- **CLI**: Modern **coding agents** increasingly favor CLI–based workflows exposed as SKILLs over MCP because CLI invocations are more token-efficient: they avoid loading large tool schemas and verbose accessibility trees into the model context, allowing agents to act through concise, purpose-built commands. This makes CLI + SKILLs better suited for high-throughput coding agents that must balance browser automation with large codebases, tests, and reasoning within limited context windows.
**Learn more about [Playwright CLI with SKILLS](https://github.com/microsoft/playwright-cli)**. +- **CLI**:现代**编程代理**越来越倾向于将基于 CLI 的工作流以 SKILL 形式暴露,而不是 MCP,因为 CLI 调用更节省 token:它们避免将大型工具 schema 和冗长的可访问性树加载到模型上下文中,使代理能够通过简洁、专用的命令执行操作。这使得 CLI + SKILLs 更适合高吞吐的编程代理——这类代理必须在有限的上下文窗口内,在浏览器自动化与大型代码库、测试和推理之间取得平衡。
**了解更多:[Playwright CLI with SKILLS](https://github.com/microsoft/playwright-cli)**.** -- **MCP**: MCP remains relevant for specialized agentic loops that benefit from persistent state, rich introspection, and iterative reasoning over page structure, such as exploratory automation, self-healing tests, or long-running autonomous workflows where maintaining continuous browser context outweighs token cost concerns. +- **MCP**:MCP 仍适用于受益于持久状态、丰富内省能力以及对页面结构进行迭代推理的专用智能体循环,例如探索性自动化、自愈测试,或长时间运行的自主工作流——在这些场景中,维持连续的浏览器上下文比 token 成本更重要。 -### Key Features +### 主要特性 -- **Fast and lightweight**. Uses Playwright's accessibility tree, not pixel-based input. -- **LLM-friendly**. No vision models needed, operates purely on structured data. -- **Deterministic tool application**. Avoids ambiguity common with screenshot-based approaches. +- **快速且轻量**。使用 Playwright 的可访问性树,而非基于像素的输入。 +- **对 LLM 友好**。无需视觉模型,完全基于结构化数据运行。 +- **确定性的工具调用**。避免基于截图方案常见的歧义。 -### Requirements -- Node.js 18 or newer -- VS Code, Cursor, Windsurf, Claude Desktop, Goose, Grok, Junie or any other MCP client +### 要求 +- Node.js 18 或更高版本 +- VS Code、Cursor、Windsurf、Claude Desktop、Goose、Grok、Junie 或任何其他 MCP 客户端 -### Getting started +### 快速开始 -First, install the Playwright MCP server with your client. +首先,在你的客户端中安装 Playwright MCP 服务器。 -**Standard config** works in most of the tools: +**标准配置**适用于大多数工具: ```js { @@ -49,7 +55,7 @@ First, install the Playwright MCP server with your client.
Amp -Add via the Amp VS Code extension settings screen or by updating your settings.json file: +通过 Amp VS Code 扩展设置界面添加,或更新你的 settings.json 文件: ```json "amp.mcpServers": { @@ -62,9 +68,9 @@ Add via the Amp VS Code extension settings screen or by updating your settings.j } ``` -**Amp CLI Setup:** +**Amp CLI 设置:** -Add via the `amp mcp add`command below +通过下方 `amp mcp add` 命令添加 ```bash amp mcp add playwright -- npx @playwright/mcp@latest @@ -75,7 +81,7 @@ amp mcp add playwright -- npx @playwright/mcp@latest
Antigravity -Add via the Antigravity settings or by updating your configuration file: +通过 Antigravity 设置添加,或更新你的配置文件: ```json { @@ -95,7 +101,7 @@ Add via the Antigravity settings or by updating your configuration file:
Claude Code -Use the Claude Code CLI to add the Playwright MCP server: +使用 Claude Code CLI 添加 Playwright MCP 服务器: ```bash claude mcp add playwright npx @playwright/mcp@latest @@ -105,18 +111,18 @@ claude mcp add playwright npx @playwright/mcp@latest
Claude Desktop -Follow the MCP install [guide](https://modelcontextprotocol.io/quickstart/user), use the standard config above. +按照 MCP 安装[指南](https://modelcontextprotocol.io/quickstart/user), 使用上方标准配置。
Cline -Follow the instruction in the section [Configuring MCP Servers](https://docs.cline.bot/mcp/configuring-mcp-servers) +按照 [Configuring MCP Servers](https://docs.cline.bot/mcp/configuring-mcp-servers) 章节中的说明操作。 -**Example: Local Setup** +**示例:本地设置** -Add the following to your [`cline_mcp_settings.json`](https://docs.cline.bot/mcp/configuring-mcp-servers#editing-mcp-settings-files) file: +将以下内容添加到你的 [`cline_mcp_settings.json`](https://docs.cline.bot/mcp/configuring-mcp-servers#editing-mcp-settings-files) 文件中: ```json { @@ -140,13 +146,13 @@ Add the following to your [`cline_mcp_settings.json`](https://docs.cline.bot/mcp
Codex -Use the Codex CLI to add the Playwright MCP server: +使用 Codex CLI 添加 Playwright MCP 服务器: ```bash codex mcp add playwright npx "@playwright/mcp@latest" ``` -Alternatively, create or edit the configuration file `~/.codex/config.toml` and add: +或者,创建或编辑配置文件 `~/.codex/config.toml` 并添加: ```toml [mcp_servers.playwright] @@ -154,20 +160,20 @@ command = "npx" args = ["@playwright/mcp@latest"] ``` -For more information, see the [Codex MCP documentation](https://github.com/openai/codex/blob/main/codex-rs/config.md#mcp_servers). +更多信息请参阅 [Codex MCP documentation](https://github.com/openai/codex/blob/main/codex-rs/config.md#mcp_servers).
Copilot -Use the Copilot CLI to interactively add the Playwright MCP server: +使用 Copilot CLI 以交互方式添加 Playwright MCP 服务器: ```bash /mcp add ``` -Alternatively, create or edit the configuration file `~/.copilot/mcp-config.json` and add: +或者,创建或编辑配置文件 `~/.copilot/mcp-config.json` 并添加: ```json { @@ -186,67 +192,67 @@ Alternatively, create or edit the configuration file `~/.copilot/mcp-config.json } ``` -For more information, see the [Copilot CLI documentation](https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli). +更多信息请参阅 [Copilot CLI documentation](https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli).
Cursor -#### Click the button to install: +#### 点击按钮安装: [Install in Cursor](https://cursor.com/en/install-mcp?name=Playwright&config=eyJjb21tYW5kIjoibnB4IEBwbGF5d3JpZ2h0L21jcEBsYXRlc3QifQ%3D%3D) -#### Or install manually: +#### 或手动安装: -Go to `Cursor Settings` -> `MCP` -> `Add new MCP Server`. Name to your liking, use `command` type with the command `npx @playwright/mcp@latest`. You can also verify config or add command like arguments via clicking `Edit`. +前往 `Cursor Settings` -> `MCP` -> `Add new MCP Server`。名称可自定,类型选择 `command`,命令为 `npx @playwright/mcp@latest`。也可通过点击 `Edit` 验证配置或添加命令参数。
Factory -Use the Factory CLI to add the Playwright MCP server: +使用 Factory CLI 添加 Playwright MCP 服务器: ```bash droid mcp add playwright "npx @playwright/mcp@latest" ``` -Alternatively, type `/mcp` within Factory droid to open an interactive UI for managing MCP servers. +或者,在 Factory droid 中输入 `/mcp`,打开用于管理 MCP 服务器的交互式界面。 -For more information, see the [Factory MCP documentation](https://docs.factory.ai/cli/configuration/mcp). +更多信息请参阅 [Factory MCP documentation](https://docs.factory.ai/cli/configuration/mcp).
Gemini CLI -Follow the MCP install [guide](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md#configure-the-mcp-server-in-settingsjson), use the standard config above. +按照 MCP 安装[指南](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md#configure-the-mcp-server-in-settingsjson), 使用上方标准配置。
Goose -#### Click the button to install: +#### 点击按钮安装: [![Install in Goose](https://block.github.io/goose/img/extension-install-dark.svg)](https://block.github.io/goose/extension?cmd=npx&arg=%40playwright%2Fmcp%40latest&id=playwright&name=Playwright&description=Interact%20with%20web%20pages%20through%20structured%20accessibility%20snapshots%20using%20Playwright) -#### Or install manually: +#### 或手动安装: -Go to `Advanced settings` -> `Extensions` -> `Add custom extension`. Name to your liking, use type `STDIO`, and set the `command` to `npx @playwright/mcp`. Click "Add Extension". +前往 `Advanced settings` -> `Extensions` -> `Add custom extension`。名称可自定,类型使用 `STDIO`,并将 `command` 设为 `npx @playwright/mcp`。点击 "Add Extension"。
Grok -Use the Grok CLI to add the Playwright MCP server: +使用 Grok CLI 添加 Playwright MCP 服务器: ```bash grok mcp add playwright -- npx @playwright/mcp@latest ``` -Alternatively, create or edit the configuration file `~/.grok/config.toml` and add: +或者,创建或编辑配置文件 `~/.grok/config.toml` 并添加: ```toml [mcp_servers.playwright] @@ -254,20 +260,20 @@ command = "npx" args = ["@playwright/mcp@latest"] ``` -For more information, see the [Grok MCP documentation](https://docs.x.ai/build/features/mcp-servers). +更多信息请参阅 [Grok MCP documentation](https://docs.x.ai/build/features/mcp-servers).
Junie -To add the Playwright MCP server in Junie CLI: +在 Junie CLI 中添加 Playwright MCP 服务器: -1. Type `/mcp` -2. Press `Ctrl+A` to add a new MCP server -3. Select **Playwright** from the list +1. 输入 `/mcp` +2. 按 `Ctrl+A` 添加新的 MCP 服务器 +3. 从列表中选择 **Playwright** -Alternatively, add to `.junie/mcp/mcp.json`: +或者,添加到 `.junie/mcp/mcp.json`: ```json { @@ -283,7 +289,7 @@ Alternatively, add to `.junie/mcp/mcp.json`: } ``` -For more information, see the [Junie MCP configuration documentation](https://junie.jetbrains.com/docs/junie-cli-mcp-configuration.html). +更多信息请参阅 [Junie MCP 配置文档](https://junie.jetbrains.com/docs/junie-cli-mcp-configuration.html).
@@ -292,7 +298,7 @@ For more information, see the [Junie MCP configuration documentation](https://ju [![Add to Kiro](https://kiro.dev/images/add-to-kiro.svg)](https://kiro.dev/launch/mcp/add?name=playwright&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22%40playwright%2Fmcp%40latest%22%5D%7D) -Follow the MCP Servers [documentation](https://kiro.dev/docs/mcp/). For example in `.kiro/settings/mcp.json`: +请遵循 MCP Servers [文档](https://kiro.dev/docs/mcp/). 例如在 `.kiro/settings/mcp.json` 中: ```json { @@ -311,19 +317,19 @@ Follow the MCP Servers [documentation](https://kiro.dev/docs/mcp/). For example
LM Studio -#### Click the button to install: +#### 点击按钮安装: [![Add MCP Server playwright to LM Studio](https://files.lmstudio.ai/deeplink/mcp-install-light.svg)](https://lmstudio.ai/install-mcp?name=playwright&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyJAcGxheXdyaWdodC9tY3BAbGF0ZXN0Il19) -#### Or install manually: +#### 或手动安装: -Go to `Program` in the right sidebar -> `Install` -> `Edit mcp.json`. Use the standard config above. +在右侧边栏中转到 `Program` -> `Install` -> `Edit mcp.json`。使用上方的标准配置。
opencode -Follow the MCP Servers [documentation](https://opencode.ai/docs/mcp-servers/). For example in `~/.config/opencode/opencode.json`: +请遵循 MCP Servers [文档](https://opencode.ai/docs/mcp-servers/). 例如在 `~/.config/opencode/opencode.json` 中: ```json { @@ -346,36 +352,36 @@ Follow the MCP Servers [documentation](https://opencode.ai/docs/mcp-servers/). F
Qodo Gen -Open [Qodo Gen](https://docs.qodo.ai/qodo-documentation/qodo-gen) chat panel in VSCode or IntelliJ → Connect more tools → + Add new MCP → Paste the standard config above. +在 VSCode 或 IntelliJ 中打开 [Qodo Gen](https://docs.qodo.ai/qodo-documentation/qodo-gen) 聊天面板 → 连接更多工具 → + 添加新 MCP → 粘贴上方的标准配置。 -Click Save. +点击 Save
VS Code -#### Click the button to install: +#### 点击按钮安装: [Install in VS Code](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522playwright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D) [Install in VS Code Insiders](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522playwright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D) -#### Or install manually: +#### 或手动安装: -Follow the MCP install [guide](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server), use the standard config above. You can also install the Playwright MCP server using the VS Code CLI: +请遵循 MCP 安装 [指南](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server), 使用上方的标准配置。你也可以使用 VS Code CLI 安装 Playwright MCP 服务器: ```bash # For VS Code code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}' ``` -After installation, the Playwright MCP server will be available for use with your GitHub Copilot agent in VS Code. +安装完成后,即可在 VS Code 中将 Playwright MCP 服务器用于你的 GitHub Copilot agent。
Warp -Go to `Settings` -> `AI` -> `Manage MCP Servers` -> `+ Add` to [add an MCP Server](https://docs.warp.dev/knowledge-and-collaboration/mcp#adding-an-mcp-server). Use the standard config above. +转到 `Settings` -> `AI` -> `Manage MCP Servers` -> `+ Add` 以[添加 MCP 服务器](https://docs.warp.dev/knowledge-and-collaboration/mcp#adding-an-mcp-server). 使用上方的标准配置。 -Alternatively, use the slash command `/add-mcp` in the Warp prompt and paste the standard config from above: +或者,在 Warp 提示符中使用斜杠命令 `/add-mcp`,并粘贴上方的标准配置: ```js { "mcpServers": { @@ -394,74 +400,74 @@ Alternatively, use the slash command `/add-mcp` in the Warp prompt and paste the
Windsurf -Follow Windsurf MCP [documentation](https://docs.windsurf.com/windsurf/cascade/mcp). Use the standard config above. +请遵循 Windsurf MCP [文档](https://docs.windsurf.com/windsurf/cascade/mcp). 使用上方的标准配置。
-### Configuration +### 配置 -Playwright MCP server supports following arguments. They can be provided in the JSON configuration above, as a part of the `"args"` list: +Playwright MCP 服务器支持以下参数。你可以在上方 JSON 配置中提供它们,作为 `"args"` 列表的一部分: | Option | Description | |--------|-------------| -| --allowed-hosts | comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '*' to disable the host check.
*env* `PLAYWRIGHT_MCP_ALLOWED_HOSTS` | -| --allowed-origins | semicolon-separated list of TRUSTED origins to allow the browser to request. Default is to allow all. Important: *does not* serve as a security boundary and *does not* affect redirects.
*env* `PLAYWRIGHT_MCP_ALLOWED_ORIGINS` | -| --allow-unrestricted-file-access | allow access to files outside of the workspace roots. Also allows unrestricted access to file:// URLs. By default access to file system is restricted to workspace root directories (or cwd if no roots are configured) only, and navigation to file:// URLs is blocked.
*env* `PLAYWRIGHT_MCP_ALLOW_UNRESTRICTED_FILE_ACCESS` | -| --blocked-origins | semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed. Important: *does not* serve as a security boundary and *does not* affect redirects.
*env* `PLAYWRIGHT_MCP_BLOCKED_ORIGINS` | -| --block-service-workers | block service workers
*env* `PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS` | -| --browser | browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.
*env* `PLAYWRIGHT_MCP_BROWSER` | -| --caps | comma-separated list of additional capabilities to enable, possible values: vision, pdf, devtools.
*env* `PLAYWRIGHT_MCP_CAPS` | -| --cdp-endpoint | CDP endpoint to connect to.
*env* `PLAYWRIGHT_MCP_CDP_ENDPOINT` | -| --cdp-header | CDP headers to send with the connect request, multiple can be specified.
*env* `PLAYWRIGHT_MCP_CDP_HEADERS` | -| --cdp-timeout | timeout in milliseconds for connecting to CDP endpoint, defaults to 30000ms
*env* `PLAYWRIGHT_MCP_CDP_TIMEOUT` | -| --codegen | specify the language to use for code generation, possible values: "typescript", "none". Default is "typescript".
*env* `PLAYWRIGHT_MCP_CODEGEN` | -| --config | path to the configuration file.
*env* `PLAYWRIGHT_MCP_CONFIG` | -| --console-level | level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels.
*env* `PLAYWRIGHT_MCP_CONSOLE_LEVEL` | -| --device | device to emulate, for example: "iPhone 15"
*env* `PLAYWRIGHT_MCP_DEVICE` | -| --mobile | emulate a generic mobile device (Pixel 10 for Chromium, iPhone 17 for WebKit). Mobile pages are usually lighter, which saves tokens. Cannot be combined with --device.
*env* `PLAYWRIGHT_MCP_MOBILE` | -| --executable-path | path to the browser executable.
*env* `PLAYWRIGHT_MCP_EXECUTABLE_PATH` | -| --extension | Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright Extension" to be installed.
*env* `PLAYWRIGHT_MCP_EXTENSION` | -| --endpoint | Bound browser endpoint to connect to.
*env* `PLAYWRIGHT_MCP_ENDPOINT` | -| --grant-permissions | List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write".
*env* `PLAYWRIGHT_MCP_GRANT_PERMISSIONS` | -| --headless | run browser in headless mode, headed by default
*env* `PLAYWRIGHT_MCP_HEADLESS` | -| --host | host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.
*env* `PLAYWRIGHT_MCP_HOST` | -| --ignore-https-errors | ignore https errors
*env* `PLAYWRIGHT_MCP_IGNORE_HTTPS_ERRORS` | -| --init-page | path to TypeScript file to evaluate on Playwright page object
*env* `PLAYWRIGHT_MCP_INIT_PAGE` | -| --init-script | path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times.
*env* `PLAYWRIGHT_MCP_INIT_SCRIPT` | -| --isolated | keep the browser profile in memory, do not save it to disk.
*env* `PLAYWRIGHT_MCP_ISOLATED` | -| --image-responses | whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".
*env* `PLAYWRIGHT_MCP_IMAGE_RESPONSES` | -| --no-sandbox | disable the sandbox for all process types that are normally sandboxed.
*env* `PLAYWRIGHT_MCP_NO_SANDBOX` | -| --output-dir | path to the directory for output files.
*env* `PLAYWRIGHT_MCP_OUTPUT_DIR` | -| --output-max-size | Threshold for evicting old output files, in bytes.
*env* `PLAYWRIGHT_MCP_OUTPUT_MAX_SIZE` | -| --output-mode | whether to save snapshots, console messages, network logs to a file or to the standard output. Can be "file" or "stdout". Default is "stdout".
*env* `PLAYWRIGHT_MCP_OUTPUT_MODE` | -| --port | port to listen on for SSE transport.
*env* `PLAYWRIGHT_MCP_PORT` | -| --proxy-bypass | comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"
*env* `PLAYWRIGHT_MCP_PROXY_BYPASS` | -| --proxy-server | specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"
*env* `PLAYWRIGHT_MCP_PROXY_SERVER` | -| --sandbox | enable the sandbox for all process types that are normally not sandboxed.
*env* `PLAYWRIGHT_MCP_SANDBOX` | -| --save-session | Whether to save the Playwright MCP session into the output directory.
*env* `PLAYWRIGHT_MCP_SAVE_SESSION` | -| --secrets | path to a file containing secrets in the dotenv format
*env* `PLAYWRIGHT_MCP_SECRETS_FILE` | -| --shared-browser-context | reuse the same browser context between all connected HTTP clients.
*env* `PLAYWRIGHT_MCP_SHARED_BROWSER_CONTEXT` | -| --snapshot-mode | when taking snapshots for responses, specifies the mode to use. Can be "full" or "none". Default is "full".
*env* `PLAYWRIGHT_MCP_SNAPSHOT_MODE` | -| --storage-state | path to the storage state file for isolated sessions.
*env* `PLAYWRIGHT_MCP_STORAGE_STATE` | -| --test-id-attribute | specify the attribute to use for test ids, defaults to "data-testid"
*env* `PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE` | -| --timeout-action | specify action timeout in milliseconds, defaults to 5000ms
*env* `PLAYWRIGHT_MCP_TIMEOUT_ACTION` | -| --timeout-navigation | specify navigation timeout in milliseconds, defaults to 60000ms
*env* `PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION` | -| --user-agent | specify user agent string
*env* `PLAYWRIGHT_MCP_USER_AGENT` | -| --user-data-dir | path to the user data directory. If not specified, a temporary directory will be created.
*env* `PLAYWRIGHT_MCP_USER_DATA_DIR` | -| --viewport-size | specify browser viewport size in pixels, for example "1280x720"
*env* `PLAYWRIGHT_MCP_VIEWPORT_SIZE` | +| --allowed-hosts | 逗号分隔的主机列表,指定此服务器允许提供服务的主机。默认为服务器绑定的主机。传入 '*' 可禁用主机检查。
*env* `PLAYWRIGHT_MCP_ALLOWED_HOSTS` | +| --allowed-origins | 分号分隔的受信任来源(TRUSTED origins)列表,允许浏览器发起请求。默认允许所有来源。重要:*不*构成安全边界,*不*影响重定向。
*env* `PLAYWRIGHT_MCP_ALLOWED_ORIGINS` | +| --allow-unrestricted-file-access | 允许访问工作区根目录之外的文件。同时允许无限制访问 file:// URL。默认情况下,文件系统访问仅限于工作区根目录(若未配置根目录则为 cwd),且禁止导航到 file:// URL。
*env* `PLAYWRIGHT_MCP_ALLOW_UNRESTRICTED_FILE_ACCESS` | +| --blocked-origins | 分号分隔的来源列表,阻止浏览器发起请求。阻止列表在允许列表之前评估。若在未使用允许列表的情况下使用,不匹配阻止列表的请求仍会被允许。重要:*不*构成安全边界,*不*影响重定向。
*env* `PLAYWRIGHT_MCP_BLOCKED_ORIGINS` | +| --block-service-workers | 阻止 Service Worker
*env* `PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS` | +| --browser | 要使用的浏览器或 Chrome 渠道,可选值:chrome、firefox、webkit、msedge。
*env* `PLAYWRIGHT_MCP_BROWSER` | +| --caps | 逗号分隔的额外功能列表,可选值:vision、pdf、devtools。
*env* `PLAYWRIGHT_MCP_CAPS` | +| --cdp-endpoint | 要连接的 CDP 端点。
*env* `PLAYWRIGHT_MCP_CDP_ENDPOINT` | +| --cdp-header | 随连接请求发送的 CDP 请求头,可指定多个。
*env* `PLAYWRIGHT_MCP_CDP_HEADERS` | +| --cdp-timeout | 连接 CDP 端点的超时时间(毫秒),默认为 30000ms
*env* `PLAYWRIGHT_MCP_CDP_TIMEOUT` | +| --codegen | 指定代码生成使用的语言,可选值:"typescript"、"none"。默认为 "typescript"。
*env* `PLAYWRIGHT_MCP_CODEGEN` | +| --config | 配置文件路径。
*env* `PLAYWRIGHT_MCP_CONFIG` | +| --console-level | 要返回的控制台消息级别:"error"、"warning"、"info"、"debug"。每个级别都包含更严重级别的消息。
*env* `PLAYWRIGHT_MCP_CONSOLE_LEVEL` | +| --device | 要模拟的设备,例如:"iPhone 15"
*env* `PLAYWRIGHT_MCP_DEVICE` | +| --mobile | 模拟通用移动设备(Chromium 为 Pixel 10,WebKit 为 iPhone 17)。移动页面通常更轻量,可节省 token。不能与 --device 组合使用。
*env* `PLAYWRIGHT_MCP_MOBILE` | +| --executable-path | 浏览器可执行文件路径。
*env* `PLAYWRIGHT_MCP_EXECUTABLE_PATH` | +| --extension | 连接到正在运行的浏览器实例(仅 Edge/Chrome)。需要安装 "Playwright Extension"。
*env* `PLAYWRIGHT_MCP_EXTENSION` | +| --endpoint | 要连接的绑定浏览器端点。
*env* `PLAYWRIGHT_MCP_ENDPOINT` | +| --grant-permissions | 授予浏览器上下文的权限列表,例如 "geolocation"、"clipboard-read"、"clipboard-write"。
*env* `PLAYWRIGHT_MCP_GRANT_PERMISSIONS` | +| --headless | 以无头模式运行浏览器,默认为有界面模式
*env* `PLAYWRIGHT_MCP_HEADLESS` | +| --host | 服务器绑定的主机。默认为 localhost。使用 0.0.0.0 可绑定到所有网络接口。
*env* `PLAYWRIGHT_MCP_HOST` | +| --ignore-https-errors | 忽略 HTTPS 错误
*env* `PLAYWRIGHT_MCP_IGNORE_HTTPS_ERRORS` | +| --init-page | 在 Playwright page 对象上求值的 TypeScript 文件路径
*env* `PLAYWRIGHT_MCP_INIT_PAGE` | +| --init-script | 作为初始化脚本添加的 JavaScript 文件路径。该脚本会在页面任何脚本之前在每个页面上求值。可多次指定。
*env* `PLAYWRIGHT_MCP_INIT_SCRIPT` | +| --isolated | 将浏览器配置文件保存在内存中,不写入磁盘。
*env* `PLAYWRIGHT_MCP_ISOLATED` | +| --image-responses | 是否向客户端发送图像响应。可为 "allow" 或 "omit",默认为 "allow"。
*env* `PLAYWRIGHT_MCP_IMAGE_RESPONSES` | +| --no-sandbox | 为所有通常启用沙箱的进程类型禁用沙箱。
*env* `PLAYWRIGHT_MCP_NO_SANDBOX` | +| --output-dir | 输出文件目录路径。
*env* `PLAYWRIGHT_MCP_OUTPUT_DIR` | +| --output-max-size | 驱逐旧输出文件的阈值(字节)。
*env* `PLAYWRIGHT_MCP_OUTPUT_MAX_SIZE` | +| --output-mode | 是否将快照、控制台消息、网络日志保存到文件或标准输出。可为 "file" 或 "stdout"。默认为 "stdout"。
*env* `PLAYWRIGHT_MCP_OUTPUT_MODE` | +| --port | SSE 传输监听的端口。
*env* `PLAYWRIGHT_MCP_PORT` | +| --proxy-bypass | 绕过代理的域名列表(逗号分隔),例如 ".com,chromium.org,.domain.com"
*env* `PLAYWRIGHT_MCP_PROXY_BYPASS` | +| --proxy-server | 指定代理服务器,例如 "http://myproxy:3128" 或 "socks5://myproxy:8080"
*env* `PLAYWRIGHT_MCP_PROXY_SERVER` | +| --sandbox | 为所有通常未启用沙箱的进程类型启用沙箱。
*env* `PLAYWRIGHT_MCP_SANDBOX` | +| --save-session | 是否将 Playwright MCP 会话保存到输出目录。
*env* `PLAYWRIGHT_MCP_SAVE_SESSION` | +| --secrets | 包含 dotenv 格式密钥的文件路径
*env* `PLAYWRIGHT_MCP_SECRETS_FILE` | +| --shared-browser-context | 在所有已连接的 HTTP 客户端之间复用同一浏览器上下文。
*env* `PLAYWRIGHT_MCP_SHARED_BROWSER_CONTEXT` | +| --snapshot-mode | 为响应拍摄快照时指定使用的模式。可为 "full" 或 "none"。默认为 "full"。
*env* `PLAYWRIGHT_MCP_SNAPSHOT_MODE` | +| --storage-state | 隔离会话的 storage state 文件路径
*env* `PLAYWRIGHT_MCP_STORAGE_STATE` | +| --test-id-attribute | 指定用于测试 ID 的属性,默认为 "data-testid"
*env* `PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE` | +| --timeout-action | 指定操作超时时间(毫秒),默认为 5000ms
*env* `PLAYWRIGHT_MCP_TIMEOUT_ACTION` | +| --timeout-navigation | 指定导航超时时间(毫秒),默认为 60000ms
*env* `PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION` | +| --user-agent | 指定 User-Agent 字符串
*env* `PLAYWRIGHT_MCP_USER_AGENT` | +| --user-data-dir | 用户数据目录路径。若未指定,将创建临时目录。
*env* `PLAYWRIGHT_MCP_USER_DATA_DIR` | +| --viewport-size | 指定浏览器视口大小(像素),例如 "1280x720"
*env* `PLAYWRIGHT_MCP_VIEWPORT_SIZE` | -### User profile +### 用户配置文件 -You can run Playwright MCP with persistent profile like a regular browser (default), in isolated contexts for testing sessions, or connect to your existing browser using the browser extension. +你可以像在常规浏览器中一样,使用持久化配置文件(默认)运行 Playwright MCP,在隔离上下文中进行测试会话,或通过浏览器扩展连接到你现有的浏览器。 -**Persistent profile** +**持久化配置文件** -All the logged in information will be stored in the persistent profile, you can delete it between sessions if you'd like to clear the offline state. -Persistent profile is located at the following locations and you can override it with the `--user-data-dir` argument. +所有已登录信息都会保存在持久化配置文件中;如需清除离线状态,可以在会话之间删除它。 +持久化配置文件位于以下位置,你可以使用 `--user-data-dir` 参数覆盖它。 ```bash # Windows @@ -474,17 +480,15 @@ Persistent profile is located at the following locations and you can override it - ~/.cache/ms-playwright/mcp-{channel}-{workspace-hash} ``` -`{workspace-hash}` is derived from the MCP client's workspace root, so different projects get separate profiles automatically. +`{workspace-hash}` 派生自 MCP 客户端的工作区根目录,因此不同项目会自动获得独立的配置文件。 > [!IMPORTANT] -> A persistent profile can only be used by one browser instance at a time, so concurrent MCP clients sharing the same workspace will conflict. To run several clients in parallel, start each additional client with `--isolated` or point it at a distinct `--user-data-dir`. +> 持久化配置文件同一时间只能被一个浏览器实例使用,因此共享同一工作区的并发 MCP 客户端会发生冲突。要并行运行多个客户端,请为每个额外客户端使用 `--isolated` 启动,或将其指向不同的 `--user-data-dir`。 -**Isolated** +**隔离模式** -In the isolated mode, each session is started in the isolated profile. Every time you ask MCP to close the browser, -the session is closed and all the storage state for this session is lost. You can provide initial storage state -to the browser via the config's `contextOptions` or via the `--storage-state` argument. Learn more about the storage -state [here](https://playwright.dev/docs/auth). +在隔离模式下,每个会话都在隔离配置文件中启动。每当你要求 MCP 关闭浏览器时, +会话就会关闭,该会话的所有存储状态(storage state)也会丢失。你可以通过配置中的 `contextOptions` 或 `--storage-state` 参数向浏览器提供初始存储状态。了解更多关于存储状态的内容,请参见[此处](https://playwright.dev/docs/auth). ```js { @@ -501,21 +505,21 @@ state [here](https://playwright.dev/docs/auth). } ``` -**Browser Extension** +**浏览器扩展** -The Playwright MCP Chrome Extension allows you to connect to existing browser tabs and leverage your logged-in sessions and browser state. See [microsoft/playwright › packages/extension](https://github.com/microsoft/playwright/tree/main/packages/extension#readme) for installation and setup instructions. +Playwright MCP Chrome 扩展允许你连接到现有的浏览器标签页,并利用你已登录的会话和浏览器状态。安装与设置说明请参见 [microsoft/playwright › packages/extension](https://github.com/microsoft/playwright/tree/main/packages/extension#readme) -### Initial state +### 初始状态 -There are multiple ways to provide the initial state to the browser context or a page. +有多种方式可向浏览器上下文(browser context)或页面提供初始状态。 -For the storage state, you can either: -- Start with a user data directory using the `--user-data-dir` argument. This will persist all browser data between the sessions. -- Start with a storage state file using the `--storage-state` argument. This will load cookies and local storage from the file into an isolated browser context. +对于存储状态,你可以: +- 使用 `--user-data-dir` 参数,从用户数据目录(user data directory)启动。这会在会话之间持久保存所有浏览器数据。 +- 使用 `--storage-state` 参数,从存储状态文件启动。这会将文件中的 cookies 和 local storage 加载到隔离的浏览器上下文中。 -For the page state, you can use: +对于页面状态,你可以使用: -- `--init-page` to point to a TypeScript file that will be evaluated on the Playwright page object. This allows you to run arbitrary code to set up the page. +- `--init-page` 可指向一个 TypeScript 文件,该文件会在 Playwright 页面对象上执行。这允许你运行任意代码来设置页面。 ```ts // init-page.ts @@ -526,25 +530,24 @@ export default async ({ page }) => { }; ``` -- `--init-script` to point to a JavaScript file that will be added as an initialization script. The script will be evaluated in every page before any of the page's scripts. -This is useful for overriding browser APIs or setting up the environment. +- `--init-script` 可指向一个 JavaScript 文件,该文件会作为初始化脚本添加。此脚本会在页面任何脚本之前于每个页面上执行。 +这适用于覆盖浏览器 API 或设置环境。 ```js // init-script.js window.isPlaywrightMCP = true; ``` -### Configuration file +### 配置文件 -The Playwright MCP server can be configured using a JSON configuration file. You can specify the configuration file -using the `--config` command line option: +Playwright MCP 服务器可使用 JSON 配置文件进行配置。你可以使用 `--config` 命令行选项指定配置文件: ```bash npx @playwright/mcp@latest --config path/to/config.json ```
-Configuration file schema +配置文件模式(schema) @@ -762,16 +765,16 @@ npx @playwright/mcp@latest --config path/to/config.json
-### Standalone MCP server +### 独立 MCP 服务器 -When running headed browser on system w/o display or from worker processes of the IDEs, -run the MCP server from environment with the DISPLAY and pass the `--port` flag to enable HTTP transport. +在无显示器的系统上运行有界面(headed)浏览器,或从 IDE 的工作进程运行时, +请在配置了 DISPLAY 的环境中运行 MCP 服务器,并传入 `--port` 标志以启用 HTTP 传输。 ```bash npx @playwright/mcp@latest --port 8931 ``` -And then in MCP client config, set the `url` to the HTTP endpoint: +然后在 MCP 客户端配置中,将 `url` 设置为 HTTP 端点: ```js { @@ -783,14 +786,14 @@ And then in MCP client config, set the `url` to the HTTP endpoint: } ``` -## Security +## 安全 -Playwright MCP is **not** a security boundary. See [MCP Security Best Practices](https://modelcontextprotocol.io/docs/tutorials/security/security_best_practices) for guidance on securing your deployment. +Playwright MCP **并非**安全边界。请参阅 [MCP Security Best Practices](https://modelcontextprotocol.io/docs/tutorials/security/security_best_practices)) 了解如何保护你的部署。
Docker -**NOTE:** The Docker implementation only supports headless chromium at the moment. +**注意:** 目前的 Docker 实现仅支持 headless chromium。 ```js { @@ -803,7 +806,7 @@ Playwright MCP is **not** a security boundary. See [MCP Security Best Practices] } ``` -Or If you prefer to run the container as a long-lived service instead of letting the MCP client spawn it, use: +或者,如果你希望将容器作为长期运行的服务,而不是由 MCP 客户端启动,请使用: ``` docker run -d -i --rm --init --pull=always \ @@ -814,9 +817,9 @@ docker run -d -i --rm --init --pull=always \ /app/cli.js --headless --browser chromium --no-sandbox --port 8931 --host 0.0.0.0 ``` -The server will listen on host port **8931** and can be reached by any MCP client. +服务器将在主机端口 **8931** 上监听,任何 MCP 客户端均可访问。 -You can build the Docker image yourself. +你可以自行构建 Docker 镜像。 ``` docker build -t mcr.microsoft.com/playwright/mcp . @@ -824,7 +827,7 @@ docker build -t mcr.microsoft.com/playwright/mcp .
-Programmatic usage +编程式使用 ```js import http from 'http'; @@ -845,745 +848,745 @@ http.createServer(async (req, res) => { ```
-### Tools +### 工具
-Core automation +核心自动化 - **browser_click** - - Title: Click - - Description: Perform click on a web page - - Parameters: - - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element - - `target` (string): Exact target element reference from the page snapshot, or a unique element selector - - `doubleClick` (boolean, optional): Whether to perform a double click instead of a single click - - `button` (string, optional): Button to click, defaults to left - - `modifiers` (array, optional): Modifier keys to press - - Read-only: **false** + - 标题:点击 + - 描述:在网页上执行点击操作 + - 参数: + - `element` (string, optional):用于获取与元素交互权限的人类可读元素描述 + - `target` (string):来自页面快照的精确目标元素引用,或唯一的元素选择器 + - `doubleClick` (boolean, optional):是否执行双击而非单击 + - `button` (string, optional):要点击的按钮,默认为 left + - `modifiers` (array, optional):要按下的修饰键 + - 只读:**false** - **browser_close** - - Title: Close browser - - Description: Close the page - - Parameters: None - - Read-only: **false** + - 标题:关闭浏览器 + - 描述:关闭页面 + - 参数:无 + - 只读:**false** - **browser_console_messages** - - Title: Get console messages - - Description: Returns all console messages - - Parameters: - - `level` (string): Level of the console messages to return. Each level includes the messages of more severe levels. Defaults to "info". - - `all` (boolean, optional): Return all console messages since the beginning of the session, not just since the last navigation. Defaults to false. - - `filename` (string, optional): Filename to save the console messages to. If not provided, messages are returned as text. - - Read-only: **true** + - 标题:获取控制台消息 + - 描述:返回所有控制台消息 + - 参数: + - `level` (string):要返回的控制台消息级别。每个级别包含更严重级别的消息。默认为 "info"。 + - `all` (boolean, optional):返回自会话开始以来的所有控制台消息,而不仅仅是自上次导航以来的消息。默认为 false。 + - `filename` (string, optional):用于保存控制台消息的文件名。如未提供,则以文本形式返回消息。 + - 只读:**true** - **browser_drag** - - Title: Drag mouse - - Description: Perform drag and drop between two elements - - Parameters: - - `startElement` (string, optional): Human-readable source element description used to obtain the permission to interact with the element - - `startTarget` (string): Exact target element reference from the page snapshot, or a unique element selector - - `endElement` (string, optional): Human-readable target element description used to obtain the permission to interact with the element - - `endTarget` (string): Exact target element reference from the page snapshot, or a unique element selector - - Read-only: **false** + - 标题:拖动鼠标 + - 描述:在两个元素之间执行拖放操作 + - 参数: + - `startElement` (string, optional):用于获取与源元素交互权限的人类可读源元素描述 + - `startTarget` (string):来自页面快照的精确目标元素引用,或唯一的元素选择器 + - `endElement` (string, optional):用于获取与目标元素交互权限的人类可读目标元素描述 + - `endTarget` (string):来自页面快照的精确目标元素引用,或唯一的元素选择器 + - 只读:**false** - **browser_drop** - - Title: Drop files or data onto an element - - Description: Drop files or MIME-typed data onto an element, as if dragged from outside the page. At least one of "paths" or "data" must be provided. - - Parameters: - - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element - - `target` (string): Exact target element reference from the page snapshot, or a unique element selector - - `paths` (array, optional): Absolute paths to files to drop onto the element. - - `data` (object, optional): Data to drop, as a map of MIME type to string value (e.g. {"text/plain": "hello", "text/uri-list": "https://example.com"}). - - Read-only: **false** + - 标题:将文件或数据拖放到元素上 + - 描述:将文件或 MIME 类型的数据拖放到元素上,如同从页面外部拖入。必须至少提供 "paths" 或 "data" 之一。 + - 参数: + - `element` (string, optional):用于获取与元素交互权限的人类可读元素描述 + - `target` (string):来自页面快照的精确目标元素引用,或唯一的元素选择器 + - `paths` (array, optional):要拖放到元素上的文件的绝对路径。 + - `data` (object, optional):要拖放的数据,以 MIME 类型到字符串值的映射形式提供(例如 {"text/plain": "hello", "text/uri-list": "https://example.com"})。 + - 只读:**false** - **browser_evaluate** - - Title: Evaluate JavaScript - - Description: Evaluate JavaScript expression on page or element - - Parameters: - - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element - - `target` (string, optional): Exact target element reference from the page snapshot, or a unique element selector - - `function` (string): () => { /* code */ } or (element) => { /* code */ } when element is provided - - `filename` (string, optional): Filename to save the result to. If not provided, result is returned as text. - - Read-only: **false** + - 标题:执行 JavaScript + - 描述:在页面或元素上执行 JavaScript 表达式 + - 参数: + - `element` (string, optional):用于获取与元素交互权限的人类可读元素描述 + - `target` (string, optional):来自页面快照的精确目标元素引用,或唯一的元素选择器 + - `function` (string):() => { /* code */ } 或当提供 element 时为 (element) => { /* code */ } + - `filename` (string, optional):用于保存结果的文件名。如未提供,则以文本形式返回结果。 + - 只读:**false** - **browser_file_upload** - - Title: Upload files - - Description: Upload one or multiple files - - Parameters: - - `paths` (array, optional): The absolute paths to the files to upload. Can be single file or multiple files. If omitted, file chooser is cancelled. - - Read-only: **false** + - 标题:上传文件 + - 描述:上传一个或多个文件 + - 参数: + - `paths` (array, optional):要上传文件的绝对路径。可以是单个文件或多个文件。如省略,则取消文件选择器。 + - 只读:**false** - **browser_fill_form** - - Title: Fill form - - Description: Fill multiple form fields - - Parameters: - - `fields` (array): Fields to fill in - - Read-only: **false** + - 标题:填写表单 + - 描述:填写多个表单字段 + - 参数: + - `fields` (array):要填写的字段 + - 只读:**false** - **browser_find** - - Title: Find in page snapshot - - Description: Search the accessibility snapshot of the current page for text or a regular expression. Returns matching snapshot nodes with a few lines of surrounding context (like search snippets), each shown under its path from the root of the tree, which is cheaper than capturing the whole snapshot when you only need to locate an element and its ref. - - Parameters: - - `text` (string, optional): Plain text to search for in the page snapshot (case-insensitive substring match). Provide either text or regex, not both. - - `regex` (string, optional): Regular expression to search for in the page snapshot. Matching is case-sensitive by default; wrap the pattern in slashes to add flags, e.g. "/error/i" for case-insensitive. Provide either text or regex, not both. - - Read-only: **true** + - 标题:在页面快照中查找 + - 描述:在当前页面的无障碍(accessibility)快照中搜索文本或正则表达式。返回匹配的快照节点及少量周围上下文(类似搜索片段),每个节点均显示其在树中的路径;当你只需定位元素及其 ref 时,这比捕获整个快照更节省开销。 + - 参数: + - `text` (string, optional):要在页面快照中搜索的纯文本(不区分大小写的子串匹配)。请提供 text 或 regex 之一,不要同时提供。 + - `regex` (string, optional):要在页面快照中搜索的正则表达式。默认区分大小写;用斜杠包裹模式以添加标志,例如 "/error/i" 表示不区分大小写。请提供 text 或 regex 之一,不要同时提供。 + - 只读:**true** - **browser_handle_dialog** - - Title: Handle a dialog - - Description: Handle a dialog - - Parameters: - - `accept` (boolean): Whether to accept the dialog. - - `promptText` (string, optional): The text of the prompt in case of a prompt dialog. - - Read-only: **false** + - 标题:处理对话框 + - 描述:处理对话框 + - 参数: + - `accept` (boolean):是否接受该对话框。 + - `promptText` (string, optional):在 prompt 对话框情况下,提示框的文本。 + - 只读:**false** - **browser_hover** - - Title: Hover mouse - - Description: Hover over element on page - - Parameters: - - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element - - `target` (string): Exact target element reference from the page snapshot, or a unique element selector - - Read-only: **false** + - 标题:悬停鼠标 + - 描述:在页面元素上悬停 + - 参数: + - `element` (string, optional):用于获取与元素交互权限的人类可读元素描述 + - `target` (string):来自页面快照的精确目标元素引用,或唯一的元素选择器 + - 只读:**false** - **browser_navigate** - - Title: Navigate to a URL - - Description: Navigate to a URL + - Title: 导航到 URL + - Description: 导航到 URL - Parameters: - - `url` (string): The URL to navigate to + - `url` (string): 要导航到的 URL - Read-only: **false** - **browser_navigate_back** - - Title: Go back - - Description: Go back to the previous page in the history + - Title: 后退 + - Description: 返回历史记录中的上一页 - Parameters: None - Read-only: **false** - **browser_network_request** - - Title: Show network request details - - Description: Returns full details (headers and body) of a single network request, or a single part if `part` is set. Use the number from browser_network_requests. + - Title: 显示网络请求详情 + - Description: 返回单个网络请求的完整详情(headers 和 body),若设置了 `part` 则仅返回其中一部分。请使用 browser_network_requests 输出的编号。 - Parameters: - - `index` (integer): 1-based index of the request, as printed by browser_network_requests. - - `part` (string, optional): Return only this part of the request. Omit to return full details. - - `filename` (string, optional): Filename to save the result to. If not provided, output is returned as text. + - `index` (integer): 请求的 1-based 索引,与 browser_network_requests 输出的编号一致。 + - `part` (string, optional): 仅返回请求的此部分。省略则返回完整详情。 + - `filename` (string, optional): 将结果保存到的文件名。若未提供,则以文本形式返回输出。 - Read-only: **true** - **browser_network_requests** - - Title: List network requests - - Description: Returns a numbered list of network requests since loading the page. Use browser_network_request with the number to get full details. + - Title: 列出网络请求 + - Description: 返回自页面加载以来的网络请求编号列表。使用 browser_network_request 并传入编号可获取完整详情。 - Parameters: - - `static` (boolean): Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false. - - `filter` (string, optional): Only return requests whose URL matches this regexp (e.g. "/api/.*user"). - - `filename` (string, optional): Filename to save the network requests to. If not provided, requests are returned as text. + - `static` (boolean): 是否包含成功的静态资源(如图片、字体、脚本等)。默认为 false。 + - `filter` (string, optional): 仅返回 URL 匹配此正则表达式的请求(例如 "/api/.*user")。 + - `filename` (string, optional): 将网络请求保存到的文件名。若未提供,则以文本形式返回请求。 - Read-only: **true** - **browser_press_key** - - Title: Press a key - - Description: Press a key on the keyboard + - Title: 按键 + - Description: 在键盘上按下一个键 - Parameters: - - `key` (string): Name of the key to press or a character to generate, such as `ArrowLeft` or `a` + - `key` (string): 要按下的键名或要生成的字符,例如 `ArrowLeft` 或 `a` - Read-only: **false** - **browser_resize** - - Title: Resize browser window - - Description: Resize the browser window + - Title: 调整浏览器窗口大小 + - Description: 调整浏览器窗口大小 - Parameters: - - `width` (number): Width of the browser window - - `height` (number): Height of the browser window + - `width` (number): 浏览器窗口宽度 + - `height` (number): 浏览器窗口高度 - Read-only: **false** - **browser_run_code_unsafe** - - Title: Run Playwright code (unsafe) - - Description: Run a Playwright code snippet. Unsafe: executes arbitrary JavaScript in the Playwright server process and is RCE-equivalent. + - Title: 运行 Playwright 代码(不安全) + - Description: 运行一段 Playwright 代码片段。不安全:在 Playwright 服务器进程中执行任意 JavaScript,等效于远程代码执行(RCE)。 - Parameters: - - `code` (string, optional): A JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction. For example: `async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }` - - `filename` (string, optional): Load code from the specified file. If both code and filename are provided, code will be ignored. + - `code` (string, optional): 包含待执行 Playwright 代码的 JavaScript 函数。将以单个参数 page 调用,可用于任意页面交互。例如:`async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }` + - `filename` (string, optional): 从指定文件加载代码。若同时提供 code 和 filename,将忽略 code。 - Read-only: **false** - **browser_select_option** - - Title: Select option - - Description: Select an option in a dropdown + - Title: 选择选项 + - Description: 在下拉框中选择选项 - Parameters: - - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element - - `target` (string): Exact target element reference from the page snapshot, or a unique element selector - - `values` (array): Array of values to select in the dropdown. This can be a single value or multiple values. + - `element` (string, optional): 用于获取与元素交互权限的人类可读元素描述 + - `target` (string): 来自页面快照的精确目标元素引用,或唯一元素选择器 + - `values` (array): 要在下拉框中选择的值数组。可以是单个值或多个值。 - Read-only: **false** - **browser_snapshot** - - Title: Page snapshot - - Description: Capture accessibility snapshot of the current page, this is better than screenshot + - Title: 页面快照 + - Description: 捕获当前页面的无障碍(accessibility)快照,优于截图 - Parameters: - - `target` (string, optional): Exact target element reference from the page snapshot, or a unique element selector - - `filename` (string, optional): Save snapshot to markdown file instead of returning it in the response. - - `depth` (number, optional): Limit the depth of the snapshot tree - - `boxes` (boolean, optional): Include each element's bounding box as [box=x,y,width,height] in the snapshot. Coordinates are viewport-relative, in CSS pixels (Element.getBoundingClientRect) + - `target` (string, optional): 来自页面快照的精确目标元素引用,或唯一元素选择器 + - `filename` (string, optional): 将快照保存为 Markdown 文件,而非在响应中返回。 + - `depth` (number, optional): 限制快照树的深度 + - `boxes` (boolean, optional): 在快照中包含每个元素的边界框,格式为 [box=x,y,width,height]。坐标相对于视口,单位为 CSS 像素(Element.getBoundingClientRect) - Read-only: **true** - **browser_take_screenshot** - - Title: Take a screenshot - - Description: Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions. + - Title: 截图 + - Description: 对当前页面截图。无法基于截图执行操作,请使用 browser_snapshot 进行操作。 - Parameters: - - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element - - `target` (string, optional): Exact target element reference from the page snapshot, or a unique element selector - - `type` (string): Image format for the screenshot. Default is png. - - `filename` (string, optional): File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified. Prefer relative file names to stay within the output directory. - - `fullPage` (boolean, optional): When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Cannot be used with element screenshots. - - `scale` (string): Image resolution scale. "css" produces a screenshot sized in CSS pixels (smaller, consistent across devices). "device" produces a high-resolution screenshot using device pixels (larger, accounts for the device pixel ratio). Default is css. + - `element` (string, optional): 用于获取与元素交互权限的人类可读元素描述 + - `target` (string, optional): 来自页面快照的精确目标元素引用,或唯一元素选择器 + - `type` (string): 截图的图像格式。默认为 png。 + - `filename` (string, optional): 保存截图的文件名。若未指定,默认为 `page-{timestamp}.{png|jpeg}`。建议使用相对文件名以保持在输出目录内。 + - `fullPage` (boolean, optional): 为 true 时,截取完整可滚动页面的截图,而非当前可见视口。不能与元素截图同时使用。 + - `scale` (string): 图像分辨率缩放。"css" 生成以 CSS 像素计尺寸的截图(较小,跨设备一致)。"device" 使用设备像素生成高分辨率截图(较大,考虑设备像素比)。默认为 css。 - Read-only: **true** - **browser_type** - - Title: Type text - - Description: Type text into editable element + - Title: 输入文本 + - Description: 在可编辑元素中输入文本 - Parameters: - - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element - - `target` (string): Exact target element reference from the page snapshot, or a unique element selector - - `text` (string): Text to type into the element - - `submit` (boolean, optional): Whether to submit entered text (press Enter after) - - `slowly` (boolean, optional): Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once. + - `element` (string, optional): 用于获取与元素交互权限的人类可读元素描述 + - `target` (string): 来自页面快照的精确目标元素引用,或唯一元素选择器 + - `text` (string): 要输入到元素中的文本 + - `submit` (boolean, optional): 是否提交已输入的文本(之后按 Enter) + - `slowly` (boolean, optional): 是否逐字符输入。适用于触发页面中的按键处理程序。默认情况下会一次性填入全部文本。 - Read-only: **false** - **browser_wait_for** - - Title: Wait for - - Description: Wait for text to appear or disappear or a specified time to pass + - Title: 等待 + - Description: 等待文本出现或消失,或等待指定时间过去 - Parameters: - - `time` (number, optional): The time to wait in seconds - - `text` (string, optional): The text to wait for - - `textGone` (string, optional): The text to wait for to disappear + - `time` (number, optional): 等待时间(秒) + - `text` (string, optional): 要等待出现的文本 + - `textGone` (string, optional): 要等待消失的文本 - Read-only: **false**
-Tab management +标签页管理 - **browser_tabs** - - Title: Manage tabs - - Description: List, create, close, or select a browser tab. + - Title: 管理标签页 + - Description: 列出、创建、关闭或选择浏览器标签页。 - Parameters: - - `action` (string): Operation to perform - - `index` (number, optional): Tab index, used for close/select. If omitted for close, current tab is closed. - - `url` (string, optional): URL to navigate to in the new tab, used for new. + - `action` (string): 要执行的操作 + - `index` (number, optional): 标签页索引,用于 close/select。close 时若省略,则关闭当前标签页。 + - `url` (string, optional): 在新标签页中导航到的 URL,用于 new。 - Read-only: **false**
-Browser installation +浏览器安装
-Configuration (opt-in via --caps=config) +配置(通过 --caps=config 可选启用) - **browser_get_config** - - Title: Get config - - Description: Get the final resolved config after merging CLI options, environment variables and config file. + - Title: 获取配置 + - Description: 获取合并 CLI 选项、环境变量和配置文件后的最终解析配置。 - Parameters: None - Read-only: **true**
-Network (opt-in via --caps=network) +网络(通过 --caps=network 可选启用) - **browser_network_state_set** - - Title: Set network state - - Description: Sets the browser network state to online or offline. When offline, all network requests will fail. + - Title: 设置网络状态 + - Description: 将浏览器网络状态设置为 online 或 offline。offline 时,所有网络请求都会失败。 - Parameters: - - `state` (string): Set to "offline" to simulate offline mode, "online" to restore network connectivity + - `state` (string): 设为 "offline" 以模拟离线模式,设为 "online" 以恢复网络连接 - Read-only: **false** - **browser_route** - - Title: Mock network requests - - Description: Set up a route to mock network requests matching a URL pattern + - Title: 模拟网络请求 + - Description: 设置路由以模拟匹配 URL 模式的网络请求 - Parameters: - - `pattern` (string): URL pattern to match (e.g., "**/api/users", "**/*.{png,jpg}") - - `status` (number, optional): HTTP status code to return (default: 200) - - `body` (string, optional): Response body (text or JSON string) - - `contentType` (string, optional): Content-Type header (e.g., "application/json", "text/html") - - `headers` (array, optional): Headers to add in "Name: Value" format - - `removeHeaders` (string, optional): Comma-separated list of header names to remove from request + - `pattern` (string): 要匹配的 URL 模式(例如 "**/api/users"、"**/*.{png,jpg}") + - `status` (number, optional): 要返回的 HTTP 状态码(默认:200) + - `body` (string, optional): 响应体(文本或 JSON 字符串) + - `contentType` (string, optional): Content-Type 标头(例如 "application/json"、"text/html") + - `headers` (array, optional): 以 "Name: Value" 格式添加的标头 + - `removeHeaders` (string, optional): 要从请求中移除的标头名称列表,以逗号分隔 - Read-only: **false** - **browser_route_list** - - Title: List network routes - - Description: List all active network routes + - Title: 列出网络路由 + - Description: 列出所有活动的网络路由 - Parameters: None - Read-only: **true** - **browser_unroute** - - Title: Remove network routes - - Description: Remove network routes matching a pattern (or all routes if no pattern specified) + - Title: 移除网络路由 + - Description: 移除匹配指定模式的网络路由(若未指定模式则移除所有路由) - Parameters: - - `pattern` (string, optional): URL pattern to unroute (omit to remove all routes) + - `pattern` (string, optional): 要取消路由的 URL 模式(省略则移除所有路由) - Read-only: **false**
-Storage (opt-in via --caps=storage) +Storage(通过 --caps=storage 可选启用) - **browser_cookie_clear** - - Title: Clear cookies - - Description: Clear all cookies + - Title: 清除 Cookie + - Description: 清除所有 Cookie - Parameters: None - Read-only: **false** - **browser_cookie_delete** - - Title: Delete cookie - - Description: Delete a specific cookie + - Title: 删除 Cookie + - Description: 删除指定的 Cookie - Parameters: - - `name` (string): Cookie name to delete + - `name` (string): 要删除的 Cookie 名称 - Read-only: **false** - **browser_cookie_get** - - Title: Get cookie - - Description: Get a specific cookie by name + - Title: 获取 Cookie + - Description: 按名称获取指定的 Cookie - Parameters: - - `name` (string): Cookie name to get + - `name` (string): 要获取的 Cookie 名称 - Read-only: **true** - **browser_cookie_list** - - Title: List cookies - - Description: List all cookies (optionally filtered by domain/path) + - Title: 列出 Cookie + - Description: 列出所有 Cookie(可按域名/路径可选过滤) - Parameters: - - `domain` (string, optional): Filter cookies by domain - - `path` (string, optional): Filter cookies by path + - `domain` (string, optional): 按域名过滤 Cookie + - `path` (string, optional): 按路径过滤 Cookie - Read-only: **true** - **browser_cookie_set** - - Title: Set cookie - - Description: Set a cookie with optional flags (domain, path, expires, httpOnly, secure, sameSite) + - Title: 设置 Cookie + - Description: 设置 Cookie,并可选配置标志(domain、path、expires、httpOnly、secure、sameSite) - Parameters: - - `name` (string): Cookie name - - `value` (string): Cookie value - - `domain` (string, optional): Cookie domain - - `path` (string, optional): Cookie path - - `expires` (number, optional): Cookie expiration as Unix timestamp - - `httpOnly` (boolean, optional): Whether the cookie is HTTP only - - `secure` (boolean, optional): Whether the cookie is secure - - `sameSite` (string, optional): Cookie SameSite attribute + - `name` (string): Cookie 名称 + - `value` (string): Cookie 值 + - `domain` (string, optional): Cookie 域名 + - `path` (string, optional): Cookie 路径 + - `expires` (number, optional): Cookie 过期时间(Unix 时间戳) + - `httpOnly` (boolean, optional): Cookie 是否为 HTTP only + - `secure` (boolean, optional): Cookie 是否为 secure + - `sameSite` (string, optional): Cookie SameSite 属性 - Read-only: **false** - **browser_localstorage_clear** - - Title: Clear localStorage - - Description: Clear all localStorage + - Title: 清除 localStorage + - Description: 清除所有 localStorage - Parameters: None - Read-only: **false** - **browser_localstorage_delete** - - Title: Delete localStorage item - - Description: Delete a localStorage item + - Title: 删除 localStorage 项 + - Description: 删除 localStorage 项 - Parameters: - - `key` (string): Key to delete + - `key` (string): 要删除的键 - Read-only: **false** - **browser_localstorage_get** - - Title: Get localStorage item - - Description: Get a localStorage item by key + - Title: 获取 localStorage 项 + - Description: 按键获取 localStorage 项 - Parameters: - - `key` (string): Key to get + - `key` (string): 要获取的键 - Read-only: **true** - **browser_localstorage_list** - - Title: List localStorage - - Description: List all localStorage key-value pairs + - Title: 列出 localStorage + - Description: 列出所有 localStorage 键值对 - Parameters: None - Read-only: **true** - **browser_localstorage_set** - - Title: Set localStorage item - - Description: Set a localStorage item + - Title: 设置 localStorage 项 + - Description: 设置 localStorage 项 - Parameters: - - `key` (string): Key to set - - `value` (string): Value to set + - `key` (string): 要设置的键 + - `value` (string): 要设置的值 - Read-only: **false** - **browser_sessionstorage_clear** - - Title: Clear sessionStorage - - Description: Clear all sessionStorage + - Title: 清除 sessionStorage + - Description: 清除所有 sessionStorage - Parameters: None - Read-only: **false** - **browser_sessionstorage_delete** - - Title: Delete sessionStorage item - - Description: Delete a sessionStorage item + - Title: 删除 sessionStorage 项 + - Description: 删除 sessionStorage 项 - Parameters: - - `key` (string): Key to delete + - `key` (string): 要删除的键 - Read-only: **false** - **browser_sessionstorage_get** - - Title: Get sessionStorage item - - Description: Get a sessionStorage item by key + - Title: 获取 sessionStorage 项 + - Description: 按键获取 sessionStorage 项 - Parameters: - - `key` (string): Key to get + - `key` (string): 要获取的键 - Read-only: **true** - **browser_sessionstorage_list** - - Title: List sessionStorage - - Description: List all sessionStorage key-value pairs + - Title: 列出 sessionStorage + - Description: 列出所有 sessionStorage 键值对 - Parameters: None - Read-only: **true** - **browser_sessionstorage_set** - - Title: Set sessionStorage item - - Description: Set a sessionStorage item + - Title: 设置 sessionStorage 项 + - Description: 设置 sessionStorage 项 - Parameters: - - `key` (string): Key to set - - `value` (string): Value to set + - `key` (string): 要设置的键 + - `value` (string): 要设置的值 - Read-only: **false** - **browser_set_storage_state** - - Title: Restore storage state - - Description: Restore storage state (cookies, local storage) from a file. This clears existing cookies and local storage before restoring. + - Title: 恢复存储状态 + - Description: 从文件恢复存储状态(Cookie、local storage)。恢复前会清除现有的 Cookie 和 local storage。 - Parameters: - - `filename` (string): Path to the storage state file to restore from + - `filename` (string): 要从中恢复的存储状态文件路径 - Read-only: **false** - **browser_storage_state** - - Title: Save storage state - - Description: Save storage state (cookies, local storage) to a file for later reuse + - Title: 保存存储状态 + - Description: 将存储状态(Cookie、local storage)保存到文件,供后续复用 - Parameters: - - `filename` (string, optional): File name to save the storage state to. Defaults to `storage-state-{timestamp}.json` if not specified. + - `filename` (string, optional): 保存存储状态的文件名。若未指定,则默认为 `storage-state-{timestamp}.json`。 - Read-only: **true**
-DevTools (opt-in via --caps=devtools) +DevTools(通过 --caps=devtools 可选启用) - **browser_annotate** - - Title: Annotate the current page - - Description: Open the Playwright Dashboard in annotation mode for the current page and wait for the user to draw annotations. Returns the annotated screenshot, ARIA snapshot, and the list of annotations. + - Title: 标注当前页面 + - Description: 以标注模式为当前页面打开 Playwright Dashboard,并等待用户绘制标注。返回带标注的截图、ARIA 快照以及标注列表。 - Parameters: None - Read-only: **true** - **browser_hide_highlight** - - Title: Hide element highlight - - Description: Remove a highlight overlay previously added for the element. + - Title: 隐藏元素高亮 + - Description: 移除先前为该元素添加的高亮叠加层。 - Parameters: - - `element` (string, optional): Human-readable element description used when adding the highlight; must match the value passed to browser_highlight. - - `target` (string, optional): Exact target element reference from the page snapshot, or a unique element selector + - `element` (string, optional): 添加高亮时使用的人类可读元素描述;必须与传递给 browser_highlight 的值一致。 + - `target` (string, optional): 页面快照中的精确目标元素引用,或唯一的元素选择器 - Read-only: **true** - **browser_highlight** - - Title: Highlight element - - Description: Show a persistent highlight overlay around the element on the page. + - Title: 高亮元素 + - Description: 在页面上显示围绕该元素的持久高亮叠加层。 - Parameters: - - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element - - `target` (string): Exact target element reference from the page snapshot, or a unique element selector - - `style` (string, optional): Additional inline CSS applied to the highlight overlay, e.g. "outline: 2px dashed red". + - `element` (string, optional): 用于获取与元素交互权限的人类可读元素描述 + - `target` (string): 页面快照中的精确目标元素引用,或唯一的元素选择器 + - `style` (string, optional): 应用于高亮叠加层的额外内联 CSS,例如 "outline: 2px dashed red"。 - Read-only: **true** - **browser_resume** - - Title: Resume paused script execution - - Description: Resume script execution after it was paused. When called with step set to true, execution will pause again before the next action. + - Title: 恢复已暂停的脚本执行 + - Description: 在脚本暂停后恢复执行。当 step 设为 true 时,执行会在下一个操作前再次暂停。 - Parameters: - - `step` (boolean, optional): When true, execution will pause again before the next action, allowing step-by-step debugging. - - `location` (string, optional): Pause execution at a specific :, e.g. "example.spec.ts:42". + - `step` (boolean, optional): 为 true 时,执行会在下一个操作前再次暂停,以便逐步调试。 + - `location` (string, optional): 在指定的 : 处暂停执行,例如 "example.spec.ts:42"。 - Read-only: **false** - **browser_start_tracing** - - Title: Start tracing - - Description: Start trace recording - - Parameters: None + - Title: 开始追踪 + - Description: 开始记录追踪 + - Parameters: 无 - Read-only: **true** - **browser_start_video** - - Title: Start video - - Description: Start video recording + - Title: 开始录制视频 + - Description: 开始录制视频 - Parameters: - - `filename` (string, optional): Filename to save the video. - - `size` (object, optional): Video size + - `filename` (string, optional): 用于保存视频的文件名。 + - `size` (object, optional): 视频尺寸 - Read-only: **true** - **browser_stop_tracing** - - Title: Stop tracing - - Description: Stop trace recording - - Parameters: None + - Title: 停止追踪 + - Description: 停止记录追踪 + - Parameters: 无 - Read-only: **true** - **browser_stop_video** - - Title: Stop video - - Description: Stop video recording - - Parameters: None + - Title: 停止录制视频 + - Description: 停止录制视频 + - Parameters: 无 - Read-only: **true** - **browser_video_chapter** - - Title: Video chapter - - Description: Add a chapter marker to the video recording. Shows a full-screen chapter card with blurred backdrop. + - Title: 视频章节 + - Description: 为视频录制添加章节标记。会显示带模糊背景的满屏章节卡片。 - Parameters: - - `title` (string): Chapter title - - `description` (string, optional): Chapter description - - `duration` (number, optional): Duration in milliseconds to show the chapter card + - `title` (string): 章节标题 + - `description` (string, optional): 章节描述 + - `duration` (number, optional): 章节卡片显示时长(毫秒) - Read-only: **true** - **browser_video_hide_actions** - - Title: Hide action overlays - - Description: Stop annotating actions performed on the page. - - Parameters: None + - Title: 隐藏操作叠加层 + - Description: 停止标注页面上执行的操作。 + - Parameters: 无 - Read-only: **true** - **browser_video_show_actions** - - Title: Show action overlays - - Description: Annotate subsequent actions performed on the page with a callout that names the action and highlights the target element. Useful while video recording or screencasting. + - Title: 显示操作叠加层 + - Description: 为页面上后续执行的操作添加标注:通过标注框显示操作名称并高亮目标元素。适用于视频录制或屏幕录制(screencasting)时。 - Parameters: - - `duration` (number, optional): How long each action annotation stays on screen, in milliseconds. Defaults to 500. - - `position` (string, optional): Where to place the action title relative to the page. Defaults to top-right. - - `cursor` (string, optional): Cursor decoration for pointer actions. "pointer" (default) animates a mouse pointer from the previous action point to the next one; "none" disables the cursor decoration. + - `duration` (number, optional): 每个操作标注在屏幕上停留的时长(毫秒)。默认为 500。 + - `position` (string, optional): 操作标题相对于页面的显示位置。默认为 top-right。 + - `cursor` (string, optional): 指针操作的鼠标光标装饰。"pointer"(默认)会将鼠标指针从上一个操作点动画移动到下一个操作点;"none" 会禁用光标装饰。 - Read-only: **true**
-Coordinate-based (opt-in via --caps=vision) +基于坐标(通过 --caps=vision 可选启用) - **browser_mouse_click_xy** - - Title: Click - - Description: Click mouse button at a given position + - Title: 点击 + - Description: 在指定位置点击鼠标按钮 - Parameters: - - `x` (number): X coordinate - - `y` (number): Y coordinate - - `button` (string, optional): Button to click, defaults to left - - `clickCount` (number, optional): Number of clicks, defaults to 1 - - `delay` (number, optional): Time to wait between mouse down and mouse up in milliseconds, defaults to 0 + - `x` (number): X 坐标 + - `y` (number): Y 坐标 + - `button` (string, optional): 要点击的按钮,默认为 left + - `clickCount` (number, optional): 点击次数,默认为 1 + - `delay` (number, optional): 鼠标按下与松开之间的等待时间(毫秒),默认为 0 - Read-only: **false** - **browser_mouse_down** - - Title: Press mouse down - - Description: Press mouse down + - Title: 按下鼠标 + - Description: 按下鼠标 - Parameters: - - `button` (string, optional): Button to press, defaults to left + - `button` (string, optional): 要按下的按钮,默认为 left - Read-only: **false** - **browser_mouse_drag_xy** - - Title: Drag mouse - - Description: Drag left mouse button to a given position + - Title: 拖动鼠标 + - Description: 将鼠标左键拖动到指定位置 - Parameters: - - `startX` (number): Start X coordinate - - `startY` (number): Start Y coordinate - - `endX` (number): End X coordinate - - `endY` (number): End Y coordinate + - `startX` (number): 起始 X 坐标 + - `startY` (number): 起始 Y 坐标 + - `endX` (number): 结束 X 坐标 + - `endY` (number): 结束 Y 坐标 - Read-only: **false** - **browser_mouse_move_xy** - - Title: Move mouse - - Description: Move mouse to a given position + - Title: 移动鼠标 + - Description: 将鼠标移动到指定位置 - Parameters: - - `x` (number): X coordinate - - `y` (number): Y coordinate + - `x` (number): X 坐标 + - `y` (number): Y 坐标 - Read-only: **false** - **browser_mouse_up** - - Title: Press mouse up - - Description: Press mouse up + - Title: 松开鼠标 + - Description: 松开鼠标 - Parameters: - - `button` (string, optional): Button to press, defaults to left + - `button` (string, optional): 要松开的按钮,默认为 left - Read-only: **false** - **browser_mouse_wheel** - - Title: Scroll mouse wheel - - Description: Scroll mouse wheel + - Title: 滚动鼠标滚轮 + - Description: 滚动鼠标滚轮 - Parameters: - - `deltaX` (number): X delta - - `deltaY` (number): Y delta + - `deltaX` (number): X 增量 + - `deltaY` (number): Y 增量 - Read-only: **false**
-PDF generation (opt-in via --caps=pdf) +PDF 生成(通过 --caps=pdf 可选启用) - **browser_pdf_save** - - Title: Save as PDF - - Description: Save page as PDF + - Title: 另存为 PDF + - Description: 将页面另存为 PDF - Parameters: - - `filename` (string, optional): File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified. Prefer relative file names to stay within the output directory. + - `filename` (string, optional): 用于保存 PDF 的文件名。若未指定,则默认为 `page-{timestamp}.pdf`。建议使用相对文件名,以保留在输出目录内。 - Read-only: **true**
-Test assertions (opt-in via --caps=testing) +测试断言(通过 --caps=testing 可选启用) - **browser_generate_locator** - - Title: Create locator for element - - Description: Generate locator for the given element to use in tests + - Title: 为元素创建定位器(locator) + - Description: 为给定元素生成定位器,供测试使用 - Parameters: - - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element - - `target` (string): Exact target element reference from the page snapshot, or a unique element selector + - `element` (string, optional): 用于获取与元素交互权限的人类可读元素描述 + - `target` (string): 来自页面快照的精确目标元素引用,或唯一元素选择器 - Read-only: **true** - **browser_verify_element_visible** - - Title: Verify element visible - - Description: Verify element is visible on the page + - Title: 验证元素可见 + - Description: 验证元素在页面上可见 - Parameters: - - `role` (string): ROLE of the element. Can be found in the snapshot like this: `- {ROLE} "Accessible Name":` - - `accessibleName` (string): ACCESSIBLE_NAME of the element. Can be found in the snapshot like this: `- role "{ACCESSIBLE_NAME}"` + - `role` (string): 元素的 ROLE。可在快照中这样找到:`- {ROLE} "Accessible Name":` + - `accessibleName` (string): 元素的 ACCESSIBLE_NAME。可在快照中这样找到:`- role "{ACCESSIBLE_NAME}"` - Read-only: **false** - **browser_verify_list_visible** - - Title: Verify list visible - - Description: Verify list is visible on the page + - Title: 验证列表可见 + - Description: 验证列表在页面上可见 - Parameters: - - `element` (string): Human-readable list description - - `target` (string): Exact target element reference that points to the list - - `items` (array): Items to verify + - `element` (string): 人类可读的列表描述 + - `target` (string): 指向该列表的精确目标元素引用 + - `items` (array): 要验证的条目 - Read-only: **false** - **browser_verify_text_visible** - - Title: Verify text visible - - Description: Verify text is visible on the page. Prefer browser_verify_element_visible if possible. + - Title: 验证文本可见 + - Description: 验证文本在页面上可见。如有可能,请优先使用 browser_verify_element_visible。 - Parameters: - - `text` (string): TEXT to verify. Can be found in the snapshot like this: `- role "Accessible Name": {TEXT}` or like this: `- text: {TEXT}` + - `text` (string): 要验证的 TEXT。可在快照中这样找到:`- role "Accessible Name": {TEXT}`,或这样:`- text: {TEXT}` - Read-only: **false** - **browser_verify_value** - - Title: Verify value - - Description: Verify element value + - Title: 验证值 + - Description: 验证元素值 - Parameters: - - `type` (string): Type of the element - - `element` (string): Human-readable element description - - `target` (string): Exact target element reference from the page snapshot - - `value` (string): Value to verify. For checkbox, use "true" or "false". + - `type` (string): 元素类型 + - `element` (string): 人类可读的元素描述 + - `target` (string): 来自页面快照的精确目标元素引用 + - `value` (string): 要验证的值。对于复选框(checkbox),请使用 "true" 或 "false"。 - Read-only: **false**