Playwright Browser Skill - Browser Automation Skill
⚡ AI Invocation Guide (Required Reading for OpenClaw)
How to Invoke MCP Tools
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
- Launch Browser → Call
- Access Web Page → Call
- Perform Operations → Call corresponding tools (click, fill, extract, etc.)
- Close Browser → Call
Common Tools Quick Reference
| User Requirement | Tool to Invoke | Parameter Example |
|---|
| "Access a website" | | { "url": "https://example.com" }
|
| "Click a button" | | { "selector": "button.submit" }
|
| "Fill out a form" | | { "selector": "#username", "value": "admin" }
|
| "Get page title" | | |
| "Take a screenshot" | | { "path": "screenshot.png", "fullPage": true }
|
| "Get text content" | | |
| "Wait for an element" | browser_wait_for_selector
| { "selector": ".content" }
|
Complete Example: Access a web page and get its title
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
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
- ✅ 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
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
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
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
🔧 Tool Invocation Guide (For OpenClaw)
Basic Invocation Process
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. Launch Browser
json
{
"tool": "browser_launch",
"arguments": {
"browserType": "chromium",
"headless": false
}
}
2. Access Web Page
json
{
"tool": "browser_goto",
"arguments": {
"url": "https://example.com"
}
}
3. Get Page Title
json
{
"tool": "browser_get_title",
"arguments": {}
}
4. Get Page Text
json
{
"tool": "browser_get_text",
"arguments": {
"selector": "body"
}
}
5. Click Element
json
{
"tool": "browser_click",
"arguments": {
"selector": "button.submit"
}
}
6. Fill Form
json
{
"tool": "browser_fill",
"arguments": {
"selector": "#username",
"value": "user@example.com"
}
}
7. Take Screenshot
json
{
"tool": "browser_screenshot",
"arguments": {
"path": "screenshot.png",
"fullPage": true
}
}
8. Get All Links
json
{
"tool": "browser_get_links",
"arguments": {}
}
9. Wait for Element
json
{
"tool": "browser_wait_for_selector",
"arguments": {
"selector": ".content",
"timeout": 10000
}
}
10. Close Browser
json
{
"tool": "browser_close",
"arguments": {}
}
Complete Task Examples
Example 1: Access web page and extract title
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: {}
Example 2: Search and extract results
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: {}
Example 3: Extract web page data
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
- Must launch the browser first - Before using any other tools, you must call first
- Close after use - After the task is completed, call to release resources
- Wait for page loading - After accessing a web page, use
browser_wait_for_selector
to wait for content to load
- 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
- 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
Launch a browser instance (supports advanced features such as device simulation, video recording, tracing, etc.)
Parameters:
- : 'chromium' | 'firefox' | 'webkit' (default: 'chromium')
- : boolean - Whether to run in headless mode (default: true)
- : { width: number, height: number } - Viewport size
- : string - Device name, e.g. 'iPhone 13', 'Pixel 5'
- : boolean - Whether to record video
- : boolean - Whether to record tracing
- : number - Slow motion delay (milliseconds)
Invocation Example:
json
{
"browserType": "chromium",
"headless": false,
"viewport": { "width": 1920, "height": 1080 },
"deviceName": "iPhone 13"
}
browser_close
Close the browser and release all resources
Parameters: None
Invocation Example:
browser_new_page
Create a new browser page (tab)
Parameters: None
Invocation Example:
browser_switch_page
Switch to the page with the specified index
Parameters:
- : number - Page index (starts from 0)
Invocation Example:
browser_close_page
Close the page with the specified index
Parameters:
- : number - Page index (optional, closes the current page by default)
Invocation Example:
browser_get_all_pages
Get a list of all open pages
Parameters: None
Invocation Example:
browser_get_version
Get browser version information
Parameters: None
Invocation Example:
browser_is_connected
Check browser connection status
Parameters: None
Invocation Example:
Page Navigation
browser_goto
Navigate to the specified URL
Parameters:
- : string - Target URL (required)
- : 'load' | 'domcontentloaded' | 'networkidle' - Wait condition
- : number - Timeout period (milliseconds)
Invocation Example:
json
{
"url": "https://www.example.com",
"waitUntil": "networkidle",
"timeout": 30000
}
browser_go_back
Go back to the previous page
Parameters: None
Invocation Example:
browser_go_forward
Go forward to the next page
Parameters: None
Invocation Example:
browser_reload
Refresh the current page
Parameters: None
Invocation Example:
Element Interaction
browser_click
Click a page element
Parameters:
- : string - CSS selector (required)
- : number - Timeout period (milliseconds)
- : 'left' | 'right' | 'middle' - Mouse button
- : number - Number of clicks
Invocation Example:
json
{
"selector": "button.submit",
"button": "left",
"clickCount": 1
}
browser_dblclick
Double-click an element
Parameters:
- : string - CSS selector (required)
Invocation Example:
browser_hover
Hover the mouse over an element
Parameters:
- : string - CSS selector (required)
Invocation Example:
json
{ "selector": ".menu-item" }
browser_fill
Fill in a form field (clears first then fills)
Parameters:
- : string - CSS selector (required)
- : string - Value to fill in (required)
Invocation Example:
json
{
"selector": "#username",
"value": "user@example.com"
}
browser_type
Enter text character by character (simulates real keyboard input)
Parameters:
- : string - CSS selector (required)
- : string - Text to enter (required)
- : number - Delay between each character (milliseconds)
Invocation Example:
json
{
"selector": "#search",
"text": "playwright",
"delay": 100
}
browser_press
Press a keyboard key
Parameters:
- : string - CSS selector (required)
- : string - Key name (e.g. 'Enter', 'Tab', 'Escape')
Invocation Example:
json
{
"selector": "#search",
"key": "Enter"
}
browser_select
Select a dropdown option
Parameters:
- : string - CSS selector (required)
- : string | string[] - Option value(s) (required)
Invocation Example:
json
{
"selector": "select#country",
"value": "US"
}
browser_check
Check a checkbox
Parameters:
- : string - CSS selector (required)
Invocation Example:
json
{ "selector": "#agree-terms" }
browser_uncheck
Uncheck a checkbox
Parameters:
- : string - CSS selector (required)
Invocation Example:
json
{ "selector": "#newsletter" }
browser_focus
Focus on an element
Parameters:
- : string - CSS selector (required)
Invocation Example:
browser_drag
Drag an element to the target position
Parameters:
- : string - Source element selector (required)
- : string - Target element selector (required)
Invocation Example:
json
{
"sourceSelector": ".draggable",
"targetSelector": ".drop-zone"
}
browser_tap
Touch click (for mobile devices)
Parameters:
- : string - CSS selector (required)
Invocation Example:
json
{ "selector": ".mobile-button" }
Keyboard and Mouse Operations
browser_keyboard_down
Press a keyboard key (without releasing)
Parameters:
- : string - Key name (required)
Invocation Example:
browser_keyboard_up
Release a keyboard key
Parameters:
- : string - Key name (required)
Invocation Example:
browser_mouse_move
Move the mouse to the specified coordinates
Parameters:
- : number - X coordinate (required)
- : number - Y coordinate (required)
- : number - Number of movement steps (for smooth movement)
Invocation Example:
json
{
"x": 100,
"y": 200,
"steps": 10
}
browser_mouse_click
Click the mouse at the specified coordinates
Parameters:
- : number - X coordinate (required)
- : number - Y coordinate (required)
Invocation Example:
browser_mouse_wheel
Scroll with the mouse wheel
Parameters:
- : number - Horizontal scroll amount (required)
- : number - Vertical scroll amount (required)
Invocation Example:
json
{
"deltaX": 0,
"deltaY": 100
}
browser_mouse_down
Press a mouse button (without releasing)
Parameters:
- : 'left' | 'right' | 'middle' - Mouse button
- : number - Number of clicks
Invocation Example:
json
{
"button": "left",
"clickCount": 1
}
browser_mouse_up
Release a mouse button
Parameters:
- : 'left' | 'right' | 'middle' - Mouse button
- : number - Number of clicks
Invocation Example:
json
{
"button": "left",
"clickCount": 1
}
browser_keyboard_insert_text
Insert text (does not trigger keyboard events, sets value directly)
Parameters:
- : string - Text to insert (required)
Invocation Example:
json
{
"text": "Hello World"
}
Content Extraction
browser_get_text
Get the text content of an element
Parameters:
- : string - CSS selector (required)
Invocation Example:
json
{ "selector": "h1.title" }
browser_get_title
Get the page title
Parameters: None
Invocation Example:
browser_get_html
Get the HTML content of the entire page
Parameters: None
Invocation Example:
browser_get_links
Get all links on the page
Parameters: None
Invocation Example:
browser_get_attribute
Get the attribute value of an element
Parameters:
- : string - CSS selector (required)
- : string - Attribute name (required)
Invocation Example:
json
{
"selector": "img.logo",
"attribute": "src"
}
browser_get_input_value
Get the value of an input box
Parameters:
- : string - CSS selector (required)
Invocation Example:
browser_is_visible
Check if an element is visible
Parameters:
- : string - CSS selector (required)
Invocation Example:
browser_is_enabled
Check if an element is enabled
Parameters:
- : string - CSS selector (required)
Invocation Example:
json
{ "selector": "button.submit" }
browser_is_checked
Check if a checkbox/radio button is selected
Parameters:
- : string - CSS selector (required)
Invocation Example:
browser_count
Count the number of elements matching the selector
Parameters:
- : string - CSS selector (required)
Invocation Example:
json
{ "selector": ".product-item" }
browser_get_current_url
Get the current page URL
Parameters: None
Invocation Example:
Advanced Selectors
browser_get_by_role
Find elements by ARIA role
Parameters:
- : string - ARIA role (required)
- : string - Accessible name
Invocation Example:
json
{
"role": "button",
"name": "Submit"
}
browser_get_by_text
Find elements by text content
Parameters:
- : string - Text content (required)
- : boolean - Whether to match exactly
Invocation Example:
json
{
"text": "Sign In",
"exact": true
}
browser_get_by_label
Find form elements by label text
Parameters:
- : string - Label text (required)
- : boolean - Whether to match exactly
Invocation Example:
json
{
"text": "Email Address",
"exact": false
}
browser_get_by_placeholder
Find input boxes by placeholder text
Parameters:
- : string - Placeholder text (required)
- : boolean - Whether to match exactly
Invocation Example:
json
{
"text": "Enter your email",
"exact": false
}
browser_get_by_test_id
Find elements by test ID
Parameters:
- : string - Test ID (required)
Invocation Example:
json
{ "testId": "submit-button" }
browser_get_by_alt_text
Find image elements by alt attribute text
Parameters:
- : string - Alt text (required)
- : boolean - Whether to match exactly
Invocation Example:
json
{
"text": "Company Logo",
"exact": false
}
browser_get_by_title
Find elements by title attribute
Parameters:
- : string - Title text (required)
- : boolean - Whether to match exactly
Invocation Example:
json
{
"text": "Click to expand",
"exact": false
}
Wait Operations
browser_wait_for_selector
Wait for an element to appear in the DOM
Parameters:
- : string - CSS selector (required)
- : number - Timeout period (milliseconds)
- : 'attached' | 'visible' | 'hidden' - Wait state
Invocation Example:
json
{
"selector": ".loading-complete",
"timeout": 10000,
"state": "visible"
}
browser_wait_for_timeout
Wait for a specified period of time
Parameters:
- : number - Wait time (milliseconds, required)
Invocation Example:
browser_wait_for_url
Wait for the URL to match the specified pattern
Parameters:
- : string - URL pattern (required)
- : number - Timeout period (milliseconds)
Invocation Example:
json
{
"url": "https://example.com/dashboard",
"timeout": 5000
}
browser_wait_for_request
Wait for a network request
Parameters:
- : string - URL pattern (required)
- : number - Timeout period (milliseconds)
Invocation Example:
json
{
"urlPattern": "**/api/users",
"timeout": 10000
}
browser_wait_for_response
Wait for a network response
Parameters:
- : string - URL pattern (required)
- : number - Timeout period (milliseconds)
Invocation Example:
json
{
"urlPattern": "**/api/data",
"timeout": 10000
}
browser_wait_for_function
Wait for a JavaScript function to return true
Parameters:
- : string - JavaScript function code (required)
- : any - Parameters passed to the function
- : number - Timeout period (milliseconds)
- : number - Polling interval (milliseconds)
Invocation Example:
json
{
"fn": "() => document.readyState === 'complete'",
"timeout": 5000,
"polling": 100
}
browser_wait_for_load_state
Wait for the page to load to the specified state
Parameters:
- : 'load' | 'domcontentloaded' | 'networkidle' - Load state (required)
- : number - Timeout period (milliseconds)
Invocation Example:
json
{
"state": "networkidle",
"timeout": 30000
}
Screenshots and PDF
browser_screenshot
Take a page screenshot
Parameters:
- : string - Save path
- : boolean - Whether to capture the full page
- : 'png' | 'jpeg' - Image format
- : number - Image quality (0-100, only for JPEG)
Invocation Example:
json
{
"path": "screenshot.png",
"fullPage": true,
"type": "png"
}
browser_screenshot_element
Take a screenshot of a specified element
Parameters:
- : string - CSS selector (required)
- : string - Save path
Invocation Example:
json
{
"selector": ".chart",
"path": "chart.png"
}
browser_pdf
Generate a page PDF
Parameters:
- : string - Save path
- : string - Paper format (e.g. 'A4', 'Letter')
- : boolean - Whether to print background
Invocation Example:
json
{
"path": "page.pdf",
"format": "A4",
"printBackground": true
}
JavaScript Execution
browser_evaluate
Execute JavaScript code in the page context
Parameters:
- : string - JavaScript code (required)
- : any - Parameters passed to the script
Invocation Example:
json
{
"script": "document.querySelectorAll('h2').length"
}
browser_add_script_tag
Add a script tag to the page
Parameters:
- : string - Script URL
- : string - Script content
Invocation Example:
json
{
"url": "https://cdn.example.com/library.js"
}
browser_add_style_tag
Add a style tag to the page
Parameters:
- : string - Style URL
- : string - Style content
Invocation Example:
json
{
"content": "body { background: red; }"
}
Cookie and Storage
browser_set_cookies
Set one or more cookies
Parameters:
- : array - Cookie array (required)
- : string - Cookie name
- : string - Cookie value
- : string - Domain name
- : string - Path
Invocation Example:
json
{
"cookies": [
{
"name": "session",
"value": "abc123",
"domain": "example.com",
"path": "/"
}
]
}
browser_get_cookies
Get all cookies of the current page
Parameters: None
Invocation Example:
browser_clear_cookies
Clear all cookies
Parameters: None
Invocation Example:
browser_set_local_storage
Set LocalStorage item
Parameters:
- : string - Key name (required)
- : string - Value (required)
Invocation Example:
json
{
"key": "theme",
"value": "dark"
}
browser_get_local_storage
Get LocalStorage item
Parameters:
- : string - Key name (optional, returns all items if not provided)
Invocation Example:
browser_clear_local_storage
Clear LocalStorage
Parameters: None
Invocation Example:
browser_storage_state
Save storage state (Cookie and LocalStorage)
Parameters:
Invocation Example:
json
{ "path": "storage.json" }
browser_restore_storage_state
Restore storage state
Parameters:
- : object - Storage state object (required)
Invocation Example:
json
{
"state": { "cookies": [], "origins": [] }
}
Network Control
browser_set_offline
Set offline mode
Parameters:
- : boolean - Whether to be offline (required)
Invocation Example:
browser_block_requests
Block requests matching the pattern
Parameters:
- : array - URL pattern array (required)
Invocation Example:
json
{
"patterns": ["*.jpg", "*.png", "*/ads/*"]
}
browser_mock_response
Mock network response
Parameters:
- : string - URL pattern (required)
- : object - Response object (required)
- : number - Status code
- : string - Response body
- : string - Content type
Invocation Example:
json
{
"urlPattern": "**/api/users",
"response": {
"status": 200,
"body": "{\"users\": []}",
"contentType": "application/json"
}
}
browser_get_request_logs
Get request logs
Parameters:
Invocation Example:
browser_get_response_logs
Get response logs
Parameters:
Invocation Example:
browser_get_console_logs
Get console logs
Parameters:
Invocation Example:
browser_clear_logs
Clear all logs (request, response, console)
Parameters: None
Invocation Example:
File Operations
browser_upload_file
Upload files to a file input box
Parameters:
- : string - File input box selector (required)
- : string | array - File path(s) (required)
Invocation Example:
json
{
"selector": "input[type='file']",
"filePath": "C:\\Users\\Admin\\document.pdf"
}
browser_download_file
Trigger file download
Parameters:
- : string - Selector of the element that triggers download (required)
Invocation Example:
json
{ "triggerSelector": "a.download-link" }
Viewport and Device
browser_set_viewport_size
Set viewport size
Parameters:
- : number - Width (required)
- : number - Height (required)
Invocation Example:
json
{
"width": 1920,
"height": 1080
}
browser_get_viewport_size
Get current viewport size
Parameters: None
Invocation Example:
browser_emulate_media
Emulate media type and color scheme
Parameters:
- : 'light' | 'dark' | 'no-preference' - Color scheme
- : 'screen' | 'print' - Media type
Invocation Example:
json
{
"colorScheme": "dark",
"media": "screen"
}
browser_set_geolocation
Set geolocation
Parameters:
- : number - Latitude (required)
- : number - Longitude (required)
- : number - Accuracy
Invocation Example:
json
{
"latitude": 37.7749,
"longitude": -122.4194,
"accuracy": 100
}
browser_clear_geolocation
Clear geolocation settings
Parameters: None
Invocation Example:
browser_touchscreen_tap
Tap on the touchscreen at specified coordinates (for mobile devices)
Parameters:
- : number - X coordinate (required)
- : number - Y coordinate (required)
Invocation Example:
Scroll Operations
browser_scroll_to
Scroll to specified coordinates
Parameters:
- : number - X coordinate (required)
- : number - Y coordinate (required)
Invocation Example:
browser_scroll_into_view
Scroll an element into the visible area
Parameters:
- : string - CSS selector (required)
Invocation Example:
json
{ "selector": "#footer" }
Performance Metrics
browser_get_metrics
Get page performance metrics
Parameters: None
Invocation Example:
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
Start collecting JavaScript and CSS code coverage
Parameters: None
Invocation Example:
browser_stop_coverage
Stop collecting code coverage and return results
Parameters: None
Invocation Example:
Accessibility Features
browser_get_accessibility_snapshot
Get page accessibility tree snapshot
Parameters:
- : string - Selector to limit the scope (optional)
Invocation Example:
Time Control
browser_install_clock
Install clock control (for testing time-related functions)
Parameters:
- : number | string - Initial time
Invocation Example:
json
{ "time": 1609459200000 }
browser_set_system_time
Set system time
Parameters:
- : number | string - Timestamp or date string (required)
Invocation Example:
json
{ "time": "2024-01-01T00:00:00Z" }
browser_fast_forward
Fast forward time
Parameters:
- : number - Milliseconds to fast forward (required)
Invocation Example:
browser_pause_clock
Pause the clock (freeze time)
Parameters: None
Invocation Example:
browser_resume_clock
Resume clock operation
Parameters: None
Invocation Example:
Permission Management
browser_grant_permissions
Grant browser permissions
Parameters:
- : array - Permission list (required)
- Optional values: 'geolocation', 'notifications', 'camera', 'microphone', 'clipboard-read', 'clipboard-write'
- : string - Limited domain name
Invocation Example:
json
{
"permissions": ["geolocation", "notifications"],
"origin": "https://example.com"
}
browser_clear_permissions
Clear all permissions
Parameters: None
Invocation Example:
Dialog Handling
browser_handle_dialog
Handle JavaScript dialogs (alert, confirm, prompt)
Parameters:
- : 'accept' | 'dismiss' - Operation type (required)
- : string - Input text for prompt dialogs
Invocation Example:
json
{
"action": "accept",
"promptText": "My Input"
}
Frame Operations
browser_get_frames
Get all frames in the page
Parameters: None
Invocation Example:
🎯 Practical Usage Scenario Examples
The following are some practical usage scenarios showing how to interact with me in natural language to complete tasks.
Scenario 1: View web page content
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
Scenario 2: Search for information
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
Scenario 3: Extract data
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
Scenario 4: Web page screenshot
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
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
Scenario 6: Monitor web page changes
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
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
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()
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()
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()
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()
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()
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()
Selector Syntax Reference
CSS Selectors
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
// 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 key
- - Tab key
- - Esc key
- - Backspace key
- - Delete key
- , , , - Arrow keys
- , - Home/End keys
- , - Page up/down keys
- , , , - Modifier keys
- - - Function keys
Error Handling and Best Practices
1. Browser Lifecycle Management
- You must call to launch the browser before use
- You should call to release resources after use
- Calling other methods when the browser is not launched will throw an error
2. Wait Strategy
- Use
browser_wait_for_selector
to ensure elements are loaded
- Set a reasonable timeout period (default 30 seconds)
- Use to wait for network requests to complete
3. Selector Best Practices
- 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. Performance Optimization
- Use to improve execution speed
- Use to block unnecessary resources (images, ads)
- Set a reasonable viewport size to avoid overly large screenshots
5. Debugging Tips
- Use to view the browser operation process
- Use the parameter to slow down the operation speed
- Use to view page errors
- Use and to record the operation process
6. Error Handling
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
-
Path format: Use double backslashes
or forward slashes
for Windows systems
- Correct:
C:\\Users\\Admin\\file.pdf
or
- Incorrect:
-
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
- 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
- Version: 2.0.0
- Update Date: 2024
- Playwright Version: Latest stable version
- Supported Platforms: Windows, macOS, Linux
Technical Support
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