update snippet

This commit is contained in:
Arjun Attam 2020-01-24 11:17:34 -08:00 committed by GitHub
parent 3bf52d0ce7
commit 7abca5f15c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,16 +42,14 @@ This code snippet navigates to whatsmyuseragent.org in Chromium, Firefox and Web
const pw = require('playwright'); const pw = require('playwright');
(async () => { (async () => {
const browsers = ['chromium', 'firefox', 'webkit']; for (const name of ['chromium', 'firefox', 'webkit']) {
const browser = await pw[name].launch();
browsers.forEach(async browserName => {
const browser = await pw[browserName].launch();
const context = await browser.newContext(); const context = await browser.newContext();
const page = await context.newPage('http://whatsmyuseragent.org/'); const page = await context.newPage('http://whatsmyuseragent.org/');
await page.screenshot({ path: `example-${browserName}.png` }); await page.screenshot({ path: `example-${name}.png` });
await browser.close(); await browser.close();
}); }
})(); })();
``` ```