Skip to content

Commit

Permalink
docs(readme): update hero snippet to illustrate single API (#631)
Browse files Browse the repository at this point in the history
* docs(readme): update hero snippet to illustrate single API

* update faqs

* update snippet
  • Loading branch information
arjunattam authored and pavelfeldman committed Jan 24, 2020
1 parent 3abaced commit 834698c
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
###### [API](https://github.com/microsoft/playwright/blob/master/docs/api.md) | [FAQ](#faq) | [Contributing](#contributing)


Playwright is a Node library to automate the [Chromium](https://www.chromium.org/Home), [WebKit](https://webkit.org/) and [Firefox](https://www.mozilla.org/en-US/firefox/new/) browsers. This includes support for the new Microsoft Edge browser, which is based on Chromium.
Playwright is a Node library to automate the [Chromium](https://www.chromium.org/Home), [WebKit](https://webkit.org/) and [Firefox](https://www.mozilla.org/en-US/firefox/new/) browsers with **a single API**. This includes support for the new Microsoft Edge browser, which is based on Chromium.

Playwright is focused on enabling **cross-browser** web automation platform that is **ever-green**, **capable**, **reliable** and **fast**. Our primary goal with Playwright is to improve automated UI testing by eliminating flakiness, improving the speed of execution and offering insights into the browser operation.

Expand All @@ -17,7 +17,8 @@ Playwright is focused on enabling **cross-browser** web automation platform that
| Chromium| 81.0.4032 | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit | 13.0.4 | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Firefox |73.0b3 | :white_check_mark: | :white_check_mark: | :white_check_mark: |
- Headless is supported for all browsers on all platforms.

Headless is supported for all browsers on all platforms.

### Installation

Expand All @@ -35,23 +36,25 @@ Playwright can be used to create a browser instance, open pages, and then manipu

#### Page screenshot

This code snippet navigates to example.com in WebKit, and saves a screenshot.
This code snippet navigates to whatsmyuseragent.org in Chromium, Firefox and WebKit, and saves 3 screenshots.

```js
const pw = require('playwright');

(async () => {
const browser = await pw.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();
for (const name of ['chromium', 'firefox', 'webkit']) {
const browser = await pw[name].launch();
const context = await browser.newContext();
const page = await context.newPage('http://whatsmyuseragent.org/');

await page.screenshot({ path: `example-${name}.png` });
await browser.close();
}
})();
```

#### Mobile and geolocation

This snippet emulates Mobile Safari on a device at a given geolocation, navigates to maps.google.com, performs action and takes a screenshot.

```js
Expand Down Expand Up @@ -130,6 +133,10 @@ Check out our [contributing guide](https://github.com/microsoft/playwright/blob/

## FAQ

**Q: Can I use a single API to automate different browsers?**

Yes, you can. See [Browser](https://github.com/microsoft/playwright/blob/master/docs/api.md#class-browser) in the API reference for the common set of APIs across Chromium, Firefox and WebKit. A small set of features are specific to browsers, for example see [ChromiumBrowser](https://github.com/microsoft/playwright/blob/master/docs/api.md#class-chromiumbrowser).

**Q: How does Playwright relate to [Puppeteer](https://github.com/puppeteer/puppeteer)?**

Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer project is active and is maintained by Google.
Expand Down

0 comments on commit 834698c

Please sign in to comment.