> ## Documentation Index
> Fetch the complete documentation index at: https://browseruse-0aece648-magnus-streaming-api-link.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Playwright, Puppeteer, Selenium

> Connect your automation framework to Browser Use's stealth infrastructure via CDP.

## Option 1: WebSocket URL (no SDK)

Connect with a single URL. All configuration is passed as query parameters.

### Playwright

<CodeGroup>
  ```python Python theme={null}
  from playwright.async_api import async_playwright

  WSS_URL = "wss://connect.browser-use.com?apiKey=YOUR_API_KEY&proxyCountryCode=us"

  async with async_playwright() as p:
      browser = await p.chromium.connect_over_cdp(WSS_URL)
      page = browser.contexts[0].pages[0]
      await page.goto("https://example.com")
      print(await page.title())
      await browser.close()
  # Browser is automatically stopped when the WebSocket disconnects
  ```

  ```typescript TypeScript theme={null}
  import { chromium } from "playwright";

  const WSS_URL = "wss://connect.browser-use.com?apiKey=YOUR_API_KEY&proxyCountryCode=us";

  const browser = await chromium.connectOverCDP(WSS_URL);
  const page = browser.contexts()[0].pages()[0];
  await page.goto("https://example.com");
  console.log(await page.title());
  await browser.close();
  // Browser is automatically stopped when the WebSocket disconnects
  ```
</CodeGroup>

### Puppeteer

```typescript theme={null}
import puppeteer from "puppeteer-core";

const WSS_URL = "wss://connect.browser-use.com?apiKey=YOUR_API_KEY&proxyCountryCode=us";

const browser = await puppeteer.connect({ browserWSEndpoint: WSS_URL });
const [page] = await browser.pages();
await page.goto("https://example.com");
console.log(await page.title());
await browser.close();
```

### Selenium

```python theme={null}
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from browser_use_sdk.v3 import AsyncBrowserUse

client = AsyncBrowserUse()
browser = await client.browsers.create()

options = Options()
options.debugger_address = browser.cdp_url.replace("ws://", "").replace("/devtools/browser/", "")
driver = webdriver.Chrome(options=options)
driver.get("https://example.com")
print(driver.title)
driver.quit()

await client.browsers.stop(browser.id)
```

## Query parameters

| Parameter             | Type     | Description                                                 |
| --------------------- | -------- | ----------------------------------------------------------- |
| `apiKey`              | `string` | **Required.** Your Browser Use API key.                     |
| `proxyCountryCode`    | `string` | Proxy country code (e.g. `us`, `de`, `jp`). 195+ countries. |
| `profileId`           | `string` | Load a saved browser profile (cookies, localStorage).       |
| `timeout`             | `int`    | Session timeout in minutes. Max: 240 (4 hours).             |
| `browserScreenWidth`  | `int`    | Browser width in pixels.                                    |
| `browserScreenHeight` | `int`    | Browser height in pixels.                                   |

## Option 2: SDK

Create a browser via the SDK, get a `cdp_url`, connect with your framework.

<CodeGroup>
  ```python Python theme={null}
  from browser_use_sdk.v3 import AsyncBrowserUse

  client = AsyncBrowserUse()
  browser = await client.browsers.create(proxy_country_code="us")
  print(browser.cdp_url)   # ws://...
  print(browser.live_url)  # debug view
  ```

  ```typescript TypeScript theme={null}
  import { BrowserUse } from "browser-use-sdk/v3";

  const client = new BrowserUse();
  const browser = await client.browsers.create({ proxyCountryCode: "us" });
  console.log(browser.cdpUrl);
  console.log(browser.liveUrl);
  ```
</CodeGroup>

<Warning>
  Always stop browser sessions when done. Sessions left running will continue to incur charges until the timeout expires.
</Warning>
