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-09 15:14:35 -08:00
.ci Initial commit 2019-11-19 10:58:15 -08:00
.github/workflows chore(github): only run tests on the master branch (#446) 2020-01-09 14:29:19 -08:00
browser_patches feat(webkit): pass objectId into Page.accessibilitySnapshot (#445) 2020-01-09 15:14:23 -08:00
docs docs: unify XYZPlaywright api and docs (#443) 2020-01-09 14:49:22 -08:00
src chore(webkit): remove WKPageProxySession, separate connection from browser session (#447) 2020-01-09 15:14:35 -08:00
test chore(webkit): remove WKPageProxySession, separate connection from browser session (#447) 2020-01-09 15:14:35 -08:00
utils feat(testrunner): "sourcemapify" crash error stacktraces (#441) 2020-01-09 16:37:19 +00: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 chore: reuse BrowserFetcher between browsers (#177) 2019-12-08 13:29:03 -08:00
.npmignore chore: mark version v0.9.3 2019-12-14 11:56:34 -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 chore: move webkit server code to src/server (#415) 2020-01-07 16:15:07 -08:00
index.js chore: move webkit server code to src/server (#415) 2020-01-07 16:15:07 -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 feat(webkit): roll webkit to 1078 (#438) 2020-01-08 20:11:10 -08:00
README.md docs: preparing readme for public release (#433) 2020-01-08 16:53:57 -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
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