JSPM

playwright

0.9.12
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 18189680
  • Score
    100M100P100Q208395F
  • License Apache-2.0

A high-level API to automate web browsers

Package Exports

  • playwright

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (playwright) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Playwright

npm version

Build Status
Chromium Chromium
Firefox Firefox
WebKit WebKit

Playwright is a Node library to automate the Chromium, Webkit and Firefox browsers.

Getting started

Installation

npm i playwright

Usage

Playwright can be used to create a browser instance, open pages, and then manipulate them. See API docs for a comprehensive list.

Examples

Page screenshot

This code snippet navigates to example.com in WebKit, and saves a screenshot.

const pw = require('playwright');

(async () => {
  const browser = await pw.playwright('webkit').launch(); // or 'chromium', 'firefox'
  const context = await browser.newContext();
  const page = await context.newPage();

  await page.goto('https://www.example.com/');
  await page.screenshot({ path: 'example.png' });

  await browser.close();
})();

Evaluate script

This code snippet navigates to example.com in Firefox, and executes a script in the page context.

const pw = require('playwright');

(async () => {
  const browser = await pw.playwright('firefox').launch(); // or 'chromium', 'webkit'
  const context = await browser.newContext();
  const page = await context.newPage();

  await page.goto('https://www.example.com/');
  const dimensions = await page.evaluate(() => {
    return {
      width: document.documentElement.clientWidth,
      height: document.documentElement.clientHeight,
      deviceScaleFactor: window.devicePixelRatio
    }
  })
  console.log(dimensions);

  await browser.close();
})();

Credits

Playwright has code derived from the Puppeteer project, available under the Apache 2.0 license.

FAQs

Q: What are the goals of Playwright?

Playwright is focused to enable cross-browser web automation scripts that are reliable and fast. Our primary goal with Playwright is to improve automated UI testing by eliminating flakiness and improving the speed of execution.

Q: How does Playwright compare against Puppeteer?

[WIP]

Puppeteer is a Node library to automate the Chromium browser through the Chrome DevTools Protocol. It enables fast, rich and reliable automation scripts for Chromium.

Playwright introduces similar bi-directional protocols for the Firefox and WebKit browsers, extending Puppeteer's capabilities to enable cross-browser automation.

Q: Is Playwright ready?

Playwright is actively developed as we get to feature parity across Chromium, Firefox and WebKit. Progress on each browser can be tracked on the Is Playwright Ready? page, which shows test coverage per browser.

Resources