Features

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.


To get started, install these packages:

pip install playwright
playwright install

Example


Now you can record your actions to a Playwright file:

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

await chromium.connectOverCDP({
    wsEndpoint: 'wss://cloud.testingbot.com?key=api_key&secret=api_secret&browserName=chrome&browserVersion=latest',
});
Playwright Recorder