Skip to content

Instantly share code, notes, and snippets.

@OJ7
Created July 8, 2023 16:14
Show Gist options
  • Save OJ7/71d2cae2a9233b098a2c9d7e6823311b to your computer and use it in GitHub Desktop.
Save OJ7/71d2cae2a9233b098a2c9d7e6823311b to your computer and use it in GitHub Desktop.
Open Interactive Playwright in Node session (run code in real time in browser)
/**
* Run the following in your terminal:
* npm i playwright-firefox
* npx playwright install --with-deps
* node --experimental-repl-await
*/
// Modify/paste the following in the interactive console:
const { firefox } = require('playwright-firefox');
const BROWSER_DIR = '/full/path/to/dir'; # eg /Users/myuser/Documents/playwright-testing/
const URL = 'https://playwright.dev/';
const context = await firefox.launchPersistentContext(BROWSER_DIR, {
headless: false,
viewport: { width: 1280, height: 1280 },
});
const page = context.pages().length ? context.pages()[0] : await context.newPage();
await page.goto(URL);
// ... perform interactive testing here ...
await browser.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment