mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-07 11:46:42 +03:00
docs: Page screenshot Example with all TypeScript types (#9549)
This commit is contained in:
parent
42b535246f
commit
1656c7071e
@ -48,12 +48,12 @@ This code snippet navigates to whatsmyuseragent.org in Chromium, Firefox and Web
|
|||||||
const playwright = require('playwright');
|
const playwright = require('playwright');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
for (const browserType of ['chromium', 'firefox', 'webkit']) {
|
for (const browserType of [playwright.chromium, playwright.firefox, playwright.webkit]) {
|
||||||
const browser = await playwright[browserType].launch();
|
const browser = await browserType.launch();
|
||||||
const context = await browser.newContext();
|
const context = await browser.newContext();
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
await page.goto('http://whatsmyuseragent.org/');
|
await page.goto('http://whatsmyuseragent.org/');
|
||||||
await page.screenshot({ path: `example-${browserType}.png` });
|
await page.screenshot({ path: `example-${browserType.name()}.png` });
|
||||||
await browser.close();
|
await browser.close();
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user