Znote (recipes)
  Get Znote  

Playwright basic automation example

Use Playwright to automate browser action


Playwright demo

npm package installation npm i -S playwright

Open browser and take a screenshot

const { chromium } = require('playwright');

const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://playwright.dev/');

const results = await page.$("[class*=heroTitle]");
const text = await results.evaluate(element => element.innerText);
print(text); // Get text from title
await page.screenshot({ path: '/Users/alagrede/example.png' });
await browser.close();

Related recipes