docs(readme): update hero snippet to illustrate single API

This commit is contained in:
Arjun Attam 2020-01-24 09:54:26 -08:00 committed by GitHub
parent ff877014cd
commit 9861cb99c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,7 +7,7 @@
###### [API](https://github.com/microsoft/playwright/blob/master/docs/api.md) | [FAQ](#faq) | [Contributing](#contributing) ###### [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. 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.
@ -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: | | 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: | | 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: | | 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 ### Installation
@ -35,23 +36,27 @@ Playwright can be used to create a browser instance, open pages, and then manipu
#### Page screenshot #### Page screenshot
This code snippet navigates to example.com in WebKit, and saves a screenshot. This code snippet navigates to thismachine.info in Chromium, Firefox and WebKit, and saves 3 screenshots.
```js ```js
const pw = require('playwright'); const pw = require('playwright');
(async () => { (async () => {
const browser = await pw.webkit.launch(); // or 'chromium', 'firefox' const browsers = ['chromium', 'firefox', 'webkit'];
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://www.example.com/'); browsers.forEach(async browserName => {
await page.screenshot({ path: 'example.png' }); const browser = await pw[browserName].launch();
const context = await browser.newContext();
const page = await context.newPage('http://thismachine.info/');
await browser.close(); await page.screenshot({ path: `example-${browserName}.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. This snippet emulates Mobile Safari on a device at a given geolocation, navigates to maps.google.com, performs action and takes a screenshot.
```js ```js