Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Go to file
2020-01-10 21:20:59 -08:00
.ci Initial commit 2019-11-19 10:58:15 -08:00
.github/workflows Update webkit.yml 2020-01-09 17:07:22 -08:00
browser_patches fix(webkit): fix modifier keys for mouse events (#460) 2020-01-10 21:20:59 -08:00
docs feat(pw-web): generate playwright/web.js which can be used in the browser (#455) 2020-01-10 16:03:10 -08:00
src feat(navigation): early return when navigation was canceled by another one (#459) 2020-01-10 17:33:07 -08:00
test feat(navigation): early return when navigation was canceled by another one (#459) 2020-01-10 17:33:07 -08:00
utils feat(pw-web): generate playwright/web.js which can be used in the browser (#455) 2020-01-10 16:03:10 -08:00
.appveyor.yml Initial commit 2019-11-19 10:58:15 -08:00
.cirrus.yml Initial commit 2019-11-19 10:58:15 -08:00
.editorconfig Initial commit 2019-11-19 10:58:15 -08:00
.eslintignore feat: basic d.ts file (#161) 2019-12-06 11:28:23 -08:00
.eslintrc.js lint: fixes (#85) 2019-11-26 08:19:02 -08:00
.gitignore feat(pw-web): generate playwright/web.js which can be used in the browser (#455) 2020-01-10 16:03:10 -08:00
.npmignore feat(pw-web): generate playwright/web.js which can be used in the browser (#455) 2020-01-10 16:03:10 -08:00
.travis.yml chore(ci): use bionic for travis 2019-12-05 15:18:55 -08:00
chromium.js fix: async stacks should work now (#325) 2019-12-20 15:31:20 -08:00
CODE_OF_CONDUCT.md Initial CODE_OF_CONDUCT.md commit 2019-11-15 10:32:47 -08:00
CONTRIBUTING.md docs: preparing readme for public release (#433) 2020-01-08 16:53:57 -08:00
DeviceDescriptors.js chore: cleanup code around device descriptors (#404) 2020-01-07 12:53:06 -08:00
Errors.js chrome: co-locate transport types (#236) 2019-12-12 21:30:49 -08:00
firefox.js fix: async stacks should work now (#325) 2019-12-20 15:31:20 -08:00
index.d.ts feat(pw-web): generate playwright/web.js which can be used in the browser (#455) 2020-01-10 16:03:10 -08:00
index.js feat(pw-web): generate playwright/web.js which can be used in the browser (#455) 2020-01-10 16:03:10 -08:00
install.js docs: unify XYZPlaywright api and docs (#443) 2020-01-09 14:49:22 -08:00
LICENSE chore(license): use Apache 2.0 (#389) 2020-01-06 18:22:35 -08:00
NOTICE chore(license): add NOTICE (#309) 2019-12-19 12:19:54 -08:00
package.json Revert "Revert "feat(firefox): roll Firefox to r1011 (#452)"" 2020-01-11 02:32:28 +01:00
README.md feat(pw-web): generate playwright/web.js which can be used in the browser (#455) 2020-01-10 16:03:10 -08:00
SECURITY.md Initial SECURITY.md commit 2019-11-15 10:32:49 -08:00
tsconfig.json feat: basic d.ts file (#161) 2019-12-06 11:28:23 -08:00
web.d.ts feat(pw-web): generate playwright/web.js which can be used in the browser (#455) 2020-01-10 16:03:10 -08:00
webkit.js fix: async stacks should work now (#325) 2019-12-20 15:31:20 -08:00

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