playwright-browser

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Playwright Browser Skill - 浏览器自动化技能

Playwright Browser Skill - Browser Automation Skill

⚡ AI 调用指南(OpenClaw 必读)

⚡ AI Invocation Guide (Required Reading for OpenClaw)

如何调用 MCP 工具

How to Invoke MCP Tools

当用户请求浏览器操作时,你需要通过 MCP 协议调用相应的工具。以下是调用方法:
When a user requests browser operations, you need to invoke the corresponding tools via the MCP protocol. The invocation method is as follows:

基本调用流程

Basic Invocation Process

  1. 启动浏览器 → 调用
    browser_launch
  2. 访问网页 → 调用
    browser_goto
  3. 执行操作 → 调用相应工具(点击、填写、提取等)
  4. 关闭浏览器 → 调用
    browser_close
  1. Launch Browser → Call
    browser_launch
  2. Access Web Page → Call
    browser_goto
  3. Perform Operations → Call corresponding tools (click, fill, extract, etc.)
  4. Close Browser → Call
    browser_close

常用工具快速参考

Common Tools Quick Reference

用户需求调用工具参数示例
"访问网站"
browser_goto
{ "url": "https://example.com" }
"点击按钮"
browser_click
{ "selector": "button.submit" }
"填写表单"
browser_fill
{ "selector": "#username", "value": "admin" }
"获取标题"
browser_get_title
{}
"截图"
browser_screenshot
{ "path": "screenshot.png", "fullPage": true }
"获取文本"
browser_get_text
{ "selector": "h1" }
"等待元素"
browser_wait_for_selector
{ "selector": ".content" }
User RequirementTool to InvokeParameter Example
"Access a website"
browser_goto
{ "url": "https://example.com" }
"Click a button"
browser_click
{ "selector": "button.submit" }
"Fill out a form"
browser_fill
{ "selector": "#username", "value": "admin" }
"Get page title"
browser_get_title
{}
"Take a screenshot"
browser_screenshot
{ "path": "screenshot.png", "fullPage": true }
"Get text content"
browser_get_text
{ "selector": "h1" }
"Wait for an element"
browser_wait_for_selector
{ "selector": ".content" }

完整示例:访问网页并获取标题

Complete Example: Access a web page and get its title

用户:"访问 example.com 并获取页面标题"

你应该调用:
1. browser_launch({ "headless": false })
2. browser_goto({ "url": "https://example.com" })
3. browser_get_title({})
4. browser_close({})
User: "Access example.com and get the page title"

You should call:
1. browser_launch({ "headless": false })
2. browser_goto({ "url": "https://example.com" })
3. browser_get_title({})
4. browser_close({})

完整示例:搜索操作

Complete Example: Search operation

用户:"在百度搜索 OpenClaw"

你应该调用:
1. browser_launch({})
2. browser_goto({ "url": "https://www.baidu.com" })
3. browser_fill({ "selector": "#kw", "value": "OpenClaw" })
4. browser_click({ "selector": "#su" })
5. browser_wait_for_selector({ "selector": ".result" })
6. browser_close({})
User: "Search for OpenClaw on Baidu"

You should call:
1. browser_launch({})
2. browser_goto({ "url": "https://www.baidu.com" })
3. browser_fill({ "selector": "#kw", "value": "OpenClaw" })
4. browser_click({ "selector": "#su" })
5. browser_wait_for_selector({ "selector": ".result" })
6. browser_close({})

重要提示

Important Notes

  • 必须先调用 browser_launch - 任何操作前都要先启动浏览器
  • 使用完毕调用 browser_close - 释放资源
  • 等待元素加载 - 使用 browser_wait_for_selector 确保元素存在
  • 选择器语法 - 使用 CSS 选择器(#id, .class, button[type="submit"])

  • Must call browser_launch first - Always launch the browser before any operations
  • Call browser_close after use - Release resources
  • Wait for elements to load - Use browser_wait_for_selector to ensure elements exist
  • Selector syntax - Use CSS selectors (#id, .class, button[type="submit"])

🚀 用户使用指南

🚀 User Guide

这是一个强大的浏览器自动化技能,可以帮助你控制浏览器、访问网页、提取内容、截图等。通过 MCP 协议提供 101 个完整的浏览器操作工具。
This is a powerful browser automation skill that can help you control browsers, access web pages, extract content, take screenshots, etc. It provides 101 complete browser operation tools via the MCP protocol.

如何使用这个技能

How to use this skill

基本用法: 当你需要访问网页、提取信息或控制浏览器时,直接告诉我你的需求即可。我会自动选择合适的工具来完成任务。
示例对话:
  • "帮我访问 example.com 并获取页面标题"
  • "打开百度搜索 'OpenClaw'"
  • "访问 github.com 并截图"
  • "帮我从这个网页提取所有链接"
  • "启动浏览器并访问 https://www.google.com"
Basic usage: When you need to access web pages, extract information or control the browser, just tell me your requirements directly. I will automatically select the appropriate tools to complete the task.
Sample conversations:
  • "Help me access example.com and get the page title"
  • "Open Baidu and search for 'OpenClaw'"
  • "Access github.com and take a screenshot"
  • "Help me extract all links from this web page"
  • "Launch the browser and access https://www.google.com"

主要功能

Main Functions

  1. 网页访问 - 访问任何网站,获取页面内容
  2. 内容提取 - 提取文本、链接、图片等信息
  3. 页面交互 - 点击按钮、填写表单、滚动页面
  4. 截图保存 - 对整个页面或特定元素截图
  5. 数据抓取 - 批量提取网页数据
  6. 自动化测试 - 模拟用户操作,测试网站功能
  1. Web page access - Access any website and get page content
  2. Content extraction - Extract text, links, images and other information
  3. Page interaction - Click buttons, fill forms, scroll pages
  4. Screenshot saving - Take screenshots of the entire page or specific elements
  5. Data scraping - Batch extract web page data
  6. Automated testing - Simulate user operations to test website functions

常见使用场景

Common Usage Scenarios

场景 1:快速查看网页
你:帮我看看 example.com 上有什么内容
我:会自动启动浏览器,访问网页,提取并总结内容
场景 2:提取信息
你:从 news.ycombinator.com 提取今天的热门文章标题
我:会访问网页,提取所有文章标题并整理给你
场景 3:网页截图
你:帮我截取 github.com 首页的截图
我:会访问网页并保存截图
场景 4:表单填写
你:帮我在这个网站的搜索框输入 "OpenClaw" 并搜索
我:会找到搜索框,输入内容,点击搜索按钮
Scenario 1: Quick web page viewing
You: Help me see what content is on example.com
Me: Will automatically launch the browser, access the web page, extract and summarize the content
Scenario 2: Information extraction
You: Extract today's popular article titles from news.ycombinator.com
Me: Will access the web page, extract all article titles and organize them for you
Scenario 3: Web page screenshot
You: Help me take a screenshot of the github.com homepage
Me: Will access the web page and save the screenshot
Scenario 4: Form filling
You: Help me enter "OpenClaw" in the search box of this website and search
Me: Will find the search box, enter the content, click the search button

💡 使用提示

💡 Usage Tips

  • 无需指定工具名称 - 直接说你的需求,我会自动选择合适的工具
  • 支持中英文 - 可以用中文或英文描述你的需求
  • 支持复杂任务 - 可以组合多个操作完成复杂任务
  • 自动处理错误 - 如果遇到问题,我会自动重试或调整策略

  • No need to specify tool names - Just state your requirements, I will automatically select the appropriate tools
  • Supports Chinese and English - You can describe your requirements in Chinese or English
  • Supports complex tasks - Multiple operations can be combined to complete complex tasks
  • Automatic error handling - If problems are encountered, I will automatically retry or adjust the strategy

🔧 工具调用指南(给 OpenClaw 看的)

🔧 Tool Invocation Guide (For OpenClaw)

基本调用流程

Basic Invocation Process

步骤 1:启动浏览器
json
工具名称: browser_launch
参数: {
  "browserType": "chromium",
  "headless": false
}
步骤 2:访问网页
json
工具名称: browser_goto
参数: {
  "url": "https://example.com",
  "waitUntil": "networkidle"
}
步骤 3:提取内容
json
工具名称: browser_get_title
参数: {}
步骤 4:关闭浏览器
json
工具名称: browser_close
参数: {}
Step 1: Launch the browser
json
Tool name: browser_launch
Parameters: {
  "browserType": "chromium",
  "headless": false
}
Step 2: Access the web page
json
Tool name: browser_goto
Parameters: {
  "url": "https://example.com",
  "waitUntil": "networkidle"
}
Step 3: Extract content
json
Tool name: browser_get_title
Parameters: {}
Step 4: Close the browser
json
Tool name: browser_close
Parameters: {}

常用工具快速参考

Common Tools Quick Reference

1. 启动浏览器

1. Launch Browser

json
{
  "tool": "browser_launch",
  "arguments": {
    "browserType": "chromium",
    "headless": false
  }
}
json
{
  "tool": "browser_launch",
  "arguments": {
    "browserType": "chromium",
    "headless": false
  }
}

2. 访问网页

2. Access Web Page

json
{
  "tool": "browser_goto",
  "arguments": {
    "url": "https://example.com"
  }
}
json
{
  "tool": "browser_goto",
  "arguments": {
    "url": "https://example.com"
  }
}

3. 获取页面标题

3. Get Page Title

json
{
  "tool": "browser_get_title",
  "arguments": {}
}
json
{
  "tool": "browser_get_title",
  "arguments": {}
}

4. 获取页面文本

4. Get Page Text

json
{
  "tool": "browser_get_text",
  "arguments": {
    "selector": "body"
  }
}
json
{
  "tool": "browser_get_text",
  "arguments": {
    "selector": "body"
  }
}

5. 点击元素

5. Click Element

json
{
  "tool": "browser_click",
  "arguments": {
    "selector": "button.submit"
  }
}
json
{
  "tool": "browser_click",
  "arguments": {
    "selector": "button.submit"
  }
}

6. 填写表单

6. Fill Form

json
{
  "tool": "browser_fill",
  "arguments": {
    "selector": "#username",
    "value": "user@example.com"
  }
}
json
{
  "tool": "browser_fill",
  "arguments": {
    "selector": "#username",
    "value": "user@example.com"
  }
}

7. 截图

7. Take Screenshot

json
{
  "tool": "browser_screenshot",
  "arguments": {
    "path": "screenshot.png",
    "fullPage": true
  }
}
json
{
  "tool": "browser_screenshot",
  "arguments": {
    "path": "screenshot.png",
    "fullPage": true
  }
}

8. 获取所有链接

8. Get All Links

json
{
  "tool": "browser_get_links",
  "arguments": {}
}
json
{
  "tool": "browser_get_links",
  "arguments": {}
}

9. 等待元素

9. Wait for Element

json
{
  "tool": "browser_wait_for_selector",
  "arguments": {
    "selector": ".content",
    "timeout": 10000
  }
}
json
{
  "tool": "browser_wait_for_selector",
  "arguments": {
    "selector": ".content",
    "timeout": 10000
  }
}

10. 关闭浏览器

10. Close Browser

json
{
  "tool": "browser_close",
  "arguments": {}
}
json
{
  "tool": "browser_close",
  "arguments": {}
}

完整任务示例

Complete Task Examples

示例 1:访问网页并提取标题

Example 1: Access web page and extract title

步骤 1: browser_launch
  参数: { "headless": false }

步骤 2: browser_goto
  参数: { "url": "https://example.com" }

步骤 3: browser_get_title
  参数: {}

步骤 4: browser_close
  参数: {}
Step 1: browser_launch
  Parameters: { "headless": false }

Step 2: browser_goto
  Parameters: { "url": "https://example.com" }

Step 3: browser_get_title
  Parameters: {}

Step 4: browser_close
  Parameters: {}

示例 2:搜索并提取结果

Example 2: Search and extract results

步骤 1: browser_launch
  参数: { "headless": false }

步骤 2: browser_goto
  参数: { "url": "https://www.baidu.com" }

步骤 3: browser_fill
  参数: { "selector": "#kw", "value": "OpenClaw" }

步骤 4: browser_click
  参数: { "selector": "#su" }

步骤 5: browser_wait_for_selector
  参数: { "selector": ".result", "timeout": 5000 }

步骤 6: browser_get_text
  参数: { "selector": ".result" }

步骤 7: browser_close
  参数: {}
Step 1: browser_launch
  Parameters: { "headless": false }

Step 2: browser_goto
  Parameters: { "url": "https://www.baidu.com" }

Step 3: browser_fill
  Parameters: { "selector": "#kw", "value": "OpenClaw" }

Step 4: browser_click
  Parameters: { "selector": "#su" }

Step 5: browser_wait_for_selector
  Parameters: { "selector": ".result", "timeout": 5000 }

Step 6: browser_get_text
  Parameters: { "selector": ".result" }

Step 7: browser_close
  Parameters: {}

示例 3:提取网页数据

Example 3: Extract web page data

步骤 1: browser_launch
  参数: {}

步骤 2: browser_goto
  参数: { "url": "https://news.ycombinator.com" }

步骤 3: browser_wait_for_selector
  参数: { "selector": ".itemlist" }

步骤 4: browser_evaluate
  参数: { 
    "script": "Array.from(document.querySelectorAll('.titleline > a')).map(a => ({ title: a.textContent, url: a.href }))"
  }

步骤 5: browser_close
  参数: {}
Step 1: browser_launch
  Parameters: {}

Step 2: browser_goto
  Parameters: { "url": "https://news.ycombinator.com" }

Step 3: browser_wait_for_selector
  Parameters: { "selector": ".itemlist" }

Step 4: browser_evaluate
  Parameters: { 
    "script": "Array.from(document.querySelectorAll('.titleline > a')).map(a => ({ title: a.textContent, url: a.href }))"
  }

Step 5: browser_close
  Parameters: {}

重要提示

Important Notes

  1. 必须先启动浏览器 - 使用任何其他工具前,必须先调用
    browser_launch
  2. 使用完毕要关闭 - 任务完成后,调用
    browser_close
    释放资源
  3. 等待页面加载 - 访问网页后,使用
    browser_wait_for_selector
    等待内容加载
  4. 选择器要准确 - 使用正确的 CSS 选择器来定位元素
  5. 处理错误 - 如果工具调用失败,检查参数是否正确

  1. Must launch the browser first - Before using any other tools, you must call
    browser_launch
    first
  2. Close after use - After the task is completed, call
    browser_close
    to release resources
  3. Wait for page loading - After accessing a web page, use
    browser_wait_for_selector
    to wait for content to load
  4. Selectors should be accurate - Use correct CSS selectors to locate elements
  5. Handle errors - If tool invocation fails, check if parameters are correct

📚 技术文档

📚 Technical Documentation

以下是完整的工具列表和技术文档,供高级用户参考。
The following is the complete tool list and technical documentation for advanced user reference.

目录

Table of Contents

  1. 浏览器管理 (8个工具)
  2. 页面导航 (4个工具)
  3. 元素交互 (12个工具)
  4. 键盘鼠标操作 (8个工具)
  5. 内容提取 (11个工具)
  6. 高级选择器 (7个工具)
  7. 等待操作 (7个工具)
  8. 截图和PDF (3个工具)
  9. JavaScript执行 (3个工具)
  10. Cookie和存储 (8个工具)
  11. 网络控制 (7个工具)
  12. 文件操作 (2个工具)
  13. 视口和设备 (6个工具)
  14. 滚动操作 (2个工具)
  15. 性能指标 (3个工具)
  16. 无障碍功能 (1个工具)
  17. 时间控制 (5个工具)
  18. 权限管理 (2个工具)
  19. 对话框处理 (1个工具)
  20. Frame操作 (1个工具)

浏览器管理

Browser Management

browser_launch

browser_launch

启动浏览器实例(支持设备模拟、视频录制、追踪等高级功能)
参数:
  • browserType
    : 'chromium' | 'firefox' | 'webkit' (默认: 'chromium')
  • headless
    : boolean - 是否无头模式 (默认: true)
  • viewport
    : { width: number, height: number } - 视口大小
  • deviceName
    : string - 设备名称,如 'iPhone 13', 'Pixel 5'
  • recordVideo
    : boolean - 是否录制视频
  • recordTrace
    : boolean - 是否记录追踪
  • slowMo
    : number - 慢动作延迟(毫秒)
调用示例:
json
{
  "browserType": "chromium",
  "headless": false,
  "viewport": { "width": 1920, "height": 1080 },
  "deviceName": "iPhone 13"
}
Launch a browser instance (supports advanced features such as device simulation, video recording, tracing, etc.)
Parameters:
  • browserType
    : 'chromium' | 'firefox' | 'webkit' (default: 'chromium')
  • headless
    : boolean - Whether to run in headless mode (default: true)
  • viewport
    : { width: number, height: number } - Viewport size
  • deviceName
    : string - Device name, e.g. 'iPhone 13', 'Pixel 5'
  • recordVideo
    : boolean - Whether to record video
  • recordTrace
    : boolean - Whether to record tracing
  • slowMo
    : number - Slow motion delay (milliseconds)
Invocation Example:
json
{
  "browserType": "chromium",
  "headless": false,
  "viewport": { "width": 1920, "height": 1080 },
  "deviceName": "iPhone 13"
}

browser_close

browser_close

关闭浏览器并释放所有资源
参数:
调用示例:
json
{}
Close the browser and release all resources
Parameters: None
Invocation Example:
json
{}

browser_new_page

browser_new_page

创建新的浏览器页面(标签页)
参数:
调用示例:
json
{}
Create a new browser page (tab)
Parameters: None
Invocation Example:
json
{}

browser_switch_page

browser_switch_page

切换到指定索引的页面
参数:
  • index
    : number - 页面索引(从0开始)
调用示例:
json
{ "index": 1 }
Switch to the page with the specified index
Parameters:
  • index
    : number - Page index (starts from 0)
Invocation Example:
json
{ "index": 1 }

browser_close_page

browser_close_page

关闭指定索引的页面
参数:
  • index
    : number - 页面索引(可选,默认关闭当前页面)
调用示例:
json
{ "index": 0 }
Close the page with the specified index
Parameters:
  • index
    : number - Page index (optional, closes the current page by default)
Invocation Example:
json
{ "index": 0 }

browser_get_all_pages

browser_get_all_pages

获取所有打开的页面列表
参数:
调用示例:
json
{}
Get a list of all open pages
Parameters: None
Invocation Example:
json
{}

browser_get_version

browser_get_version

获取浏览器版本信息
参数:
调用示例:
json
{}
Get browser version information
Parameters: None
Invocation Example:
json
{}

browser_is_connected

browser_is_connected

检查浏览器连接状态
参数:
调用示例:
json
{}

Check browser connection status
Parameters: None
Invocation Example:
json
{}

页面导航

Page Navigation

browser_goto

browser_goto

导航到指定URL
参数:
  • url
    : string - 目标URL(必需)
  • waitUntil
    : 'load' | 'domcontentloaded' | 'networkidle' - 等待条件
  • timeout
    : number - 超时时间(毫秒)
调用示例:
json
{
  "url": "https://www.example.com",
  "waitUntil": "networkidle",
  "timeout": 30000
}
Navigate to the specified URL
Parameters:
  • url
    : string - Target URL (required)
  • waitUntil
    : 'load' | 'domcontentloaded' | 'networkidle' - Wait condition
  • timeout
    : number - Timeout period (milliseconds)
Invocation Example:
json
{
  "url": "https://www.example.com",
  "waitUntil": "networkidle",
  "timeout": 30000
}

browser_go_back

browser_go_back

返回上一页
参数:
调用示例:
json
{}
Go back to the previous page
Parameters: None
Invocation Example:
json
{}

browser_go_forward

browser_go_forward

前进到下一页
参数:
调用示例:
json
{}
Go forward to the next page
Parameters: None
Invocation Example:
json
{}

browser_reload

browser_reload

刷新当前页面
参数:
调用示例:
json
{}

Refresh the current page
Parameters: None
Invocation Example:
json
{}

元素交互

Element Interaction

browser_click

browser_click

点击页面元素
参数:
  • selector
    : string - CSS选择器(必需)
  • timeout
    : number - 超时时间(毫秒)
  • button
    : 'left' | 'right' | 'middle' - 鼠标按钮
  • clickCount
    : number - 点击次数
调用示例:
json
{
  "selector": "button.submit",
  "button": "left",
  "clickCount": 1
}
Click a page element
Parameters:
  • selector
    : string - CSS selector (required)
  • timeout
    : number - Timeout period (milliseconds)
  • button
    : 'left' | 'right' | 'middle' - Mouse button
  • clickCount
    : number - Number of clicks
Invocation Example:
json
{
  "selector": "button.submit",
  "button": "left",
  "clickCount": 1
}

browser_dblclick

browser_dblclick

双击元素
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": ".item" }
Double-click an element
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": ".item" }

browser_hover

browser_hover

鼠标悬停在元素上
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": ".menu-item" }
Hover the mouse over an element
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": ".menu-item" }

browser_fill

browser_fill

填写表单字段(清空后填入)
参数:
  • selector
    : string - CSS选择器(必需)
  • value
    : string - 要填写的值(必需)
调用示例:
json
{
  "selector": "#username",
  "value": "user@example.com"
}
Fill in a form field (clears first then fills)
Parameters:
  • selector
    : string - CSS selector (required)
  • value
    : string - Value to fill in (required)
Invocation Example:
json
{
  "selector": "#username",
  "value": "user@example.com"
}

browser_type

browser_type

逐字符输入文本(模拟真实键盘输入)
参数:
  • selector
    : string - CSS选择器(必需)
  • text
    : string - 要输入的文本(必需)
  • delay
    : number - 每个字符间的延迟(毫秒)
调用示例:
json
{
  "selector": "#search",
  "text": "playwright",
  "delay": 100
}
Enter text character by character (simulates real keyboard input)
Parameters:
  • selector
    : string - CSS selector (required)
  • text
    : string - Text to enter (required)
  • delay
    : number - Delay between each character (milliseconds)
Invocation Example:
json
{
  "selector": "#search",
  "text": "playwright",
  "delay": 100
}

browser_press

browser_press

按下键盘按键
参数:
  • selector
    : string - CSS选择器(必需)
  • key
    : string - 按键名称(如 'Enter', 'Tab', 'Escape')
调用示例:
json
{
  "selector": "#search",
  "key": "Enter"
}
Press a keyboard key
Parameters:
  • selector
    : string - CSS selector (required)
  • key
    : string - Key name (e.g. 'Enter', 'Tab', 'Escape')
Invocation Example:
json
{
  "selector": "#search",
  "key": "Enter"
}

browser_select

browser_select

选择下拉框选项
参数:
  • selector
    : string - CSS选择器(必需)
  • value
    : string | string[] - 选项值(必需)
调用示例:
json
{
  "selector": "select#country",
  "value": "US"
}
Select a dropdown option
Parameters:
  • selector
    : string - CSS selector (required)
  • value
    : string | string[] - Option value(s) (required)
Invocation Example:
json
{
  "selector": "select#country",
  "value": "US"
}

browser_check

browser_check

勾选复选框
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": "#agree-terms" }
Check a checkbox
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": "#agree-terms" }

browser_uncheck

browser_uncheck

取消勾选复选框
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": "#newsletter" }
Uncheck a checkbox
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": "#newsletter" }

browser_focus

browser_focus

聚焦到元素
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": "#email" }
Focus on an element
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": "#email" }

browser_drag

browser_drag

拖拽元素到目标位置
参数:
  • sourceSelector
    : string - 源元素选择器(必需)
  • targetSelector
    : string - 目标元素选择器(必需)
调用示例:
json
{
  "sourceSelector": ".draggable",
  "targetSelector": ".drop-zone"
}
Drag an element to the target position
Parameters:
  • sourceSelector
    : string - Source element selector (required)
  • targetSelector
    : string - Target element selector (required)
Invocation Example:
json
{
  "sourceSelector": ".draggable",
  "targetSelector": ".drop-zone"
}

browser_tap

browser_tap

触摸点击(移动端)
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": ".mobile-button" }

Touch click (for mobile devices)
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": ".mobile-button" }

键盘鼠标操作

Keyboard and Mouse Operations

browser_keyboard_down

browser_keyboard_down

按下键盘按键(不释放)
参数:
  • key
    : string - 按键名称(必需)
调用示例:
json
{ "key": "Shift" }
Press a keyboard key (without releasing)
Parameters:
  • key
    : string - Key name (required)
Invocation Example:
json
{ "key": "Shift" }

browser_keyboard_up

browser_keyboard_up

释放键盘按键
参数:
  • key
    : string - 按键名称(必需)
调用示例:
json
{ "key": "Shift" }
Release a keyboard key
Parameters:
  • key
    : string - Key name (required)
Invocation Example:
json
{ "key": "Shift" }

browser_mouse_move

browser_mouse_move

移动鼠标到指定坐标
参数:
  • x
    : number - X坐标(必需)
  • y
    : number - Y坐标(必需)
  • steps
    : number - 移动步数(平滑移动)
调用示例:
json
{
  "x": 100,
  "y": 200,
  "steps": 10
}
Move the mouse to the specified coordinates
Parameters:
  • x
    : number - X coordinate (required)
  • y
    : number - Y coordinate (required)
  • steps
    : number - Number of movement steps (for smooth movement)
Invocation Example:
json
{
  "x": 100,
  "y": 200,
  "steps": 10
}

browser_mouse_click

browser_mouse_click

在指定坐标点击鼠标
参数:
  • x
    : number - X坐标(必需)
  • y
    : number - Y坐标(必需)
调用示例:
json
{
  "x": 150,
  "y": 250
}
Click the mouse at the specified coordinates
Parameters:
  • x
    : number - X coordinate (required)
  • y
    : number - Y coordinate (required)
Invocation Example:
json
{
  "x": 150,
  "y": 250
}

browser_mouse_wheel

browser_mouse_wheel

鼠标滚轮滚动
参数:
  • deltaX
    : number - 水平滚动量(必需)
  • deltaY
    : number - 垂直滚动量(必需)
调用示例:
json
{
  "deltaX": 0,
  "deltaY": 100
}
Scroll with the mouse wheel
Parameters:
  • deltaX
    : number - Horizontal scroll amount (required)
  • deltaY
    : number - Vertical scroll amount (required)
Invocation Example:
json
{
  "deltaX": 0,
  "deltaY": 100
}

browser_mouse_down

browser_mouse_down

按下鼠标按键(不释放)
参数:
  • button
    : 'left' | 'right' | 'middle' - 鼠标按键
  • clickCount
    : number - 点击次数
调用示例:
json
{
  "button": "left",
  "clickCount": 1
}
Press a mouse button (without releasing)
Parameters:
  • button
    : 'left' | 'right' | 'middle' - Mouse button
  • clickCount
    : number - Number of clicks
Invocation Example:
json
{
  "button": "left",
  "clickCount": 1
}

browser_mouse_up

browser_mouse_up

释放鼠标按键
参数:
  • button
    : 'left' | 'right' | 'middle' - 鼠标按键
  • clickCount
    : number - 点击次数
调用示例:
json
{
  "button": "left",
  "clickCount": 1
}
Release a mouse button
Parameters:
  • button
    : 'left' | 'right' | 'middle' - Mouse button
  • clickCount
    : number - Number of clicks
Invocation Example:
json
{
  "button": "left",
  "clickCount": 1
}

browser_keyboard_insert_text

browser_keyboard_insert_text

插入文本(不触发键盘事件,直接设置值)
参数:
  • text
    : string - 要插入的文本(必需)
调用示例:
json
{
  "text": "Hello World"
}

Insert text (does not trigger keyboard events, sets value directly)
Parameters:
  • text
    : string - Text to insert (required)
Invocation Example:
json
{
  "text": "Hello World"
}

内容提取

Content Extraction

browser_get_text

browser_get_text

获取元素的文本内容
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": "h1.title" }
Get the text content of an element
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": "h1.title" }

browser_get_title

browser_get_title

获取页面标题
参数:
调用示例:
json
{}
Get the page title
Parameters: None
Invocation Example:
json
{}

browser_get_html

browser_get_html

获取整个页面的HTML内容
参数:
调用示例:
json
{}
Get the HTML content of the entire page
Parameters: None
Invocation Example:
json
{}

browser_get_links

browser_get_links

获取页面中所有链接
参数:
调用示例:
json
{}
Get all links on the page
Parameters: None
Invocation Example:
json
{}

browser_get_attribute

browser_get_attribute

获取元素的属性值
参数:
  • selector
    : string - CSS选择器(必需)
  • attribute
    : string - 属性名称(必需)
调用示例:
json
{
  "selector": "img.logo",
  "attribute": "src"
}
Get the attribute value of an element
Parameters:
  • selector
    : string - CSS selector (required)
  • attribute
    : string - Attribute name (required)
Invocation Example:
json
{
  "selector": "img.logo",
  "attribute": "src"
}

browser_get_input_value

browser_get_input_value

获取输入框的值
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": "#email" }
Get the value of an input box
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": "#email" }

browser_is_visible

browser_is_visible

检查元素是否可见
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": ".modal" }
Check if an element is visible
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": ".modal" }

browser_is_enabled

browser_is_enabled

检查元素是否启用
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": "button.submit" }
Check if an element is enabled
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": "button.submit" }

browser_is_checked

browser_is_checked

检查复选框/单选框是否选中
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": "#agree" }
Check if a checkbox/radio button is selected
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": "#agree" }

browser_count

browser_count

统计匹配选择器的元素数量
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": ".product-item" }
Count the number of elements matching the selector
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": ".product-item" }

browser_get_current_url

browser_get_current_url

获取当前页面URL
参数:
调用示例:
json
{}

Get the current page URL
Parameters: None
Invocation Example:
json
{}

高级选择器

Advanced Selectors

browser_get_by_role

browser_get_by_role

通过ARIA角色查找元素
参数:
  • role
    : string - ARIA角色(必需)
  • name
    : string - 可访问名称
调用示例:
json
{
  "role": "button",
  "name": "Submit"
}
Find elements by ARIA role
Parameters:
  • role
    : string - ARIA role (required)
  • name
    : string - Accessible name
Invocation Example:
json
{
  "role": "button",
  "name": "Submit"
}

browser_get_by_text

browser_get_by_text

通过文本内容查找元素
参数:
  • text
    : string - 文本内容(必需)
  • exact
    : boolean - 是否精确匹配
调用示例:
json
{
  "text": "Sign In",
  "exact": true
}
Find elements by text content
Parameters:
  • text
    : string - Text content (required)
  • exact
    : boolean - Whether to match exactly
Invocation Example:
json
{
  "text": "Sign In",
  "exact": true
}

browser_get_by_label

browser_get_by_label

通过标签文本查找表单元素
参数:
  • text
    : string - 标签文本(必需)
  • exact
    : boolean - 是否精确匹配
调用示例:
json
{
  "text": "Email Address",
  "exact": false
}
Find form elements by label text
Parameters:
  • text
    : string - Label text (required)
  • exact
    : boolean - Whether to match exactly
Invocation Example:
json
{
  "text": "Email Address",
  "exact": false
}

browser_get_by_placeholder

browser_get_by_placeholder

通过占位符文本查找输入框
参数:
  • text
    : string - 占位符文本(必需)
  • exact
    : boolean - 是否精确匹配
调用示例:
json
{
  "text": "Enter your email",
  "exact": false
}
Find input boxes by placeholder text
Parameters:
  • text
    : string - Placeholder text (required)
  • exact
    : boolean - Whether to match exactly
Invocation Example:
json
{
  "text": "Enter your email",
  "exact": false
}

browser_get_by_test_id

browser_get_by_test_id

通过测试ID查找元素
参数:
  • testId
    : string - 测试ID(必需)
调用示例:
json
{ "testId": "submit-button" }
Find elements by test ID
Parameters:
  • testId
    : string - Test ID (required)
Invocation Example:
json
{ "testId": "submit-button" }

browser_get_by_alt_text

browser_get_by_alt_text

通过alt属性文本查找图片元素
参数:
  • text
    : string - alt文本(必需)
  • exact
    : boolean - 是否精确匹配
调用示例:
json
{
  "text": "Company Logo",
  "exact": false
}
Find image elements by alt attribute text
Parameters:
  • text
    : string - Alt text (required)
  • exact
    : boolean - Whether to match exactly
Invocation Example:
json
{
  "text": "Company Logo",
  "exact": false
}

browser_get_by_title

browser_get_by_title

通过title属性查找元素
参数:
  • text
    : string - title文本(必需)
  • exact
    : boolean - 是否精确匹配
调用示例:
json
{
  "text": "Click to expand",
  "exact": false
}

Find elements by title attribute
Parameters:
  • text
    : string - Title text (required)
  • exact
    : boolean - Whether to match exactly
Invocation Example:
json
{
  "text": "Click to expand",
  "exact": false
}

等待操作

Wait Operations

browser_wait_for_selector

browser_wait_for_selector

等待元素出现在DOM中
参数:
  • selector
    : string - CSS选择器(必需)
  • timeout
    : number - 超时时间(毫秒)
  • state
    : 'attached' | 'visible' | 'hidden' - 等待状态
调用示例:
json
{
  "selector": ".loading-complete",
  "timeout": 10000,
  "state": "visible"
}
Wait for an element to appear in the DOM
Parameters:
  • selector
    : string - CSS selector (required)
  • timeout
    : number - Timeout period (milliseconds)
  • state
    : 'attached' | 'visible' | 'hidden' - Wait state
Invocation Example:
json
{
  "selector": ".loading-complete",
  "timeout": 10000,
  "state": "visible"
}

browser_wait_for_timeout

browser_wait_for_timeout

等待指定时间
参数:
  • timeout
    : number - 等待时间(毫秒,必需)
调用示例:
json
{ "timeout": 3000 }
Wait for a specified period of time
Parameters:
  • timeout
    : number - Wait time (milliseconds, required)
Invocation Example:
json
{ "timeout": 3000 }

browser_wait_for_url

browser_wait_for_url

等待URL匹配指定模式
参数:
  • url
    : string - URL模式(必需)
  • timeout
    : number - 超时时间(毫秒)
调用示例:
json
{
  "url": "https://example.com/dashboard",
  "timeout": 5000
}
Wait for the URL to match the specified pattern
Parameters:
  • url
    : string - URL pattern (required)
  • timeout
    : number - Timeout period (milliseconds)
Invocation Example:
json
{
  "url": "https://example.com/dashboard",
  "timeout": 5000
}

browser_wait_for_request

browser_wait_for_request

等待网络请求
参数:
  • urlPattern
    : string - URL模式(必需)
  • timeout
    : number - 超时时间(毫秒)
调用示例:
json
{
  "urlPattern": "**/api/users",
  "timeout": 10000
}
Wait for a network request
Parameters:
  • urlPattern
    : string - URL pattern (required)
  • timeout
    : number - Timeout period (milliseconds)
Invocation Example:
json
{
  "urlPattern": "**/api/users",
  "timeout": 10000
}

browser_wait_for_response

browser_wait_for_response

等待网络响应
参数:
  • urlPattern
    : string - URL模式(必需)
  • timeout
    : number - 超时时间(毫秒)
调用示例:
json
{
  "urlPattern": "**/api/data",
  "timeout": 10000
}
Wait for a network response
Parameters:
  • urlPattern
    : string - URL pattern (required)
  • timeout
    : number - Timeout period (milliseconds)
Invocation Example:
json
{
  "urlPattern": "**/api/data",
  "timeout": 10000
}

browser_wait_for_function

browser_wait_for_function

等待JavaScript函数返回true
参数:
  • fn
    : string - JavaScript函数代码(必需)
  • arg
    : any - 传递给函数的参数
  • timeout
    : number - 超时时间(毫秒)
  • polling
    : number - 轮询间隔(毫秒)
调用示例:
json
{
  "fn": "() => document.readyState === 'complete'",
  "timeout": 5000,
  "polling": 100
}
Wait for a JavaScript function to return true
Parameters:
  • fn
    : string - JavaScript function code (required)
  • arg
    : any - Parameters passed to the function
  • timeout
    : number - Timeout period (milliseconds)
  • polling
    : number - Polling interval (milliseconds)
Invocation Example:
json
{
  "fn": "() => document.readyState === 'complete'",
  "timeout": 5000,
  "polling": 100
}

browser_wait_for_load_state

browser_wait_for_load_state

等待页面加载到指定状态
参数:
  • state
    : 'load' | 'domcontentloaded' | 'networkidle' - 加载状态(必需)
  • timeout
    : number - 超时时间(毫秒)
调用示例:
json
{
  "state": "networkidle",
  "timeout": 30000
}

Wait for the page to load to the specified state
Parameters:
  • state
    : 'load' | 'domcontentloaded' | 'networkidle' - Load state (required)
  • timeout
    : number - Timeout period (milliseconds)
Invocation Example:
json
{
  "state": "networkidle",
  "timeout": 30000
}

截图和PDF

Screenshots and PDF

browser_screenshot

browser_screenshot

截取页面截图
参数:
  • path
    : string - 保存路径
  • fullPage
    : boolean - 是否截取整页
  • type
    : 'png' | 'jpeg' - 图片格式
  • quality
    : number - 图片质量(0-100,仅JPEG)
调用示例:
json
{
  "path": "screenshot.png",
  "fullPage": true,
  "type": "png"
}
Take a page screenshot
Parameters:
  • path
    : string - Save path
  • fullPage
    : boolean - Whether to capture the full page
  • type
    : 'png' | 'jpeg' - Image format
  • quality
    : number - Image quality (0-100, only for JPEG)
Invocation Example:
json
{
  "path": "screenshot.png",
  "fullPage": true,
  "type": "png"
}

browser_screenshot_element

browser_screenshot_element

截取指定元素的截图
参数:
  • selector
    : string - CSS选择器(必需)
  • path
    : string - 保存路径
调用示例:
json
{
  "selector": ".chart",
  "path": "chart.png"
}
Take a screenshot of a specified element
Parameters:
  • selector
    : string - CSS selector (required)
  • path
    : string - Save path
Invocation Example:
json
{
  "selector": ".chart",
  "path": "chart.png"
}

browser_pdf

browser_pdf

生成页面PDF
参数:
  • path
    : string - 保存路径
  • format
    : string - 纸张格式(如 'A4', 'Letter')
  • printBackground
    : boolean - 是否打印背景
调用示例:
json
{
  "path": "page.pdf",
  "format": "A4",
  "printBackground": true
}

Generate a page PDF
Parameters:
  • path
    : string - Save path
  • format
    : string - Paper format (e.g. 'A4', 'Letter')
  • printBackground
    : boolean - Whether to print background
Invocation Example:
json
{
  "path": "page.pdf",
  "format": "A4",
  "printBackground": true
}

JavaScript执行

JavaScript Execution

browser_evaluate

browser_evaluate

在页面上下文中执行JavaScript代码
参数:
  • script
    : string - JavaScript代码(必需)
  • arg
    : any - 传递给脚本的参数
调用示例:
json
{
  "script": "document.querySelectorAll('h2').length"
}
Execute JavaScript code in the page context
Parameters:
  • script
    : string - JavaScript code (required)
  • arg
    : any - Parameters passed to the script
Invocation Example:
json
{
  "script": "document.querySelectorAll('h2').length"
}

browser_add_script_tag

browser_add_script_tag

向页面添加脚本标签
参数:
  • url
    : string - 脚本URL
  • content
    : string - 脚本内容
调用示例:
json
{
  "url": "https://cdn.example.com/library.js"
}
Add a script tag to the page
Parameters:
  • url
    : string - Script URL
  • content
    : string - Script content
Invocation Example:
json
{
  "url": "https://cdn.example.com/library.js"
}

browser_add_style_tag

browser_add_style_tag

向页面添加样式标签
参数:
  • url
    : string - 样式URL
  • content
    : string - 样式内容
调用示例:
json
{
  "content": "body { background: red; }"
}

Add a style tag to the page
Parameters:
  • url
    : string - Style URL
  • content
    : string - Style content
Invocation Example:
json
{
  "content": "body { background: red; }"
}

Cookie和存储

Cookie and Storage

browser_set_cookies

browser_set_cookies

设置一个或多个Cookie
参数:
  • cookies
    : array - Cookie数组(必需)
    • name
      : string - Cookie名称
    • value
      : string - Cookie值
    • domain
      : string - 域名
    • path
      : string - 路径
调用示例:
json
{
  "cookies": [
    {
      "name": "session",
      "value": "abc123",
      "domain": "example.com",
      "path": "/"
    }
  ]
}
Set one or more cookies
Parameters:
  • cookies
    : array - Cookie array (required)
    • name
      : string - Cookie name
    • value
      : string - Cookie value
    • domain
      : string - Domain name
    • path
      : string - Path
Invocation Example:
json
{
  "cookies": [
    {
      "name": "session",
      "value": "abc123",
      "domain": "example.com",
      "path": "/"
    }
  ]
}

browser_get_cookies

browser_get_cookies

获取当前页面的所有Cookie
参数:
调用示例:
json
{}
Get all cookies of the current page
Parameters: None
Invocation Example:
json
{}

browser_clear_cookies

browser_clear_cookies

清除所有Cookie
参数:
调用示例:
json
{}
Clear all cookies
Parameters: None
Invocation Example:
json
{}

browser_set_local_storage

browser_set_local_storage

设置LocalStorage项
参数:
  • key
    : string - 键名(必需)
  • value
    : string - 值(必需)
调用示例:
json
{
  "key": "theme",
  "value": "dark"
}
Set LocalStorage item
Parameters:
  • key
    : string - Key name (required)
  • value
    : string - Value (required)
Invocation Example:
json
{
  "key": "theme",
  "value": "dark"
}

browser_get_local_storage

browser_get_local_storage

获取LocalStorage项
参数:
  • key
    : string - 键名(可选,不提供则返回所有)
调用示例:
json
{ "key": "theme" }
Get LocalStorage item
Parameters:
  • key
    : string - Key name (optional, returns all items if not provided)
Invocation Example:
json
{ "key": "theme" }

browser_clear_local_storage

browser_clear_local_storage

清除LocalStorage
参数:
调用示例:
json
{}
Clear LocalStorage
Parameters: None
Invocation Example:
json
{}

browser_storage_state

browser_storage_state

保存存储状态(Cookie和LocalStorage)
参数:
  • path
    : string - 保存路径
调用示例:
json
{ "path": "storage.json" }
Save storage state (Cookie and LocalStorage)
Parameters:
  • path
    : string - Save path
Invocation Example:
json
{ "path": "storage.json" }

browser_restore_storage_state

browser_restore_storage_state

恢复存储状态
参数:
  • state
    : object - 存储状态对象(必需)
调用示例:
json
{
  "state": { "cookies": [], "origins": [] }
}

Restore storage state
Parameters:
  • state
    : object - Storage state object (required)
Invocation Example:
json
{
  "state": { "cookies": [], "origins": [] }
}

网络控制

Network Control

browser_set_offline

browser_set_offline

设置离线模式
参数:
  • offline
    : boolean - 是否离线(必需)
调用示例:
json
{ "offline": true }
Set offline mode
Parameters:
  • offline
    : boolean - Whether to be offline (required)
Invocation Example:
json
{ "offline": true }

browser_block_requests

browser_block_requests

拦截匹配模式的请求
参数:
  • patterns
    : array - URL模式数组(必需)
调用示例:
json
{
  "patterns": ["*.jpg", "*.png", "*/ads/*"]
}
Block requests matching the pattern
Parameters:
  • patterns
    : array - URL pattern array (required)
Invocation Example:
json
{
  "patterns": ["*.jpg", "*.png", "*/ads/*"]
}

browser_mock_response

browser_mock_response

模拟网络响应
参数:
  • urlPattern
    : string - URL模式(必需)
  • response
    : object - 响应对象(必需)
    • status
      : number - 状态码
    • body
      : string - 响应体
    • contentType
      : string - 内容类型
调用示例:
json
{
  "urlPattern": "**/api/users",
  "response": {
    "status": 200,
    "body": "{\"users\": []}",
    "contentType": "application/json"
  }
}
Mock network response
Parameters:
  • urlPattern
    : string - URL pattern (required)
  • response
    : object - Response object (required)
    • status
      : number - Status code
    • body
      : string - Response body
    • contentType
      : string - Content type
Invocation Example:
json
{
  "urlPattern": "**/api/users",
  "response": {
    "status": 200,
    "body": "{\"users\": []}",
    "contentType": "application/json"
  }
}

browser_get_request_logs

browser_get_request_logs

获取请求日志
参数:
  • limit
    : number - 限制数量
调用示例:
json
{ "limit": 50 }
Get request logs
Parameters:
  • limit
    : number - Limit number
Invocation Example:
json
{ "limit": 50 }

browser_get_response_logs

browser_get_response_logs

获取响应日志
参数:
  • limit
    : number - 限制数量
调用示例:
json
{ "limit": 50 }
Get response logs
Parameters:
  • limit
    : number - Limit number
Invocation Example:
json
{ "limit": 50 }

browser_get_console_logs

browser_get_console_logs

获取控制台日志
参数:
  • limit
    : number - 限制数量
调用示例:
json
{ "limit": 100 }
Get console logs
Parameters:
  • limit
    : number - Limit number
Invocation Example:
json
{ "limit": 100 }

browser_clear_logs

browser_clear_logs

清除所有日志(请求、响应、控制台)
参数:
调用示例:
json
{}

Clear all logs (request, response, console)
Parameters: None
Invocation Example:
json
{}

文件操作

File Operations

browser_upload_file

browser_upload_file

上传文件到文件输入框
参数:
  • selector
    : string - 文件输入框选择器(必需)
  • filePath
    : string | array - 文件路径(必需)
调用示例:
json
{
  "selector": "input[type='file']",
  "filePath": "C:\\Users\\Admin\\document.pdf"
}
Upload files to a file input box
Parameters:
  • selector
    : string - File input box selector (required)
  • filePath
    : string | array - File path(s) (required)
Invocation Example:
json
{
  "selector": "input[type='file']",
  "filePath": "C:\\Users\\Admin\\document.pdf"
}

browser_download_file

browser_download_file

触发文件下载
参数:
  • triggerSelector
    : string - 触发下载的元素选择器(必需)
调用示例:
json
{ "triggerSelector": "a.download-link" }

Trigger file download
Parameters:
  • triggerSelector
    : string - Selector of the element that triggers download (required)
Invocation Example:
json
{ "triggerSelector": "a.download-link" }

视口和设备

Viewport and Device

browser_set_viewport_size

browser_set_viewport_size

设置视口大小
参数:
  • width
    : number - 宽度(必需)
  • height
    : number - 高度(必需)
调用示例:
json
{
  "width": 1920,
  "height": 1080
}
Set viewport size
Parameters:
  • width
    : number - Width (required)
  • height
    : number - Height (required)
Invocation Example:
json
{
  "width": 1920,
  "height": 1080
}

browser_get_viewport_size

browser_get_viewport_size

获取当前视口大小
参数:
调用示例:
json
{}
Get current viewport size
Parameters: None
Invocation Example:
json
{}

browser_emulate_media

browser_emulate_media

模拟媒体类型和配色方案
参数:
  • colorScheme
    : 'light' | 'dark' | 'no-preference' - 配色方案
  • media
    : 'screen' | 'print' - 媒体类型
调用示例:
json
{
  "colorScheme": "dark",
  "media": "screen"
}
Emulate media type and color scheme
Parameters:
  • colorScheme
    : 'light' | 'dark' | 'no-preference' - Color scheme
  • media
    : 'screen' | 'print' - Media type
Invocation Example:
json
{
  "colorScheme": "dark",
  "media": "screen"
}

browser_set_geolocation

browser_set_geolocation

设置地理位置
参数:
  • latitude
    : number - 纬度(必需)
  • longitude
    : number - 经度(必需)
  • accuracy
    : number - 精度
调用示例:
json
{
  "latitude": 37.7749,
  "longitude": -122.4194,
  "accuracy": 100
}
Set geolocation
Parameters:
  • latitude
    : number - Latitude (required)
  • longitude
    : number - Longitude (required)
  • accuracy
    : number - Accuracy
Invocation Example:
json
{
  "latitude": 37.7749,
  "longitude": -122.4194,
  "accuracy": 100
}

browser_clear_geolocation

browser_clear_geolocation

清除地理位置设置
参数:
调用示例:
json
{}
Clear geolocation settings
Parameters: None
Invocation Example:
json
{}

browser_touchscreen_tap

browser_touchscreen_tap

触摸屏点击指定坐标(移动端)
参数:
  • x
    : number - X坐标(必需)
  • y
    : number - Y坐标(必需)
调用示例:
json
{
  "x": 100,
  "y": 200
}

Tap on the touchscreen at specified coordinates (for mobile devices)
Parameters:
  • x
    : number - X coordinate (required)
  • y
    : number - Y coordinate (required)
Invocation Example:
json
{
  "x": 100,
  "y": 200
}

滚动操作

Scroll Operations

browser_scroll_to

browser_scroll_to

滚动到指定坐标
参数:
  • x
    : number - X坐标(必需)
  • y
    : number - Y坐标(必需)
调用示例:
json
{
  "x": 0,
  "y": 1000
}
Scroll to specified coordinates
Parameters:
  • x
    : number - X coordinate (required)
  • y
    : number - Y coordinate (required)
Invocation Example:
json
{
  "x": 0,
  "y": 1000
}

browser_scroll_into_view

browser_scroll_into_view

滚动元素到可见区域
参数:
  • selector
    : string - CSS选择器(必需)
调用示例:
json
{ "selector": "#footer" }

Scroll an element into the visible area
Parameters:
  • selector
    : string - CSS selector (required)
Invocation Example:
json
{ "selector": "#footer" }

性能指标

Performance Metrics

browser_get_metrics

browser_get_metrics

获取页面性能指标
参数:
调用示例:
json
{}
返回数据包括:
  • domContentLoaded: DOM内容加载时间
  • loadComplete: 页面完全加载时间
  • firstPaint: 首次绘制时间
  • firstContentfulPaint: 首次内容绘制时间
Get page performance metrics
Parameters: None
Invocation Example:
json
{}
Return data includes:
  • domContentLoaded: DOM content loading time
  • loadComplete: Page complete loading time
  • firstPaint: First paint time
  • firstContentfulPaint: First contentful paint time

browser_get_coverage

browser_get_coverage

开始收集JavaScript和CSS代码覆盖率
参数:
调用示例:
json
{}
Start collecting JavaScript and CSS code coverage
Parameters: None
Invocation Example:
json
{}

browser_stop_coverage

browser_stop_coverage

停止收集代码覆盖率并返回结果
参数:
调用示例:
json
{}

Stop collecting code coverage and return results
Parameters: None
Invocation Example:
json
{}

无障碍功能

Accessibility Features

browser_get_accessibility_snapshot

browser_get_accessibility_snapshot

获取页面无障碍树快照
参数:
  • selector
    : string - 限定范围的选择器(可选)
调用示例:
json
{ "selector": "main" }

Get page accessibility tree snapshot
Parameters:
  • selector
    : string - Selector to limit the scope (optional)
Invocation Example:
json
{ "selector": "main" }

时间控制

Time Control

browser_install_clock

browser_install_clock

安装时钟控制(用于测试时间相关功能)
参数:
  • time
    : number | string - 初始时间
调用示例:
json
{ "time": 1609459200000 }
Install clock control (for testing time-related functions)
Parameters:
  • time
    : number | string - Initial time
Invocation Example:
json
{ "time": 1609459200000 }

browser_set_system_time

browser_set_system_time

设置系统时间
参数:
  • time
    : number | string - 时间戳或日期字符串(必需)
调用示例:
json
{ "time": "2024-01-01T00:00:00Z" }
Set system time
Parameters:
  • time
    : number | string - Timestamp or date string (required)
Invocation Example:
json
{ "time": "2024-01-01T00:00:00Z" }

browser_fast_forward

browser_fast_forward

快进时间
参数:
  • time
    : number - 快进的毫秒数(必需)
调用示例:
json
{ "time": 60000 }
Fast forward time
Parameters:
  • time
    : number - Milliseconds to fast forward (required)
Invocation Example:
json
{ "time": 60000 }

browser_pause_clock

browser_pause_clock

暂停时钟(冻结时间)
参数:
调用示例:
json
{}
Pause the clock (freeze time)
Parameters: None
Invocation Example:
json
{}

browser_resume_clock

browser_resume_clock

恢复时钟运行
参数:
调用示例:
json
{}

Resume clock operation
Parameters: None
Invocation Example:
json
{}

权限管理

Permission Management

browser_grant_permissions

browser_grant_permissions

授予浏览器权限
参数:
  • permissions
    : array - 权限列表(必需)
    • 可选值: 'geolocation', 'notifications', 'camera', 'microphone', 'clipboard-read', 'clipboard-write'
  • origin
    : string - 限定域名
调用示例:
json
{
  "permissions": ["geolocation", "notifications"],
  "origin": "https://example.com"
}
Grant browser permissions
Parameters:
  • permissions
    : array - Permission list (required)
    • Optional values: 'geolocation', 'notifications', 'camera', 'microphone', 'clipboard-read', 'clipboard-write'
  • origin
    : string - Limited domain name
Invocation Example:
json
{
  "permissions": ["geolocation", "notifications"],
  "origin": "https://example.com"
}

browser_clear_permissions

browser_clear_permissions

清除所有权限
参数:
调用示例:
json
{}

Clear all permissions
Parameters: None
Invocation Example:
json
{}

对话框处理

Dialog Handling

browser_handle_dialog

browser_handle_dialog

处理JavaScript对话框(alert, confirm, prompt)
参数:
  • action
    : 'accept' | 'dismiss' - 操作类型(必需)
  • promptText
    : string - prompt对话框的输入文本
调用示例:
json
{
  "action": "accept",
  "promptText": "My Input"
}

Handle JavaScript dialogs (alert, confirm, prompt)
Parameters:
  • action
    : 'accept' | 'dismiss' - Operation type (required)
  • promptText
    : string - Input text for prompt dialogs
Invocation Example:
json
{
  "action": "accept",
  "promptText": "My Input"
}

Frame操作

Frame Operations

browser_get_frames

browser_get_frames

获取页面中所有frame
参数:
调用示例:
json
{}


Get all frames in the page
Parameters: None
Invocation Example:
json
{}


🎯 实际使用场景示例

🎯 Practical Usage Scenario Examples

以下是一些实际的使用场景,展示如何用自然语言与我交互来完成任务。
The following are some practical usage scenarios showing how to interact with me in natural language to complete tasks.

场景 1:查看网页内容

Scenario 1: View web page content

你说: "帮我看看 example.com 上有什么"
我会做:
  1. 启动浏览器
  2. 访问 example.com
  3. 提取页面标题和主要内容
  4. 总结并告诉你
You say: "Help me see what is on example.com"
What I will do:
  1. Launch the browser
  2. Access example.com
  3. Extract the page title and main content
  4. Summarize and tell you

场景 2:搜索信息

Scenario 2: Search for information

你说: "在百度搜索 'OpenClaw 使用教程'"
我会做:
  1. 启动浏览器
  2. 访问百度
  3. 在搜索框输入关键词
  4. 点击搜索按钮
  5. 提取搜索结果
You say: "Search for 'OpenClaw tutorial' on Baidu"
What I will do:
  1. Launch the browser
  2. Access Baidu
  3. Enter keywords in the search box
  4. Click the search button
  5. Extract search results

场景 3:提取数据

Scenario 3: Extract data

你说: "从 news.ycombinator.com 提取前10条新闻标题"
我会做:
  1. 访问 Hacker News
  2. 定位新闻列表
  3. 提取标题和链接
  4. 整理成列表返回给你
You say: "Extract the first 10 news titles from news.ycombinator.com"
What I will do:
  1. Access Hacker News
  2. Locate the news list
  3. Extract titles and links
  4. Organize into a list and return to you

场景 4:网页截图

Scenario 4: Web page screenshot

你说: "帮我截取 github.com 首页的截图"
我会做:
  1. 访问 GitHub
  2. 等待页面加载完成
  3. 截取整页截图
  4. 保存并告诉你文件位置
You say: "Help me take a screenshot of the github.com homepage"
What I will do:
  1. Access GitHub
  2. Wait for the page to load completely
  3. Take a full-page screenshot
  4. Save and tell you the file location

场景 5:表单操作

Scenario 5: Form operation

你说: "帮我在这个登录页面输入用户名和密码"
我会做:
  1. 找到用户名输入框
  2. 填写用户名
  3. 找到密码输入框
  4. 填写密码
  5. 询问是否需要点击登录按钮
You say: "Help me enter username and password on this login page"
What I will do:
  1. Find the username input box
  2. Fill in the username
  3. Find the password input box
  4. Fill in the password
  5. Ask if you need to click the login button

场景 6:监控网页变化

Scenario 6: Monitor web page changes

你说: "每隔5分钟检查一次这个网页的价格"
我会做:
  1. 定期访问网页
  2. 提取价格信息
  3. 与上次对比
  4. 如有变化立即通知你

You say: "Check the price of this web page every 5 minutes"
What I will do:
  1. Access the web page regularly
  2. Extract price information
  3. Compare with the last time
  4. Notify you immediately if there is a change

📖 技术文档:工具列表

📖 Technical Documentation: Tool List

以下是完整的 101 个工具的详细文档,供高级用户和开发者参考。
注意: 作为普通用户,你不需要了解这些技术细节。直接用自然语言告诉我你的需求即可。

The following is the detailed documentation of the complete 101 tools for advanced users and developers reference.
Note: As a regular user, you don't need to understand these technical details. Just tell me your requirements in natural language.

使用示例

Usage Examples

示例1:基础网页访问和截图

Example 1: Basic web page access and screenshot

1. browser_launch({ "headless": false })
2. browser_goto({ "url": "https://www.example.com" })
3. browser_get_title()
4. browser_screenshot({ "path": "screenshot.png", "fullPage": true })
5. browser_close()
1. browser_launch({ "headless": false })
2. browser_goto({ "url": "https://www.example.com" })
3. browser_get_title()
4. browser_screenshot({ "path": "screenshot.png", "fullPage": true })
5. browser_close()

示例2:表单填写和提交

Example 2: Form filling and submission

1. browser_launch()
2. browser_goto({ "url": "https://example.com/login" })
3. browser_fill({ "selector": "#username", "value": "user@example.com" })
4. browser_fill({ "selector": "#password", "value": "password123" })
5. browser_click({ "selector": "button[type='submit']" })
6. browser_wait_for_selector({ "selector": ".dashboard", "timeout": 10000 })
7. browser_close()
1. browser_launch()
2. browser_goto({ "url": "https://example.com/login" })
3. browser_fill({ "selector": "#username", "value": "user@example.com" })
4. browser_fill({ "selector": "#password", "value": "password123" })
5. browser_click({ "selector": "button[type='submit']" })
6. browser_wait_for_selector({ "selector": ".dashboard", "timeout": 10000 })
7. browser_close()

示例3:数据抓取

Example 3: Data scraping

1. browser_launch()
2. browser_goto({ "url": "https://example.com/products" })
3. browser_wait_for_selector({ "selector": ".product-list" })
4. browser_count({ "selector": ".product-item" })
5. browser_get_links()
6. browser_evaluate({ "script": "Array.from(document.querySelectorAll('.price')).map(e => e.textContent)" })
7. browser_close()
1. browser_launch()
2. browser_goto({ "url": "https://example.com/products" })
3. browser_wait_for_selector({ "selector": ".product-list" })
4. browser_count({ "selector": ".product-item" })
5. browser_get_links()
6. browser_evaluate({ "script": "Array.from(document.querySelectorAll('.price')).map(e => e.textContent)" })
7. browser_close()

示例4:网络拦截和模拟

Example 4: Network interception and mocking

1. browser_launch()
2. browser_block_requests({ "patterns": ["*.jpg", "*.png", "*/ads/*"] })
3. browser_mock_response({ 
     "urlPattern": "**/api/users", 
     "response": { "status": 200, "body": "{\"users\": []}" }
   })
4. browser_goto({ "url": "https://example.com" })
5. browser_get_request_logs({ "limit": 50 })
6. browser_close()
1. browser_launch()
2. browser_block_requests({ "patterns": ["*.jpg", "*.png", "*/ads/*"] })
3. browser_mock_response({ 
     "urlPattern": "**/api/users", 
     "response": { "status": 200, "body": "{\"users\": []}" }
   })
4. browser_goto({ "url": "https://example.com" })
5. browser_get_request_logs({ "limit": 50 })
6. browser_close()

示例5:移动设备模拟

Example 5: Mobile device simulation

1. browser_launch({ 
     "deviceName": "iPhone 13", 
     "headless": false 
   })
2. browser_goto({ "url": "https://example.com" })
3. browser_tap({ "selector": ".mobile-menu" })
4. browser_screenshot({ "path": "mobile.png" })
5. browser_close()
1. browser_launch({ 
     "deviceName": "iPhone 13", 
     "headless": false 
   })
2. browser_goto({ "url": "https://example.com" })
3. browser_tap({ "selector": ".mobile-menu" })
4. browser_screenshot({ "path": "mobile.png" })
5. browser_close()

示例6:性能监控

Example 6: Performance monitoring

1. browser_launch()
2. browser_goto({ "url": "https://example.com" })
3. browser_get_metrics()
4. browser_get_console_logs({ "limit": 100 })
5. browser_get_response_logs({ "limit": 50 })
6. browser_close()

1. browser_launch()
2. browser_goto({ "url": "https://example.com" })
3. browser_get_metrics()
4. browser_get_console_logs({ "limit": 100 })
5. browser_get_response_logs({ "limit": 50 })
6. browser_close()

选择器语法参考

Selector Syntax Reference

CSS选择器

CSS Selectors

css
/* ID选择器 */
#element-id

/* 类选择器 */
.class-name

/* 属性选择器 */
[data-testid="submit"]
[name="username"]
[type="text"]

/* 组合选择器 */
div.container > button.primary
form input[type="text"]
ul li:first-child

/* 伪类选择器 */
button:hover
input:focus
div:nth-child(2)
css
/* ID selector */
#element-id

/* Class selector */
.class-name

/* Attribute selector */
[data-testid="submit"]
[name="username"]
[type="text"]

/* Combined selector */
div.container > button.primary
form input[type="text"]
ul li:first-child

/* Pseudo-class selector */
button:hover
input:focus
div:nth-child(2)

高级选择器

Advanced Selectors

javascript
// 通过文本内容
browser_get_by_text({ "text": "Sign In" })

// 通过ARIA角色
browser_get_by_role({ "role": "button", "name": "Submit" })

// 通过标签
browser_get_by_label({ "text": "Email Address" })

// 通过占位符
browser_get_by_placeholder({ "text": "Enter your email" })

// 通过测试ID
browser_get_by_test_id({ "testId": "submit-button" })

javascript
// By text content
browser_get_by_text({ "text": "Sign In" })

// By ARIA role
browser_get_by_role({ "role": "button", "name": "Submit" })

// By label
browser_get_by_label({ "text": "Email Address" })

// By placeholder
browser_get_by_placeholder({ "text": "Enter your email" })

// By test ID
browser_get_by_test_id({ "testId": "submit-button" })

常用键盘按键

Common Keyboard Keys

  • Enter
    - 回车键
  • Tab
    - Tab键
  • Escape
    - Esc键
  • Backspace
    - 退格键
  • Delete
    - 删除键
  • ArrowUp
    ,
    ArrowDown
    ,
    ArrowLeft
    ,
    ArrowRight
    - 方向键
  • Home
    ,
    End
    - Home/End键
  • PageUp
    ,
    PageDown
    - 翻页键
  • Control
    ,
    Shift
    ,
    Alt
    ,
    Meta
    - 修饰键
  • F1
    -
    F12
    - 功能键

  • Enter
    - Enter key
  • Tab
    - Tab key
  • Escape
    - Esc key
  • Backspace
    - Backspace key
  • Delete
    - Delete key
  • ArrowUp
    ,
    ArrowDown
    ,
    ArrowLeft
    ,
    ArrowRight
    - Arrow keys
  • Home
    ,
    End
    - Home/End keys
  • PageUp
    ,
    PageDown
    - Page up/down keys
  • Control
    ,
    Shift
    ,
    Alt
    ,
    Meta
    - Modifier keys
  • F1
    -
    F12
    - Function keys

错误处理和最佳实践

Error Handling and Best Practices

1. 浏览器生命周期管理

1. Browser Lifecycle Management

  • 使用前必须先调用
    browser_launch
    启动浏览器
  • 使用完毕后应调用
    browser_close
    释放资源
  • 浏览器未启动时调用其他方法会抛出错误
  • You must call
    browser_launch
    to launch the browser before use
  • You should call
    browser_close
    to release resources after use
  • Calling other methods when the browser is not launched will throw an error

2. 等待策略

2. Wait Strategy

  • 使用
    browser_wait_for_selector
    确保元素加载完成
  • 设置合理的超时时间(默认30秒)
  • 使用
    waitUntil: 'networkidle'
    等待网络请求完成
  • Use
    browser_wait_for_selector
    to ensure elements are loaded
  • Set a reasonable timeout period (default 30 seconds)
  • Use
    waitUntil: 'networkidle'
    to wait for network requests to complete

3. 选择器最佳实践

3. Selector Best Practices

  • 优先使用稳定的选择器(ID、data-testid)
  • 避免使用易变的选择器(nth-child、复杂的CSS路径)
  • 使用语义化选择器(getByRole、getByLabel)提高可维护性
  • Prioritize using stable selectors (ID, data-testid)
  • Avoid using volatile selectors (nth-child, complex CSS paths)
  • Use semantic selectors (getByRole, getByLabel) to improve maintainability

4. 性能优化

4. Performance Optimization

  • 使用
    headless: true
    提高执行速度
  • 使用
    browser_block_requests
    拦截不必要的资源(图片、广告)
  • 合理设置视口大小,避免过大的截图
  • Use
    headless: true
    to improve execution speed
  • Use
    browser_block_requests
    to block unnecessary resources (images, ads)
  • Set a reasonable viewport size to avoid overly large screenshots

5. 调试技巧

5. Debugging Tips

  • 使用
    headless: false
    查看浏览器操作过程
  • 使用
    slowMo
    参数减慢操作速度
  • 使用
    browser_get_console_logs
    查看页面错误
  • 使用
    recordVideo
    recordTrace
    记录操作过程
  • Use
    headless: false
    to view the browser operation process
  • Use the
    slowMo
    parameter to slow down the operation speed
  • Use
    browser_get_console_logs
    to view page errors
  • Use
    recordVideo
    and
    recordTrace
    to record the operation process

6. 错误处理

6. Error Handling

javascript
// 所有工具调用失败时会返回错误信息
// 建议在使用时:
1. 先检查浏览器是否已启动
2. 使用 wait_for_selector 确保元素加载完成
3. 设置合理的超时时间
4. 使用 try-catch 处理异常情况

javascript
// All tool calls will return error information when they fail
// Recommended when using:
1. First check if the browser has been launched
2. Use wait_for_selector to ensure elements are loaded
3. Set a reasonable timeout period
4. Use try-catch to handle exceptions

注意事项

Notes

  1. 路径格式:Windows系统使用双反斜杠
    \\
    或正斜杠
    /
    • 正确:
      C:\\Users\\Admin\\file.pdf
      C:/Users/Admin/file.pdf
    • 错误:
      C:\Users\Admin\file.pdf
  2. 超时设置:默认超时为30秒,可根据需要调整
    • 网络慢时增加超时时间
    • 快速操作可减少超时时间
  3. 截图返回:截图返回base64编码的图片数据
    • 可保存到文件或直接使用
  4. Cookie域名:设置Cookie时必须指定正确的域名
    • 域名必须与当前页面匹配
  5. JavaScript执行:evaluate中的代码在页面上下文执行
    • 可访问页面的DOM和全局变量
    • 返回值必须是可序列化的
  6. 设备模拟:支持的设备名称参考Playwright设备列表
    • 常用:'iPhone 13', 'Pixel 5', 'iPad Pro'
  7. 权限授予:某些功能需要先授予权限
    • 地理位置需要 'geolocation' 权限
    • 通知需要 'notifications' 权限

  1. Path format: Use double backslashes
    \\
    or forward slashes
    /
    for Windows systems
    • Correct:
      C:\\Users\\Admin\\file.pdf
      or
      C:/Users/Admin/file.pdf
    • Incorrect:
      C:\Users\Admin\file.pdf
  2. Timeout setting: The default timeout is 30 seconds, which can be adjusted as needed
    • Increase the timeout when the network is slow
    • Reduce the timeout for fast operations
  3. Screenshot return: Screenshots return base64 encoded image data
    • Can be saved to a file or used directly
  4. Cookie domain: The correct domain must be specified when setting cookies
    • The domain must match the current page
  5. JavaScript execution: The code in evaluate is executed in the page context
    • Can access the page's DOM and global variables
    • The return value must be serializable
  6. Device simulation: Refer to the Playwright device list for supported device names
    • Common: 'iPhone 13', 'Pixel 5', 'iPad Pro'
  7. Permission granting: Some functions require granting permissions first
    • Geolocation requires 'geolocation' permission
    • Notifications require 'notifications' permission

工具总数统计

Total Tool Count Statistics

  • 浏览器管理: 8个工具
  • 页面导航: 4个工具
  • 元素交互: 12个工具
  • 键盘鼠标操作: 5个工具
  • 内容提取: 11个工具
  • 高级选择器: 5个工具
  • 等待操作: 5个工具
  • 截图和PDF: 3个工具
  • JavaScript执行: 3个工具
  • Cookie和存储: 8个工具
  • 网络控制: 7个工具
  • 文件操作: 2个工具
  • 视口和设备: 4个工具
  • 滚动操作: 2个工具
  • 性能指标: 1个工具
  • 无障碍功能: 1个工具
  • 时间控制: 3个工具
  • 权限管理: 2个工具
  • 对话框处理: 1个工具
  • Frame操作: 1个工具
总计:101个核心工具

  • Browser Management: 8 tools
  • Page Navigation: 4 tools
  • Element Interaction: 12 tools
  • Keyboard and Mouse Operations: 5 tools
  • Content Extraction: 11 tools
  • Advanced Selectors: 5 tools
  • Wait Operations: 5 tools
  • Screenshots and PDF: 3 tools
  • JavaScript Execution: 3 tools
  • Cookie and Storage: 8 tools
  • Network Control: 7 tools
  • File Operations: 2 tools
  • Viewport and Device: 4 tools
  • Scroll Operations: 2 tools
  • Performance Metrics: 1 tool
  • Accessibility Features: 1 tool
  • Time Control: 3 tools
  • Permission Management: 2 tools
  • Dialog Handling: 1 tool
  • Frame Operations: 1 tool
Total: 101 core tools

版本信息

Version Information

  • 版本: 2.0.0
  • 更新日期: 2024
  • Playwright版本: 最新稳定版
  • 支持平台: Windows, macOS, Linux

  • Version: 2.0.0
  • Update Date: 2024
  • Playwright Version: Latest stable version
  • Supported Platforms: Windows, macOS, Linux

技术支持

Technical Support

如遇到问题,请检查:
  1. Playwright是否正确安装
  2. 浏览器驱动是否已下载
  3. 选择器是否正确
  4. 超时时间是否足够
  5. 网络连接是否正常
更多信息请参考:
If you encounter problems, please check:
  1. Whether Playwright is installed correctly
  2. Whether the browser driver has been downloaded
  3. Whether the selector is correct
  4. Whether the timeout period is sufficient
  5. Whether the network connection is normal
For more information, please refer to:
  • Playwright official documentation: https://playwright.dev
  • Project README documentation
  • Windows compatibility guide