> ## Documentation Index
> Fetch the complete documentation index at: https://www.minitap.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Run your own Selenium and Playwright tests

> Point your existing Selenium or Playwright web suite at Minitap and read every test, recording, log and trace in Script runs.

Your team's Selenium and Playwright tests can run on browsers Minitap hosts, with the test code unchanged. You change one URL and add a few capabilities. Each test gets a fresh Chrome, Edge or Firefox, recorded from start to end, and the results show up in **Script runs**, next to Mini's runs and your [Appium tests](https://www.minitap.ai/docs/minitest/runs/script-runs.md).

Your test runner stays in your CI. Only the browser runs on Minitap, so your tests keep their sharding, retries, fixtures and reporters, and the API calls they make to seed data stay on your network.

> [!NOTE]
>
> **Beta.** Selenium and Playwright on Minitap browsers are being tried with a few teams first. Ask the Minitap team to turn them on for your workspace.

## Set up

Open **Settings → Test frameworks** and pick **Selenium** or **Playwright**. The setup walks you through three things:

1. **An API key.** Your tests sign in with a workspace [API key](https://www.minitap.ai/docs/minitest/workspace/api-keys.md). Keep it in your CI's secret store as `MINITAP_API_KEY`.
2. **The app ID.** The app the results belong to. Copy it from the setup; it isn't a secret.
3. **The hub URL.** Shown in the setup. Selenium opens its sessions at `https://<hub>/wd/hub`, Playwright connects to `wss://<hub>/playwright`.

## Selenium

Point `RemoteWebDriver` at the hub and add the Minitap capabilities:

```python theme={"theme":{"light":"github-light","dark":"vesper"}}
import os

from selenium import webdriver

options = webdriver.ChromeOptions()  # or EdgeOptions, FirefoxOptions
options.browser_version = "latest"
options.set_capability("minitap:apiKey", os.environ["MINITAP_API_KEY"])
options.set_capability("minitap:appId", os.environ["MINITAP_APP_ID"])
options.set_capability("minitap:runName", os.environ.get("MINITAP_RUN_NAME"))
options.set_capability("minitap:viewport", "1280x800")

driver = webdriver.Remote(os.environ["MINITAP_HUB_URL"], options=options)
try:
    ...  # your test, unchanged
    driver.execute_script("minitap:setStatus", {"status": "passed", "name": "Checkout"})
except Exception as error:
    driver.execute_script(
        "minitap:setStatus", {"status": "failed", "name": "Checkout", "reason": str(error)}
    )
    raise
finally:
    driver.quit()
```

Each WebDriver session is one test, on its own browser. Report how it went with `minitap:setStatus` before you quit the driver, as for [Appium](https://www.minitap.ai/docs/minitest/runs/script-runs.md#report-each-test). A suite that keeps one driver for a whole class can call it once per test: each call is a test. If you'd rather not add it, upload your JUnit report with the [CLI](https://www.minitap.ai/docs/minitest/reference/cli-commands.md) instead.

| Capability | Required | What it does |
| - | - | - |
| `browserName` | yes | `chrome`, `MicrosoftEdge` or `firefox` |
| `browserVersion` | no | A major version, `latest` (default), `latest-1` or `latest-2` |
| `minitap:apiKey` | yes | Your workspace API key |
| `minitap:appId` | yes | The app the results belong to |
| `minitap:runName` | no | Groups the tests of one CI job into one run |
| `minitap:testName` | no | The test's name when `minitap:setStatus` doesn't give one |
| `minitap:viewport` | no | The window size, `1280x800` by default, from `320x240` up to `1920x1080` |
| `minitap:queueTimeout` | no | Seconds a test waits for a free browser, 300 by default, 900 at most |

Mobile emulation stays in your test: Chrome's `mobileEmulation` works as it does locally.

## Playwright

Your tests connect to a Playwright server Minitap runs next to the browser. Add the Minitap reporter, then give each project its connection with `minitapConnect`:

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
npm install --save-dev @minitap/playwright-reporter
```

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';
import { minitapConnect } from '@minitap/playwright-reporter';

export default defineConfig({
  reporter: [['list'], ['@minitap/playwright-reporter']],
  use: { trace: 'retain-on-failure', video: 'retain-on-failure' },
  projects: [
    { name: 'chrome',  use: { ...devices['Desktop Chrome'],  connectOptions: minitapConnect('chrome') } },
    { name: 'edge',    use: { ...devices['Desktop Edge'],    connectOptions: minitapConnect('MicrosoftEdge') } },
    { name: 'firefox', use: { ...devices['Desktop Firefox'], connectOptions: minitapConnect('firefox') } },
  ],
});
```

Then run your suite as usual, with the key, the app and the hub:

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
MINITAP_API_KEY=<key> MINITAP_APP_ID=<app id> MINITAP_HUB_URL=wss://<hub host> npx playwright test
```

* **The hub.** `MINITAP_HUB_URL` takes the hub's host over `wss://`, or the Selenium URL ending in `/wd/hub`.
* **One run per CI run.** In CI, the run name is the CI's run, so the shards of one pipeline form one run. `MINITAP_RUN_NAME` sets another.
* **Browser options.** `minitapConnect('chrome', { browserVersion: 'latest-1', viewport: '1440x900', queueTimeout: 600 })` picks the version, the window size and how long a test waits for a free browser.
* **Playwright version.** Your `@playwright/test` must be one of **1.60, 1.61, 1.62, 1.63, 1.64 or 1.65**: the client and the server have to be on the same minor version. Another version is refused with a message listing the ones we run.
* **Firefox 157 and 158 with Playwright 1.65.** Playwright 1.65 can't drive these two Firefox versions, and the session is refused with a message saying so. Use Firefox 159, or Playwright 1.64 or older.
* **One row per test.** The reporter sends each test with its retries, error, stack and duration, and uploads its trace and video. Without it, a run shows one row per worker. You can send the JSON or JUnit report afterwards with `minitest script-runs report` instead (see the [CLI](https://www.minitap.ai/docs/minitest/reference/cli-commands.md)).
* **Emulation.** `devices[...]` and `use.viewport` work as they do locally.

## Browsers

| Browser | Versions |
| - | - |
| Chrome | the last three majors |
| Edge | the last three majors |
| Firefox | the last three majors |

Ask for `latest`, `latest-1` or `latest-2`, or a major by number. A version we don't run refuses the session with a message listing the ones we do. Safari and WebKit aren't available yet.

A run never mixes browsers. Its first test sets the browser, version and window size, and every later test of the run gets the same one. A later test asking for another one is refused: give it its own `minitap:runName` to run it apart.

## How many tests run at once

A test's browser counts against your workspace's browser limit, the same one Mini's web runs use. Start more tests than that and the first ones run while the others wait, first come first served. A test that waits longer than its `minitap:queueTimeout` is refused with a message naming the browser, how many tests asked for one and how many your workspace has.

A browser starts in a few seconds, and up to about a minute and a half when we add capacity.

## Private and staging apps

When your app sits behind a VPN, a firewall or an IP allowlist, use the app's [private network](https://www.minitap.ai/docs/minitest/setup/private-apps.md). Every browser your tests get reaches the app's private domains through your connector, as Mini's runs do. If the connector is offline, the test is refused with a private network error rather than reaching the app another way. Minitap's browsers don't have a fixed IP address you can allowlist, so the connector is the way in.

Playwright's `exposeNetwork: '<loopback>'` also lets the browser reach an app served on your CI's own `localhost`.

## Read the results

Open **Results → Script runs**. Each test shows its browser, like **Chrome 157 · 1280×800**, its status and failure reason. Open it to watch its recording (a Playwright test plays its own video, or its worker's recording from where the test started), read the driver log (Selenium), the browser console and a failure's stack, and open its Playwright trace in the trace viewer. A retried test shows its last attempt and how many retries it took.

From the terminal:

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
minitest script-runs list --framework playwright
minitest script-runs get <run id> --platform web
minitest script-runs trace <run id> --test "checkout › pays"
minitest script-runs browser-log <run id> --test <test id>
minitest script-runs driver-log <run id> --test <test id>
minitest script-runs report <run id> --file results.json   # a Playwright JSON or JUnit report, without the reporter
```

## Good to know

* A session lasts at most two hours.
* While we deploy a new version of the hub, sessions open at that moment can end. Playwright's retries, or your CI's, start them again.

## How long we keep them

| What | Kept |
| - | - |
| Runs, tests and recordings | 90 days |
| Driver logs, browser logs and traces | 30 days |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.