playwright-browser
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePlaywright 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
- 启动浏览器 → 调用
browser_launch - 访问网页 → 调用
browser_goto - 执行操作 → 调用相应工具(点击、填写、提取等)
- 关闭浏览器 → 调用
browser_close
- Launch Browser → Call
browser_launch - Access Web Page → Call
browser_goto - Perform Operations → Call corresponding tools (click, fill, extract, etc.)
- Close Browser → Call
browser_close
常用工具快速参考
Common Tools Quick Reference
| 用户需求 | 调用工具 | 参数示例 |
|---|---|---|
| "访问网站" | | |
| "点击按钮" | | |
| "填写表单" | | |
| "获取标题" | | |
| "截图" | | |
| "获取文本" | | |
| "等待元素" | | |
| User Requirement | Tool to Invoke | Parameter Example |
|---|---|---|
| "Access a website" | | |
| "Click a button" | | |
| "Fill out a form" | | |
| "Get page title" | | |
| "Take a screenshot" | | |
| "Get text content" | | |
| "Wait for an element" | | |
完整示例:访问网页并获取标题
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
- 网页访问 - 访问任何网站,获取页面内容
- 内容提取 - 提取文本、链接、图片等信息
- 页面交互 - 点击按钮、填写表单、滚动页面
- 截图保存 - 对整个页面或特定元素截图
- 数据抓取 - 批量提取网页数据
- 自动化测试 - 模拟用户操作,测试网站功能
- Web page access - Access any website and get page content
- Content extraction - Extract text, links, images and other information
- Page interaction - Click buttons, fill forms, scroll pages
- Screenshot saving - Take screenshots of the entire page or specific elements
- Data scraping - Batch extract web page data
- 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 contentScenario 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 youScenario 3: Web page screenshot
You: Help me take a screenshot of the github.com homepage
Me: Will access the web page and save the screenshotScenario 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
- 必须先启动浏览器 - 使用任何其他工具前,必须先调用
browser_launch - 使用完毕要关闭 - 任务完成后,调用 释放资源
browser_close - 等待页面加载 - 访问网页后,使用 等待内容加载
browser_wait_for_selector - 选择器要准确 - 使用正确的 CSS 选择器来定位元素
- 处理错误 - 如果工具调用失败,检查参数是否正确
- Must launch the browser first - Before using any other tools, you must call first
browser_launch - Close after use - After the task is completed, call to release resources
browser_close - Wait for page loading - After accessing a web page, use to wait for content to load
browser_wait_for_selector - Selectors should be accurate - Use correct CSS selectors to locate elements
- 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
- 浏览器管理 (8个工具)
- 页面导航 (4个工具)
- 元素交互 (12个工具)
- 键盘鼠标操作 (8个工具)
- 内容提取 (11个工具)
- 高级选择器 (7个工具)
- 等待操作 (7个工具)
- 截图和PDF (3个工具)
- JavaScript执行 (3个工具)
- Cookie和存储 (8个工具)
- 网络控制 (7个工具)
- 文件操作 (2个工具)
- 视口和设备 (6个工具)
- 滚动操作 (2个工具)
- 性能指标 (3个工具)
- 无障碍功能 (1个工具)
- 时间控制 (5个工具)
- 权限管理 (2个工具)
- 对话框处理 (1个工具)
- Frame操作 (1个工具)
- Browser Management (8 tools)
- Page Navigation (4 tools)
- Element Interaction (12 tools)
- Keyboard and Mouse Operations (8 tools)
- Content Extraction (11 tools)
- Advanced Selectors (7 tools)
- Wait Operations (7 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 (6 tools)
- Scroll Operations (2 tools)
- Performance Metrics (3 tools)
- Accessibility Features (1 tool)
- Time Control (5 tools)
- Permission Management (2 tools)
- Dialog Handling (1 tool)
- Frame Operations (1 tool)
浏览器管理
Browser Management
browser_launch
browser_launch
启动浏览器实例(支持设备模拟、视频录制、追踪等高级功能)
参数:
- : 'chromium' | 'firefox' | 'webkit' (默认: 'chromium')
browserType - : boolean - 是否无头模式 (默认: true)
headless - : { width: number, height: number } - 视口大小
viewport - : string - 设备名称,如 'iPhone 13', 'Pixel 5'
deviceName - : boolean - 是否录制视频
recordVideo - : boolean - 是否记录追踪
recordTrace - : number - 慢动作延迟(毫秒)
slowMo
调用示例:
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:
- : 'chromium' | 'firefox' | 'webkit' (default: 'chromium')
browserType - : boolean - Whether to run in headless mode (default: true)
headless - : { width: number, height: number } - Viewport size
viewport - : string - Device name, e.g. 'iPhone 13', 'Pixel 5'
deviceName - : boolean - Whether to record video
recordVideo - : boolean - Whether to record tracing
recordTrace - : number - Slow motion delay (milliseconds)
slowMo
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
切换到指定索引的页面
参数:
- : number - 页面索引(从0开始)
index
调用示例:
json
{ "index": 1 }Switch to the page with the specified index
Parameters:
- : number - Page index (starts from 0)
index
Invocation Example:
json
{ "index": 1 }browser_close_page
browser_close_page
关闭指定索引的页面
参数:
- : number - 页面索引(可选,默认关闭当前页面)
index
调用示例:
json
{ "index": 0 }Close the page with the specified index
Parameters:
- : number - Page index (optional, closes the current page by default)
index
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
参数:
- : string - 目标URL(必需)
url - : 'load' | 'domcontentloaded' | 'networkidle' - 等待条件
waitUntil - : number - 超时时间(毫秒)
timeout
调用示例:
json
{
"url": "https://www.example.com",
"waitUntil": "networkidle",
"timeout": 30000
}Navigate to the specified URL
Parameters:
- : string - Target URL (required)
url - : 'load' | 'domcontentloaded' | 'networkidle' - Wait condition
waitUntil - : number - Timeout period (milliseconds)
timeout
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
点击页面元素
参数:
- : string - CSS选择器(必需)
selector - : number - 超时时间(毫秒)
timeout - : 'left' | 'right' | 'middle' - 鼠标按钮
button - : number - 点击次数
clickCount
调用示例:
json
{
"selector": "button.submit",
"button": "left",
"clickCount": 1
}Click a page element
Parameters:
- : string - CSS selector (required)
selector - : number - Timeout period (milliseconds)
timeout - : 'left' | 'right' | 'middle' - Mouse button
button - : number - Number of clicks
clickCount
Invocation Example:
json
{
"selector": "button.submit",
"button": "left",
"clickCount": 1
}browser_dblclick
browser_dblclick
双击元素
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": ".item" }Double-click an element
Parameters:
- : string - CSS selector (required)
selector
Invocation Example:
json
{ "selector": ".item" }browser_hover
browser_hover
鼠标悬停在元素上
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": ".menu-item" }Hover the mouse over an element
Parameters:
- : string - CSS selector (required)
selector
Invocation Example:
json
{ "selector": ".menu-item" }browser_fill
browser_fill
填写表单字段(清空后填入)
参数:
- : string - CSS选择器(必需)
selector - : string - 要填写的值(必需)
value
调用示例:
json
{
"selector": "#username",
"value": "user@example.com"
}Fill in a form field (clears first then fills)
Parameters:
- : string - CSS selector (required)
selector - : string - Value to fill in (required)
value
Invocation Example:
json
{
"selector": "#username",
"value": "user@example.com"
}browser_type
browser_type
逐字符输入文本(模拟真实键盘输入)
参数:
- : string - CSS选择器(必需)
selector - : string - 要输入的文本(必需)
text - : number - 每个字符间的延迟(毫秒)
delay
调用示例:
json
{
"selector": "#search",
"text": "playwright",
"delay": 100
}Enter text character by character (simulates real keyboard input)
Parameters:
- : string - CSS selector (required)
selector - : string - Text to enter (required)
text - : number - Delay between each character (milliseconds)
delay
Invocation Example:
json
{
"selector": "#search",
"text": "playwright",
"delay": 100
}browser_press
browser_press
按下键盘按键
参数:
- : string - CSS选择器(必需)
selector - : string - 按键名称(如 'Enter', 'Tab', 'Escape')
key
调用示例:
json
{
"selector": "#search",
"key": "Enter"
}Press a keyboard key
Parameters:
- : string - CSS selector (required)
selector - : string - Key name (e.g. 'Enter', 'Tab', 'Escape')
key
Invocation Example:
json
{
"selector": "#search",
"key": "Enter"
}browser_select
browser_select
选择下拉框选项
参数:
- : string - CSS选择器(必需)
selector - : string | string[] - 选项值(必需)
value
调用示例:
json
{
"selector": "select#country",
"value": "US"
}Select a dropdown option
Parameters:
- : string - CSS selector (required)
selector - : string | string[] - Option value(s) (required)
value
Invocation Example:
json
{
"selector": "select#country",
"value": "US"
}browser_check
browser_check
勾选复选框
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": "#agree-terms" }Check a checkbox
Parameters:
- : string - CSS selector (required)
selector
Invocation Example:
json
{ "selector": "#agree-terms" }browser_uncheck
browser_uncheck
取消勾选复选框
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": "#newsletter" }Uncheck a checkbox
Parameters:
- : string - CSS selector (required)
selector
Invocation Example:
json
{ "selector": "#newsletter" }browser_focus
browser_focus
聚焦到元素
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": "#email" }Focus on an element
Parameters:
- : string - CSS selector (required)
selector
Invocation Example:
json
{ "selector": "#email" }browser_drag
browser_drag
拖拽元素到目标位置
参数:
- : string - 源元素选择器(必需)
sourceSelector - : string - 目标元素选择器(必需)
targetSelector
调用示例:
json
{
"sourceSelector": ".draggable",
"targetSelector": ".drop-zone"
}Drag an element to the target position
Parameters:
- : string - Source element selector (required)
sourceSelector - : string - Target element selector (required)
targetSelector
Invocation Example:
json
{
"sourceSelector": ".draggable",
"targetSelector": ".drop-zone"
}browser_tap
browser_tap
触摸点击(移动端)
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": ".mobile-button" }Touch click (for mobile devices)
Parameters:
- : string - CSS selector (required)
selector
Invocation Example:
json
{ "selector": ".mobile-button" }键盘鼠标操作
Keyboard and Mouse Operations
browser_keyboard_down
browser_keyboard_down
按下键盘按键(不释放)
参数:
- : string - 按键名称(必需)
key
调用示例:
json
{ "key": "Shift" }Press a keyboard key (without releasing)
Parameters:
- : string - Key name (required)
key
Invocation Example:
json
{ "key": "Shift" }browser_keyboard_up
browser_keyboard_up
释放键盘按键
参数:
- : string - 按键名称(必需)
key
调用示例:
json
{ "key": "Shift" }Release a keyboard key
Parameters:
- : string - Key name (required)
key
Invocation Example:
json
{ "key": "Shift" }browser_mouse_move
browser_mouse_move
移动鼠标到指定坐标
参数:
- : number - X坐标(必需)
x - : number - Y坐标(必需)
y - : number - 移动步数(平滑移动)
steps
调用示例:
json
{
"x": 100,
"y": 200,
"steps": 10
}Move the mouse to the specified coordinates
Parameters:
- : number - X coordinate (required)
x - : number - Y coordinate (required)
y - : number - Number of movement steps (for smooth movement)
steps
Invocation Example:
json
{
"x": 100,
"y": 200,
"steps": 10
}browser_mouse_click
browser_mouse_click
在指定坐标点击鼠标
参数:
- : number - X坐标(必需)
x - : number - Y坐标(必需)
y
调用示例:
json
{
"x": 150,
"y": 250
}Click the mouse at the specified coordinates
Parameters:
- : number - X coordinate (required)
x - : number - Y coordinate (required)
y
Invocation Example:
json
{
"x": 150,
"y": 250
}browser_mouse_wheel
browser_mouse_wheel
鼠标滚轮滚动
参数:
- : number - 水平滚动量(必需)
deltaX - : number - 垂直滚动量(必需)
deltaY
调用示例:
json
{
"deltaX": 0,
"deltaY": 100
}Scroll with the mouse wheel
Parameters:
- : number - Horizontal scroll amount (required)
deltaX - : number - Vertical scroll amount (required)
deltaY
Invocation Example:
json
{
"deltaX": 0,
"deltaY": 100
}browser_mouse_down
browser_mouse_down
按下鼠标按键(不释放)
参数:
- : 'left' | 'right' | 'middle' - 鼠标按键
button - : number - 点击次数
clickCount
调用示例:
json
{
"button": "left",
"clickCount": 1
}Press a mouse button (without releasing)
Parameters:
- : 'left' | 'right' | 'middle' - Mouse button
button - : number - Number of clicks
clickCount
Invocation Example:
json
{
"button": "left",
"clickCount": 1
}browser_mouse_up
browser_mouse_up
释放鼠标按键
参数:
- : 'left' | 'right' | 'middle' - 鼠标按键
button - : number - 点击次数
clickCount
调用示例:
json
{
"button": "left",
"clickCount": 1
}Release a mouse button
Parameters:
- : 'left' | 'right' | 'middle' - Mouse button
button - : number - Number of clicks
clickCount
Invocation Example:
json
{
"button": "left",
"clickCount": 1
}browser_keyboard_insert_text
browser_keyboard_insert_text
插入文本(不触发键盘事件,直接设置值)
参数:
- : string - 要插入的文本(必需)
text
调用示例:
json
{
"text": "Hello World"
}Insert text (does not trigger keyboard events, sets value directly)
Parameters:
- : string - Text to insert (required)
text
Invocation Example:
json
{
"text": "Hello World"
}内容提取
Content Extraction
browser_get_text
browser_get_text
获取元素的文本内容
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": "h1.title" }Get the text content of an element
Parameters:
- : string - CSS selector (required)
selector
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
获取元素的属性值
参数:
- : string - CSS选择器(必需)
selector - : string - 属性名称(必需)
attribute
调用示例:
json
{
"selector": "img.logo",
"attribute": "src"
}Get the attribute value of an element
Parameters:
- : string - CSS selector (required)
selector - : string - Attribute name (required)
attribute
Invocation Example:
json
{
"selector": "img.logo",
"attribute": "src"
}browser_get_input_value
browser_get_input_value
获取输入框的值
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": "#email" }Get the value of an input box
Parameters:
- : string - CSS selector (required)
selector
Invocation Example:
json
{ "selector": "#email" }browser_is_visible
browser_is_visible
检查元素是否可见
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": ".modal" }Check if an element is visible
Parameters:
- : string - CSS selector (required)
selector
Invocation Example:
json
{ "selector": ".modal" }browser_is_enabled
browser_is_enabled
检查元素是否启用
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": "button.submit" }Check if an element is enabled
Parameters:
- : string - CSS selector (required)
selector
Invocation Example:
json
{ "selector": "button.submit" }browser_is_checked
browser_is_checked
检查复选框/单选框是否选中
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": "#agree" }Check if a checkbox/radio button is selected
Parameters:
- : string - CSS selector (required)
selector
Invocation Example:
json
{ "selector": "#agree" }browser_count
browser_count
统计匹配选择器的元素数量
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": ".product-item" }Count the number of elements matching the selector
Parameters:
- : string - CSS selector (required)
selector
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角色查找元素
参数:
- : string - ARIA角色(必需)
role - : string - 可访问名称
name
调用示例:
json
{
"role": "button",
"name": "Submit"
}Find elements by ARIA role
Parameters:
- : string - ARIA role (required)
role - : string - Accessible name
name
Invocation Example:
json
{
"role": "button",
"name": "Submit"
}browser_get_by_text
browser_get_by_text
通过文本内容查找元素
参数:
- : string - 文本内容(必需)
text - : boolean - 是否精确匹配
exact
调用示例:
json
{
"text": "Sign In",
"exact": true
}Find elements by text content
Parameters:
- : string - Text content (required)
text - : boolean - Whether to match exactly
exact
Invocation Example:
json
{
"text": "Sign In",
"exact": true
}browser_get_by_label
browser_get_by_label
通过标签文本查找表单元素
参数:
- : string - 标签文本(必需)
text - : boolean - 是否精确匹配
exact
调用示例:
json
{
"text": "Email Address",
"exact": false
}Find form elements by label text
Parameters:
- : string - Label text (required)
text - : boolean - Whether to match exactly
exact
Invocation Example:
json
{
"text": "Email Address",
"exact": false
}browser_get_by_placeholder
browser_get_by_placeholder
通过占位符文本查找输入框
参数:
- : string - 占位符文本(必需)
text - : boolean - 是否精确匹配
exact
调用示例:
json
{
"text": "Enter your email",
"exact": false
}Find input boxes by placeholder text
Parameters:
- : string - Placeholder text (required)
text - : boolean - Whether to match exactly
exact
Invocation Example:
json
{
"text": "Enter your email",
"exact": false
}browser_get_by_test_id
browser_get_by_test_id
通过测试ID查找元素
参数:
- : string - 测试ID(必需)
testId
调用示例:
json
{ "testId": "submit-button" }Find elements by test ID
Parameters:
- : string - Test ID (required)
testId
Invocation Example:
json
{ "testId": "submit-button" }browser_get_by_alt_text
browser_get_by_alt_text
通过alt属性文本查找图片元素
参数:
- : string - alt文本(必需)
text - : boolean - 是否精确匹配
exact
调用示例:
json
{
"text": "Company Logo",
"exact": false
}Find image elements by alt attribute text
Parameters:
- : string - Alt text (required)
text - : boolean - Whether to match exactly
exact
Invocation Example:
json
{
"text": "Company Logo",
"exact": false
}browser_get_by_title
browser_get_by_title
通过title属性查找元素
参数:
- : string - title文本(必需)
text - : boolean - 是否精确匹配
exact
调用示例:
json
{
"text": "Click to expand",
"exact": false
}Find elements by title attribute
Parameters:
- : string - Title text (required)
text - : boolean - Whether to match exactly
exact
Invocation Example:
json
{
"text": "Click to expand",
"exact": false
}等待操作
Wait Operations
browser_wait_for_selector
browser_wait_for_selector
等待元素出现在DOM中
参数:
- : string - CSS选择器(必需)
selector - : number - 超时时间(毫秒)
timeout - : 'attached' | 'visible' | 'hidden' - 等待状态
state
调用示例:
json
{
"selector": ".loading-complete",
"timeout": 10000,
"state": "visible"
}Wait for an element to appear in the DOM
Parameters:
- : string - CSS selector (required)
selector - : number - Timeout period (milliseconds)
timeout - : 'attached' | 'visible' | 'hidden' - Wait state
state
Invocation Example:
json
{
"selector": ".loading-complete",
"timeout": 10000,
"state": "visible"
}browser_wait_for_timeout
browser_wait_for_timeout
等待指定时间
参数:
- : number - 等待时间(毫秒,必需)
timeout
调用示例:
json
{ "timeout": 3000 }Wait for a specified period of time
Parameters:
- : number - Wait time (milliseconds, required)
timeout
Invocation Example:
json
{ "timeout": 3000 }browser_wait_for_url
browser_wait_for_url
等待URL匹配指定模式
参数:
- : string - URL模式(必需)
url - : number - 超时时间(毫秒)
timeout
调用示例:
json
{
"url": "https://example.com/dashboard",
"timeout": 5000
}Wait for the URL to match the specified pattern
Parameters:
- : string - URL pattern (required)
url - : number - Timeout period (milliseconds)
timeout
Invocation Example:
json
{
"url": "https://example.com/dashboard",
"timeout": 5000
}browser_wait_for_request
browser_wait_for_request
等待网络请求
参数:
- : string - URL模式(必需)
urlPattern - : number - 超时时间(毫秒)
timeout
调用示例:
json
{
"urlPattern": "**/api/users",
"timeout": 10000
}Wait for a network request
Parameters:
- : string - URL pattern (required)
urlPattern - : number - Timeout period (milliseconds)
timeout
Invocation Example:
json
{
"urlPattern": "**/api/users",
"timeout": 10000
}browser_wait_for_response
browser_wait_for_response
等待网络响应
参数:
- : string - URL模式(必需)
urlPattern - : number - 超时时间(毫秒)
timeout
调用示例:
json
{
"urlPattern": "**/api/data",
"timeout": 10000
}Wait for a network response
Parameters:
- : string - URL pattern (required)
urlPattern - : number - Timeout period (milliseconds)
timeout
Invocation Example:
json
{
"urlPattern": "**/api/data",
"timeout": 10000
}browser_wait_for_function
browser_wait_for_function
等待JavaScript函数返回true
参数:
- : string - JavaScript函数代码(必需)
fn - : any - 传递给函数的参数
arg - : number - 超时时间(毫秒)
timeout - : number - 轮询间隔(毫秒)
polling
调用示例:
json
{
"fn": "() => document.readyState === 'complete'",
"timeout": 5000,
"polling": 100
}Wait for a JavaScript function to return true
Parameters:
- : string - JavaScript function code (required)
fn - : any - Parameters passed to the function
arg - : number - Timeout period (milliseconds)
timeout - : number - Polling interval (milliseconds)
polling
Invocation Example:
json
{
"fn": "() => document.readyState === 'complete'",
"timeout": 5000,
"polling": 100
}browser_wait_for_load_state
browser_wait_for_load_state
等待页面加载到指定状态
参数:
- : 'load' | 'domcontentloaded' | 'networkidle' - 加载状态(必需)
state - : number - 超时时间(毫秒)
timeout
调用示例:
json
{
"state": "networkidle",
"timeout": 30000
}Wait for the page to load to the specified state
Parameters:
- : 'load' | 'domcontentloaded' | 'networkidle' - Load state (required)
state - : number - Timeout period (milliseconds)
timeout
Invocation Example:
json
{
"state": "networkidle",
"timeout": 30000
}截图和PDF
Screenshots and PDF
browser_screenshot
browser_screenshot
截取页面截图
参数:
- : string - 保存路径
path - : boolean - 是否截取整页
fullPage - : 'png' | 'jpeg' - 图片格式
type - : number - 图片质量(0-100,仅JPEG)
quality
调用示例:
json
{
"path": "screenshot.png",
"fullPage": true,
"type": "png"
}Take a page screenshot
Parameters:
- : string - Save path
path - : boolean - Whether to capture the full page
fullPage - : 'png' | 'jpeg' - Image format
type - : number - Image quality (0-100, only for JPEG)
quality
Invocation Example:
json
{
"path": "screenshot.png",
"fullPage": true,
"type": "png"
}browser_screenshot_element
browser_screenshot_element
截取指定元素的截图
参数:
- : string - CSS选择器(必需)
selector - : string - 保存路径
path
调用示例:
json
{
"selector": ".chart",
"path": "chart.png"
}Take a screenshot of a specified element
Parameters:
- : string - CSS selector (required)
selector - : string - Save path
path
Invocation Example:
json
{
"selector": ".chart",
"path": "chart.png"
}browser_pdf
browser_pdf
生成页面PDF
参数:
- : string - 保存路径
path - : string - 纸张格式(如 'A4', 'Letter')
format - : boolean - 是否打印背景
printBackground
调用示例:
json
{
"path": "page.pdf",
"format": "A4",
"printBackground": true
}Generate a page PDF
Parameters:
- : string - Save path
path - : string - Paper format (e.g. 'A4', 'Letter')
format - : boolean - Whether to print background
printBackground
Invocation Example:
json
{
"path": "page.pdf",
"format": "A4",
"printBackground": true
}JavaScript执行
JavaScript Execution
browser_evaluate
browser_evaluate
在页面上下文中执行JavaScript代码
参数:
- : string - JavaScript代码(必需)
script - : any - 传递给脚本的参数
arg
调用示例:
json
{
"script": "document.querySelectorAll('h2').length"
}Execute JavaScript code in the page context
Parameters:
- : string - JavaScript code (required)
script - : any - Parameters passed to the script
arg
Invocation Example:
json
{
"script": "document.querySelectorAll('h2').length"
}browser_add_script_tag
browser_add_script_tag
向页面添加脚本标签
参数:
- : string - 脚本URL
url - : string - 脚本内容
content
调用示例:
json
{
"url": "https://cdn.example.com/library.js"
}Add a script tag to the page
Parameters:
- : string - Script URL
url - : string - Script content
content
Invocation Example:
json
{
"url": "https://cdn.example.com/library.js"
}browser_add_style_tag
browser_add_style_tag
向页面添加样式标签
参数:
- : string - 样式URL
url - : string - 样式内容
content
调用示例:
json
{
"content": "body { background: red; }"
}Add a style tag to the page
Parameters:
- : string - Style URL
url - : string - Style content
content
Invocation Example:
json
{
"content": "body { background: red; }"
}Cookie和存储
Cookie and Storage
browser_set_cookies
browser_set_cookies
设置一个或多个Cookie
参数:
- : array - Cookie数组(必需)
cookies- : string - Cookie名称
name - : string - Cookie值
value - : string - 域名
domain - : string - 路径
path
调用示例:
json
{
"cookies": [
{
"name": "session",
"value": "abc123",
"domain": "example.com",
"path": "/"
}
]
}Set one or more cookies
Parameters:
- : array - Cookie array (required)
cookies- : string - Cookie name
name - : string - Cookie value
value - : string - Domain name
domain - : string - Path
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项
参数:
- : string - 键名(必需)
key - : string - 值(必需)
value
调用示例:
json
{
"key": "theme",
"value": "dark"
}Set LocalStorage item
Parameters:
- : string - Key name (required)
key - : string - Value (required)
value
Invocation Example:
json
{
"key": "theme",
"value": "dark"
}browser_get_local_storage
browser_get_local_storage
获取LocalStorage项
参数:
- : string - 键名(可选,不提供则返回所有)
key
调用示例:
json
{ "key": "theme" }Get LocalStorage item
Parameters:
- : string - Key name (optional, returns all items if not provided)
key
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)
参数:
- : string - 保存路径
path
调用示例:
json
{ "path": "storage.json" }Save storage state (Cookie and LocalStorage)
Parameters:
- : string - Save path
path
Invocation Example:
json
{ "path": "storage.json" }browser_restore_storage_state
browser_restore_storage_state
恢复存储状态
参数:
- : object - 存储状态对象(必需)
state
调用示例:
json
{
"state": { "cookies": [], "origins": [] }
}Restore storage state
Parameters:
- : object - Storage state object (required)
state
Invocation Example:
json
{
"state": { "cookies": [], "origins": [] }
}网络控制
Network Control
browser_set_offline
browser_set_offline
设置离线模式
参数:
- : boolean - 是否离线(必需)
offline
调用示例:
json
{ "offline": true }Set offline mode
Parameters:
- : boolean - Whether to be offline (required)
offline
Invocation Example:
json
{ "offline": true }browser_block_requests
browser_block_requests
拦截匹配模式的请求
参数:
- : array - URL模式数组(必需)
patterns
调用示例:
json
{
"patterns": ["*.jpg", "*.png", "*/ads/*"]
}Block requests matching the pattern
Parameters:
- : array - URL pattern array (required)
patterns
Invocation Example:
json
{
"patterns": ["*.jpg", "*.png", "*/ads/*"]
}browser_mock_response
browser_mock_response
模拟网络响应
参数:
- : string - URL模式(必需)
urlPattern - : object - 响应对象(必需)
response- : number - 状态码
status - : string - 响应体
body - : string - 内容类型
contentType
调用示例:
json
{
"urlPattern": "**/api/users",
"response": {
"status": 200,
"body": "{\"users\": []}",
"contentType": "application/json"
}
}Mock network response
Parameters:
- : string - URL pattern (required)
urlPattern - : object - Response object (required)
response- : number - Status code
status - : string - Response body
body - : string - Content type
contentType
Invocation Example:
json
{
"urlPattern": "**/api/users",
"response": {
"status": 200,
"body": "{\"users\": []}",
"contentType": "application/json"
}
}browser_get_request_logs
browser_get_request_logs
获取请求日志
参数:
- : number - 限制数量
limit
调用示例:
json
{ "limit": 50 }Get request logs
Parameters:
- : number - Limit number
limit
Invocation Example:
json
{ "limit": 50 }browser_get_response_logs
browser_get_response_logs
获取响应日志
参数:
- : number - 限制数量
limit
调用示例:
json
{ "limit": 50 }Get response logs
Parameters:
- : number - Limit number
limit
Invocation Example:
json
{ "limit": 50 }browser_get_console_logs
browser_get_console_logs
获取控制台日志
参数:
- : number - 限制数量
limit
调用示例:
json
{ "limit": 100 }Get console logs
Parameters:
- : number - Limit number
limit
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
上传文件到文件输入框
参数:
- : string - 文件输入框选择器(必需)
selector - : string | array - 文件路径(必需)
filePath
调用示例:
json
{
"selector": "input[type='file']",
"filePath": "C:\\Users\\Admin\\document.pdf"
}Upload files to a file input box
Parameters:
- : string - File input box selector (required)
selector - : string | array - File path(s) (required)
filePath
Invocation Example:
json
{
"selector": "input[type='file']",
"filePath": "C:\\Users\\Admin\\document.pdf"
}browser_download_file
browser_download_file
触发文件下载
参数:
- : string - 触发下载的元素选择器(必需)
triggerSelector
调用示例:
json
{ "triggerSelector": "a.download-link" }Trigger file download
Parameters:
- : string - Selector of the element that triggers download (required)
triggerSelector
Invocation Example:
json
{ "triggerSelector": "a.download-link" }视口和设备
Viewport and Device
browser_set_viewport_size
browser_set_viewport_size
设置视口大小
参数:
- : number - 宽度(必需)
width - : number - 高度(必需)
height
调用示例:
json
{
"width": 1920,
"height": 1080
}Set viewport size
Parameters:
- : number - Width (required)
width - : number - Height (required)
height
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
模拟媒体类型和配色方案
参数:
- : 'light' | 'dark' | 'no-preference' - 配色方案
colorScheme - : 'screen' | 'print' - 媒体类型
media
调用示例:
json
{
"colorScheme": "dark",
"media": "screen"
}Emulate media type and color scheme
Parameters:
- : 'light' | 'dark' | 'no-preference' - Color scheme
colorScheme - : 'screen' | 'print' - Media type
media
Invocation Example:
json
{
"colorScheme": "dark",
"media": "screen"
}browser_set_geolocation
browser_set_geolocation
设置地理位置
参数:
- : number - 纬度(必需)
latitude - : number - 经度(必需)
longitude - : number - 精度
accuracy
调用示例:
json
{
"latitude": 37.7749,
"longitude": -122.4194,
"accuracy": 100
}Set geolocation
Parameters:
- : number - Latitude (required)
latitude - : number - Longitude (required)
longitude - : number - Accuracy
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
触摸屏点击指定坐标(移动端)
参数:
- : number - X坐标(必需)
x - : number - Y坐标(必需)
y
调用示例:
json
{
"x": 100,
"y": 200
}Tap on the touchscreen at specified coordinates (for mobile devices)
Parameters:
- : number - X coordinate (required)
x - : number - Y coordinate (required)
y
Invocation Example:
json
{
"x": 100,
"y": 200
}滚动操作
Scroll Operations
browser_scroll_to
browser_scroll_to
滚动到指定坐标
参数:
- : number - X坐标(必需)
x - : number - Y坐标(必需)
y
调用示例:
json
{
"x": 0,
"y": 1000
}Scroll to specified coordinates
Parameters:
- : number - X coordinate (required)
x - : number - Y coordinate (required)
y
Invocation Example:
json
{
"x": 0,
"y": 1000
}browser_scroll_into_view
browser_scroll_into_view
滚动元素到可见区域
参数:
- : string - CSS选择器(必需)
selector
调用示例:
json
{ "selector": "#footer" }Scroll an element into the visible area
Parameters:
- : string - CSS selector (required)
selector
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
获取页面无障碍树快照
参数:
- : string - 限定范围的选择器(可选)
selector
调用示例:
json
{ "selector": "main" }Get page accessibility tree snapshot
Parameters:
- : string - Selector to limit the scope (optional)
selector
Invocation Example:
json
{ "selector": "main" }时间控制
Time Control
browser_install_clock
browser_install_clock
安装时钟控制(用于测试时间相关功能)
参数:
- : number | string - 初始时间
time
调用示例:
json
{ "time": 1609459200000 }Install clock control (for testing time-related functions)
Parameters:
- : number | string - Initial time
time
Invocation Example:
json
{ "time": 1609459200000 }browser_set_system_time
browser_set_system_time
设置系统时间
参数:
- : number | string - 时间戳或日期字符串(必需)
time
调用示例:
json
{ "time": "2024-01-01T00:00:00Z" }Set system time
Parameters:
- : number | string - Timestamp or date string (required)
time
Invocation Example:
json
{ "time": "2024-01-01T00:00:00Z" }browser_fast_forward
browser_fast_forward
快进时间
参数:
- : number - 快进的毫秒数(必需)
time
调用示例:
json
{ "time": 60000 }Fast forward time
Parameters:
- : number - Milliseconds to fast forward (required)
time
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
授予浏览器权限
参数:
- : array - 权限列表(必需)
permissions- 可选值: 'geolocation', 'notifications', 'camera', 'microphone', 'clipboard-read', 'clipboard-write'
- : string - 限定域名
origin
调用示例:
json
{
"permissions": ["geolocation", "notifications"],
"origin": "https://example.com"
}Grant browser permissions
Parameters:
- : array - Permission list (required)
permissions- Optional values: 'geolocation', 'notifications', 'camera', 'microphone', 'clipboard-read', 'clipboard-write'
- : string - Limited domain name
origin
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)
参数:
- : 'accept' | 'dismiss' - 操作类型(必需)
action - : string - prompt对话框的输入文本
promptText
调用示例:
json
{
"action": "accept",
"promptText": "My Input"
}Handle JavaScript dialogs (alert, confirm, prompt)
Parameters:
- : 'accept' | 'dismiss' - Operation type (required)
action - : string - Input text for prompt dialogs
promptText
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 上有什么"
我会做:
- 启动浏览器
- 访问 example.com
- 提取页面标题和主要内容
- 总结并告诉你
You say: "Help me see what is on example.com"
What I will do:
- Launch the browser
- Access example.com
- Extract the page title and main content
- Summarize and tell you
场景 2:搜索信息
Scenario 2: Search for information
你说: "在百度搜索 'OpenClaw 使用教程'"
我会做:
- 启动浏览器
- 访问百度
- 在搜索框输入关键词
- 点击搜索按钮
- 提取搜索结果
You say: "Search for 'OpenClaw tutorial' on Baidu"
What I will do:
- Launch the browser
- Access Baidu
- Enter keywords in the search box
- Click the search button
- Extract search results
场景 3:提取数据
Scenario 3: Extract data
你说: "从 news.ycombinator.com 提取前10条新闻标题"
我会做:
- 访问 Hacker News
- 定位新闻列表
- 提取标题和链接
- 整理成列表返回给你
You say: "Extract the first 10 news titles from news.ycombinator.com"
What I will do:
- Access Hacker News
- Locate the news list
- Extract titles and links
- Organize into a list and return to you
场景 4:网页截图
Scenario 4: Web page screenshot
你说: "帮我截取 github.com 首页的截图"
我会做:
- 访问 GitHub
- 等待页面加载完成
- 截取整页截图
- 保存并告诉你文件位置
You say: "Help me take a screenshot of the github.com homepage"
What I will do:
- Access GitHub
- Wait for the page to load completely
- Take a full-page screenshot
- Save and tell you the file location
场景 5:表单操作
Scenario 5: Form operation
你说: "帮我在这个登录页面输入用户名和密码"
我会做:
- 找到用户名输入框
- 填写用户名
- 找到密码输入框
- 填写密码
- 询问是否需要点击登录按钮
You say: "Help me enter username and password on this login page"
What I will do:
- Find the username input box
- Fill in the username
- Find the password input box
- Fill in the password
- Ask if you need to click the login button
场景 6:监控网页变化
Scenario 6: Monitor web page changes
你说: "每隔5分钟检查一次这个网页的价格"
我会做:
- 定期访问网页
- 提取价格信息
- 与上次对比
- 如有变化立即通知你
You say: "Check the price of this web page every 5 minutes"
What I will do:
- Access the web page regularly
- Extract price information
- Compare with the last time
- 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 - - Esc键
Escape - - 退格键
Backspace - - 删除键
Delete - ,
ArrowUp,ArrowDown,ArrowLeft- 方向键ArrowRight - ,
Home- Home/End键End - ,
PageUp- 翻页键PageDown - ,
Control,Shift,Alt- 修饰键Meta - -
F1- 功能键F12
- - Enter key
Enter - - Tab key
Tab - - Esc key
Escape - - Backspace key
Backspace - - Delete key
Delete - ,
ArrowUp,ArrowDown,ArrowLeft- Arrow keysArrowRight - ,
Home- Home/End keysEnd - ,
PageUp- Page up/down keysPageDown - ,
Control,Shift,Alt- Modifier keysMeta - -
F1- Function keysF12
错误处理和最佳实践
Error Handling and Best Practices
1. 浏览器生命周期管理
1. Browser Lifecycle Management
- 使用前必须先调用 启动浏览器
browser_launch - 使用完毕后应调用 释放资源
browser_close - 浏览器未启动时调用其他方法会抛出错误
- You must call to launch the browser before use
browser_launch - You should call to release resources after use
browser_close - 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 to ensure elements are loaded
browser_wait_for_selector - Set a reasonable timeout period (default 30 seconds)
- Use to wait for network requests to complete
waitUntil: 'networkidle'
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 to improve execution speed
headless: true - Use to block unnecessary resources (images, ads)
browser_block_requests - Set a reasonable viewport size to avoid overly large screenshots
5. 调试技巧
5. Debugging Tips
- 使用 查看浏览器操作过程
headless: false - 使用 参数减慢操作速度
slowMo - 使用 查看页面错误
browser_get_console_logs - 使用 和
recordVideo记录操作过程recordTrace
- Use to view the browser operation process
headless: false - Use the parameter to slow down the operation speed
slowMo - Use to view page errors
browser_get_console_logs - Use and
recordVideoto record the operation processrecordTrace
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
-
路径格式:Windows系统使用双反斜杠或正斜杠
\\/- 正确:或
C:\\Users\\Admin\\file.pdfC:/Users/Admin/file.pdf - 错误:
C:\Users\Admin\file.pdf
- 正确:
-
超时设置:默认超时为30秒,可根据需要调整
- 网络慢时增加超时时间
- 快速操作可减少超时时间
-
截图返回:截图返回base64编码的图片数据
- 可保存到文件或直接使用
-
Cookie域名:设置Cookie时必须指定正确的域名
- 域名必须与当前页面匹配
-
JavaScript执行:evaluate中的代码在页面上下文执行
- 可访问页面的DOM和全局变量
- 返回值必须是可序列化的
-
设备模拟:支持的设备名称参考Playwright设备列表
- 常用:'iPhone 13', 'Pixel 5', 'iPad Pro'
-
权限授予:某些功能需要先授予权限
- 地理位置需要 'geolocation' 权限
- 通知需要 'notifications' 权限
-
Path format: Use double backslashesor forward slashes
\\for Windows systems/- Correct: or
C:\\Users\\Admin\\file.pdfC:/Users/Admin/file.pdf - Incorrect:
C:\Users\Admin\file.pdf
- Correct:
-
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
-
Screenshot return: Screenshots return base64 encoded image data
- Can be saved to a file or used directly
-
Cookie domain: The correct domain must be specified when setting cookies
- The domain must match the current page
-
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
-
Device simulation: Refer to the Playwright device list for supported device names
- Common: 'iPhone 13', 'Pixel 5', 'iPad Pro'
-
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
如遇到问题,请检查:
- Playwright是否正确安装
- 浏览器驱动是否已下载
- 选择器是否正确
- 超时时间是否足够
- 网络连接是否正常
更多信息请参考:
- Playwright官方文档:https://playwright.dev
- 项目README文档
- Windows兼容性指南
If you encounter problems, please check:
- Whether Playwright is installed correctly
- Whether the browser driver has been downloaded
- Whether the selector is correct
- Whether the timeout period is sufficient
- Whether the network connection is normal
For more information, please refer to:
- Playwright official documentation: https://playwright.dev
- Project README documentation
- Windows compatibility guide