mcp_tools / PLAYWRIGHT_TOOLS_REFERENCE.md
ZarakShah's picture
Upload folder using huggingface_hub
8a59f15 verified

A newer version of the Gradio SDK is available: 6.13.0

Upgrade

Playwright MCP Tools Reference

This document describes all available Playwright MCP browser automation tools.

Browser Navigation Tools

browser_navigate

Navigate to a URL.

  • Arguments:
    • url (string): The URL to navigate to

browser_navigate_back

Go back in browser history.

  • Arguments: None

Browser Interaction Tools

browser_click

Click on an element.

  • Arguments:
    • selector (string): CSS selector for the element
    • button (string, optional): "left", "right", or "middle" (default: "left")
    • clickCount (number, optional): Number of clicks (default: 1)

browser_hover

Hover over an element.

  • Arguments:
    • selector (string): CSS selector for the element

browser_drag

Drag an element.

  • Arguments:
    • selector (string): CSS selector for the element to drag
    • target (string): CSS selector for the drop target

browser_type

Type text into an input field.

  • Arguments:
    • selector (string): CSS selector for the input element
    • text (string): Text to type
    • delay (number, optional): Delay between keystrokes in milliseconds

browser_press_key

Press a keyboard key.

  • Arguments:
    • key (string): Key to press (e.g., "Enter", "Escape", "Tab")

browser_fill_form

Fill a form with data.

  • Arguments:
    • selector (string): CSS selector for the form
    • data (object): Key-value pairs of form field names and values

browser_select_option

Select an option from a dropdown.

  • Arguments:
    • selector (string): CSS selector for the select element
    • value (string): Value of the option to select

Browser Information Tools

browser_take_screenshot

Take a screenshot of the current page.

  • Arguments: None (or optional viewport settings)

browser_snapshot

Get the HTML snapshot of the current page.

  • Arguments: None

browser_console_messages

Get console messages from the browser.

  • Arguments: None

browser_network_requests

Get network request information.

  • Arguments: None

browser_tabs

List all open browser tabs.

  • Arguments: None

Browser Control Tools

browser_wait_for

Wait for an element or condition.

  • Arguments:
    • selector (string): CSS selector to wait for
    • state (string): "visible", "hidden", "attached", or "detached"
    • timeout (number, optional): Timeout in milliseconds (default: 30000)

browser_resize

Resize the browser window.

  • Arguments:
    • width (number): New width in pixels
    • height (number): New height in pixels

browser_close

Close the browser.

  • Arguments: None

Advanced Tools

browser_evaluate

Execute JavaScript in the browser context.

  • Arguments:
    • script (string): JavaScript code to execute

browser_run_code

Run code in the browser context (similar to evaluate).

  • Arguments:
    • code (string): Code to run

browser_handle_dialog

Handle browser dialogs (alert, confirm, prompt).

  • Arguments:
    • action (string): "accept" or "dismiss"
    • text (string, optional): Text to enter for prompt dialogs

browser_file_upload

Upload a file to an input element.

  • Arguments:
    • selector (string): CSS selector for the file input
    • filePath (string): Path to the file to upload

browser_install

Install browser dependencies (usually run once).

  • Arguments: None

Usage Tips

  1. Always wait for elements: Use browser_wait_for before interacting with elements that might not be loaded yet.

  2. Use selectors carefully: CSS selectors should be specific enough to target the right element.

  3. Handle async operations: Many browser operations are asynchronous - wait for them to complete.

  4. Take screenshots for debugging: Use browser_take_screenshot to see what the browser sees.

  5. Check console messages: Use browser_console_messages to debug JavaScript errors.

Example Workflow

  1. browser_navigate - Navigate to a page
  2. browser_wait_for - Wait for page to load
  3. browser_snapshot - Get page content (optional)
  4. browser_click / browser_type - Interact with elements
  5. browser_take_screenshot - Capture state
  6. browser_close - Clean up