---
title: Playwright Recorder - Record tests | TestingBot
description: Record tests with Playwright Recorder and run these on a remote browser
  grid.
source_url:
  html: https://testingbot.com/support/web-automate/playwright/recorder
  md: https://testingbot.com/support/web-automate/playwright/recorder/index.md
---
# Playwright Recorder

Playwright offers a feature where you can record the actions in your browser to a Playwright script file.

This allows you to easily create tests by recording your own actions, similar to [Selenium IDE](https://testingbot.com/support/web-automate/codeless-automation/add-test).

To get started, install these packages:

    npm install playwright

## Example

Now you can record your actions to a Playwright file:

    npx playwright codegen --target javascript -o example.js https://testingbot.com

This command will start a Chromium browser and will record every action you take, in JavaScript format, to a file called `example.js`.

You can choose to save the file in a different format, these are the options:

- javascript
- python
- python-async
- csharp

The `example.js` file can contain something similar to this:

    const { chromium } = require('playwright');
    
    (async () => {
      const browser = await chromium.launch({
        headless: false
      });
      const context = await browser.newContext();
    
      // Open new page
      const page = await context.newPage();
    
      // Go to https://testingbot.com/
      await page.goto('https://testingbot.com/');
    
      // Click text=Take your automated and manual testing to the next level.
      await page.click('text=Take your automated and manual testing to the next level.');
    
      // Click img[alt="Automated Testing"]
      await page.click('img[alt="Automated Testing"]');
    
      // Close page
      await page.close();
    
      // ---------------------
      await context.close();
      await browser.close();
    })();

## Run on TestingBot

To run the generated file on a browser in the TestingBot grid, you'll have to modify the script.

### Before

    const browser = await chromium.launch();

### After

    const capabilities = {
      'tb:options': {
        key: process.env.TB_KEY,
        secret: process.env.TB_SECRET
      },
      browserName: 'chrome',
      browserVersion: 'latest'
    }
    const browser = await chromium.connect({
      wsEndpoint: `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
    })

## Playwright Agents

An alternative approach to recording tests would be to generate tests from your existing code. Playwright comes with [3 agents](https://playwright.dev/docs/test-agents) that can be used to create tests.

- **planner** explores the app and produces a Markdown test plan
- **generator** transforms the Markdown plan into the Playwright Test files
- **healer** executes the test suite and automatically repairs failing tests, for example due to bad/missing locators

To get started, use this command to initialize the agent definitions:

    npx playwright init-agents --loop=claude

You can now use your AI tool of choice to generate tests and point these to use a remote TestingBot browser by replacing the `launch` command with a `connect` command, as shown in the previous sections.

For example with a prompt: "Create one or more Playwright tests from the markdown test plan that was generated."

Was this page helpful? Yes No 

## Looking for More Help?

Have questions or need more information?   
 You can reach us via the following channels:

- [Email us](https://testingbot.com/contact/new)
- [Join our Slack Channel](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
