> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/microsoft/playwright-mcp/llms.txt
> Use this file to discover all available pages before exploring further.

# Core Automation Tools

> Essential tools for browser navigation, element interaction, and page inspection

Core automation tools provide the fundamental capabilities for browser automation, including navigation, clicking, typing, form filling, and page inspection. These tools are available by default and don't require any special capabilities.

## Navigation

### browser\_navigate

Navigate to a URL.

<ParamField path="url" type="string" required>
  The URL to navigate to
</ParamField>

**Read-only**: No

```javascript theme={null}
// Example usage
{
  "tool": "browser_navigate",
  "arguments": {
    "url": "https://example.com"
  }
}
```

### browser\_navigate\_back

Go back to the previous page in the history.

**Parameters**: None

**Read-only**: No

### browser\_close

Close the current page.

**Parameters**: None

**Read-only**: No

## Element Interaction

### browser\_click

Perform click on a web page element.

<ParamField path="element" type="string">
  Human-readable element description used to obtain permission to interact with the element
</ParamField>

<ParamField path="ref" type="string" required>
  Exact target element reference from the page snapshot
</ParamField>

<ParamField path="doubleClick" type="boolean">
  Whether to perform a double click instead of a single click
</ParamField>

<ParamField path="button" type="string">
  Button to click, defaults to left
</ParamField>

<ParamField path="modifiers" type="array">
  Modifier keys to press (e.g., \["Control", "Shift"])
</ParamField>

**Read-only**: No

```javascript theme={null}
// Example: Click a submit button
{
  "tool": "browser_click",
  "arguments": {
    "element": "Submit button",
    "ref": "ref_123"
  }
}
```

### browser\_hover

Hover over element on page.

<ParamField path="element" type="string">
  Human-readable element description used to obtain permission to interact with the element
</ParamField>

<ParamField path="ref" type="string" required>
  Exact target element reference from the page snapshot
</ParamField>

**Read-only**: No

### browser\_type

Type text into editable element.

<ParamField path="element" type="string">
  Human-readable element description used to obtain permission to interact with the element
</ParamField>

<ParamField path="ref" type="string" required>
  Exact target element reference from the page snapshot
</ParamField>

<ParamField path="text" type="string" required>
  Text to type into the element
</ParamField>

<ParamField path="submit" type="boolean">
  Whether to submit entered text (press Enter after)
</ParamField>

<ParamField path="slowly" type="boolean">
  Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.
</ParamField>

**Read-only**: No

```javascript theme={null}
// Example: Type into a search field
{
  "tool": "browser_type",
  "arguments": {
    "element": "Search input",
    "ref": "ref_456",
    "text": "playwright automation",
    "submit": true
  }
}
```

### browser\_press\_key

Press a key on the keyboard.

<ParamField path="key" type="string" required>
  Name of the key to press or a character to generate, such as `ArrowLeft` or `a`
</ParamField>

**Read-only**: No

## Form Operations

### browser\_fill\_form

Fill multiple form fields in one operation.

<ParamField path="fields" type="array" required>
  Fields to fill in. Each field should contain element information and the value to enter.
</ParamField>

**Read-only**: No

```javascript theme={null}
// Example: Fill a login form
{
  "tool": "browser_fill_form",
  "arguments": {
    "fields": [
      {
        "element": "Email input",
        "ref": "ref_100",
        "text": "user@example.com"
      },
      {
        "element": "Password input",
        "ref": "ref_101",
        "text": "securepassword"
      }
    ]
  }
}
```

### browser\_select\_option

Select an option in a dropdown.

<ParamField path="element" type="string">
  Human-readable element description used to obtain permission to interact with the element
</ParamField>

<ParamField path="ref" type="string" required>
  Exact target element reference from the page snapshot
</ParamField>

<ParamField path="values" type="array" required>
  Array of values to select in the dropdown. This can be a single value or multiple values.
</ParamField>

**Read-only**: No

### browser\_file\_upload

Upload one or multiple files.

<ParamField path="paths" type="array">
  The absolute paths to the files to upload. Can be single file or multiple files. If omitted, file chooser is cancelled.
</ParamField>

**Read-only**: No

## Advanced Interactions

### browser\_drag

Perform drag and drop between two elements.

<ParamField path="startElement" type="string" required>
  Human-readable source element description used to obtain the permission to interact with the element
</ParamField>

<ParamField path="startRef" type="string" required>
  Exact source element reference from the page snapshot
</ParamField>

<ParamField path="endElement" type="string" required>
  Human-readable target element description used to obtain the permission to interact with the element
</ParamField>

<ParamField path="endRef" type="string" required>
  Exact target element reference from the page snapshot
</ParamField>

**Read-only**: No

### browser\_handle\_dialog

Handle a browser dialog (alert, confirm, prompt).

<ParamField path="accept" type="boolean" required>
  Whether to accept the dialog.
</ParamField>

<ParamField path="promptText" type="string">
  The text of the prompt in case of a prompt dialog.
</ParamField>

**Read-only**: No

## Page Inspection

### browser\_snapshot

Capture accessibility snapshot of the current page. This is the preferred method for understanding page structure and is better than screenshots for automation purposes.

<ParamField path="filename" type="string">
  Save snapshot to markdown file instead of returning it in the response.
</ParamField>

**Read-only**: Yes

<Tip>
  Use `browser_snapshot` as your primary method for understanding page structure. It provides semantic information that's much more useful for automation than visual screenshots.
</Tip>

### browser\_take\_screenshot

Take a screenshot of the current page.

<ParamField path="type" type="string">
  Image format for the screenshot. Default is png.
</ParamField>

<ParamField path="filename" type="string">
  File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified. Prefer relative file names to stay within the output directory.
</ParamField>

<ParamField path="element" type="string">
  Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too.
</ParamField>

<ParamField path="ref" type="string">
  Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too.
</ParamField>

<ParamField path="fullPage" type="boolean">
  When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Cannot be used with element screenshots.
</ParamField>

**Read-only**: Yes

<Warning>
  You can't perform actions based on screenshots. Use `browser_snapshot` for actions and automation.
</Warning>

### browser\_console\_messages

Returns all console messages from the page.

<ParamField path="level" type="string" required>
  Level of the console messages to return. Each level includes the messages of more severe levels. Defaults to "info".
</ParamField>

<ParamField path="filename" type="string">
  Filename to save the console messages to. If not provided, messages are returned as text.
</ParamField>

**Read-only**: Yes

### browser\_network\_requests

Returns all network requests since loading the page.

<ParamField path="includeStatic" type="boolean" required>
  Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false.
</ParamField>

<ParamField path="filename" type="string">
  Filename to save the network requests to. If not provided, requests are returned as text.
</ParamField>

**Read-only**: Yes

## JavaScript Execution

### browser\_evaluate

Evaluate JavaScript expression on page or element.

<ParamField path="function" type="string" required>
  JavaScript function as string: `() => { /* code */ }` or `(element) => { /* code */ }` when element is provided
</ParamField>

<ParamField path="element" type="string">
  Human-readable element description used to obtain permission to interact with the element
</ParamField>

<ParamField path="ref" type="string">
  Exact target element reference from the page snapshot
</ParamField>

**Read-only**: No

```javascript theme={null}
// Example: Get page title
{
  "tool": "browser_evaluate",
  "arguments": {
    "function": "() => document.title"
  }
}
```

### browser\_run\_code

Run Playwright code snippet directly.

<ParamField path="code" type="string" required>
  A JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction. For example: `async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }`
</ParamField>

**Read-only**: No

```javascript theme={null}
// Example: Complex interaction
{
  "tool": "browser_run_code",
  "arguments": {
    "code": "async (page) => { const button = await page.getByRole('button', { name: 'Submit' }); await button.click(); return await page.title(); }"
  }
}
```

## Browser Configuration

### browser\_resize

Resize the browser window.

<ParamField path="width" type="number" required>
  Width of the browser window
</ParamField>

<ParamField path="height" type="number" required>
  Height of the browser window
</ParamField>

**Read-only**: No

### browser\_wait\_for

Wait for text to appear or disappear or a specified time to pass.

<ParamField path="time" type="number">
  The time to wait in seconds
</ParamField>

<ParamField path="text" type="string">
  The text to wait for to appear
</ParamField>

<ParamField path="textGone" type="string">
  The text to wait for to disappear
</ParamField>

**Read-only**: No

<Note>
  You must provide either `time`, `text`, or `textGone`. The tool will wait until the condition is met or timeout occurs.
</Note>

***

## Browser Installation

### browser\_install

Install the browser specified in the configuration.

**Description**: Installs the browser executable required for Playwright. Call this if you encounter an error about the browser not being installed.

**Parameters**: None

**Read-only**: No

**Usage**:

```json theme={null}
{
  "tool": "browser_install",
  "arguments": {}
}
```

<Note>
  This tool installs the browser specified by the `--browser` flag or in the configuration file. If no browser is specified, it installs Chromium by default.
</Note>

<Tip>
  Most MCP clients will automatically install the browser on first use, but you can use this tool if installation fails or if you need to reinstall.
</Tip>
