> ## 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.

# Tab Management

> Tools for managing browser tabs - create, list, close, and switch between tabs

Playwright MCP provides a unified tool for managing browser tabs. This allows you to work with multiple pages simultaneously, which is useful for workflows that require comparing content across different pages or managing multiple web applications.

## browser\_tabs

List, create, close, or select a browser tab.

<ParamField path="action" type="string" required>
  Operation to perform. Available actions:

  * `list` - List all open tabs
  * `create` - Create a new tab
  * `close` - Close a tab
  * `select` - Switch to a specific tab
</ParamField>

<ParamField path="index" type="number">
  Tab index, used for close/select actions. If omitted for close, current tab is closed.
</ParamField>

**Read-only**: No

## Usage Examples

### List All Tabs

Get a list of all currently open tabs with their indexes and URLs:

```javascript theme={null}
{
  "tool": "browser_tabs",
  "arguments": {
    "action": "list"
  }
}
```

**Response example:**

```
Open tabs:
0: https://example.com (current)
1: https://github.com
2: https://playwright.dev
```

### Create a New Tab

Open a new blank tab:

```javascript theme={null}
{
  "tool": "browser_tabs",
  "arguments": {
    "action": "create"
  }
}
```

The new tab will become the active tab. You can then use `browser_navigate` to navigate to a URL.

### Switch to a Specific Tab

Switch to a tab by its index:

```javascript theme={null}
{
  "tool": "browser_tabs",
  "arguments": {
    "action": "select",
    "index": 1
  }
}
```

<Tip>
  Use the `list` action first to see the available tab indexes before switching.
</Tip>

### Close a Specific Tab

Close a tab by its index:

```javascript theme={null}
{
  "tool": "browser_tabs",
  "arguments": {
    "action": "close",
    "index": 2
  }
}
```

### Close the Current Tab

Close the currently active tab without specifying an index:

```javascript theme={null}
{
  "tool": "browser_tabs",
  "arguments": {
    "action": "close"
  }
}
```

<Warning>
  If you close the last remaining tab, the browser context will remain open but empty. You can create a new tab to continue working.
</Warning>

## Common Workflows

### Compare Content Across Multiple Pages

1. Navigate to the first page
2. Create a new tab
3. Navigate to the second page
4. Take snapshots or screenshots of both
5. Switch between tabs to compare

```javascript theme={null}
// Navigate to first page
{ "tool": "browser_navigate", "arguments": { "url": "https://example.com/page1" } }

// Create new tab
{ "tool": "browser_tabs", "arguments": { "action": "create" } }

// Navigate to second page
{ "tool": "browser_navigate", "arguments": { "url": "https://example.com/page2" } }

// Switch back to first tab
{ "tool": "browser_tabs", "arguments": { "action": "select", "index": 0 } }
```

### Managing Multiple Workflows

When working with multiple web applications or workflows:

```javascript theme={null}
// List current tabs to see what's open
{ "tool": "browser_tabs", "arguments": { "action": "list" } }

// Switch to admin panel tab
{ "tool": "browser_tabs", "arguments": { "action": "select", "index": 1 } }

// Perform admin actions...

// Switch back to main application
{ "tool": "browser_tabs", "arguments": { "action": "select", "index": 0 } }

// Close unused tabs to clean up
{ "tool": "browser_tabs", "arguments": { "action": "close", "index": 2 } }
```

## Best Practices

<AccordionGroup>
  <Accordion title="Track Tab Indexes">
    Tab indexes can change when tabs are closed. Always use the `list` action to get current indexes before performing `select` or `close` operations.
  </Accordion>

  <Accordion title="Clean Up Unused Tabs">
    Close tabs when you're done with them to avoid confusion and reduce resource usage.
  </Accordion>

  <Accordion title="Descriptive Workflow">
    When working with multiple tabs, maintain a clear mental model or documentation of which tab contains what content.
  </Accordion>
</AccordionGroup>

## Related Tools

<CardGroup cols={2}>
  <Card title="Core Automation" icon="browser" href="/tools/core-automation">
    Navigate and interact with pages in tabs
  </Card>

  <Card title="Page Snapshot" icon="camera" href="/tools/core-automation#browser_snapshot">
    Capture content from different tabs
  </Card>
</CardGroup>
