Recording Playwright core

We assume most folks are using Playwright Test, but because Replay is just a browser, you can also use the Playwright API, to tell Playwright to launch the Replay browser.

Getting started

Lets start with a simple Playwright test that launches Chromium and goes to google.com.

simple-test.js
const playwright = require('playwright')
;(async () => {
const browser = await playwright.chromium.launch({
headless: true,
})
const page = await browser.newPage()
await page.goto('https://google.com')
await page.close()
await browser.close()
})()

Updating the test to use the Replay browser is as simple as telling Playwright to launch the Replay browser.

simple-test.js
1const playwright = require('playwright')
2const { getExecutablePath } = require('@replayio/playwright')
3
4;(async () => {
5 const browser = await playwright.chromium.launch({
6 headless: true,
7 executablePath: getExecutablePath('chromium'),
8 env: {
9 ...process.env,
10 RECORD_ALL_CONTENT: 1,
11 RECORD_REPLAY_METADATA: JSON.stringify({
12 title: 'Go to Google',
13 }),
14 },
15 })
16 const page = await browser.newPage()
17 await page.goto('https://google.com')
18
19 await page.close()
20 await browser.close()
21})()

Run node test.js to run and record your tests. And then run replayio upload and upload your new replay.

FAQ

Previous
Playwright