From 9861cb99c9ab5830aaadbb84659f1fbaf2fc6539 Mon Sep 17 00:00:00 2001 From: Arjun Attam Date: Fri, 24 Jan 2020 09:54:26 -0800 Subject: [PATCH] docs(readme): update hero snippet to illustrate single API --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c83829343f..3e5e42eb57 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 @@ -35,23 +36,27 @@ 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 thismachine.info 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(); + const browsers = ['chromium', 'firefox', 'webkit']; - await page.goto('https://www.example.com/'); - await page.screenshot({ path: 'example.png' }); + browsers.forEach(async browserName => { + 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. ```js