docs: Page screenshot Example with all TypeScript types (#9549)

This commit is contained in:
Kilian von Pflugk 2021-10-19 01:08:18 +02:00 committed by GitHub
parent 42b535246f
commit 1656c7071e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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