Skip to content

Commit 834698c

Browse files
arjunattampavelfeldman
authored andcommitted
docs(readme): update hero snippet to illustrate single API (#631)
* docs(readme): update hero snippet to illustrate single API * update faqs * update snippet
1 parent 3abaced commit 834698c

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
###### [API](https://github.com/microsoft/playwright/blob/master/docs/api.md) | [FAQ](#faq) | [Contributing](#contributing)
88

99

10-
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.
10+
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.
1111

1212
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.
1313

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

2223
### Installation
2324

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

3637
#### Page screenshot
3738

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

4041
```js
4142
const pw = require('playwright');
4243

4344
(async () => {
44-
const browser = await pw.webkit.launch(); // or 'chromium', 'firefox'
45-
const context = await browser.newContext();
46-
const page = await context.newPage();
47-
48-
await page.goto('https://www.example.com/');
49-
await page.screenshot({ path: 'example.png' });
50-
51-
await browser.close();
45+
for (const name of ['chromium', 'firefox', 'webkit']) {
46+
const browser = await pw[name].launch();
47+
const context = await browser.newContext();
48+
const page = await context.newPage('http://whatsmyuseragent.org/');
49+
50+
await page.screenshot({ path: `example-${name}.png` });
51+
await browser.close();
52+
}
5253
})();
5354
```
5455

56+
#### Mobile and geolocation
57+
5558
This snippet emulates Mobile Safari on a device at a given geolocation, navigates to maps.google.com, performs action and takes a screenshot.
5659

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

131134
## FAQ
132135

136+
**Q: Can I use a single API to automate different browsers?**
137+
138+
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).
139+
133140
**Q: How does Playwright relate to [Puppeteer](https://github.com/puppeteer/puppeteer)?**
134141

135142
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.

0 commit comments

Comments
 (0)