First script
In our first script, we will navigate to whatsmyuseragent.org
and take a screenshot in WebKit.
const { webkit } = require('playwright');
(async () => {
const browser = await webkit.launch();
const page = await browser.newPage();
await page.goto('http://whatsmyuseragent.org/');
await page.screenshot({ path: `example.png` });
await browser.close();
})();
By default, Playwright runs the browsers in headless mode. To see the browser UI, pass the headless: false
flag while launching the browser. You can also use slowMo
to slow down execution.
firefox.launch({ headless: false, slowMo: 50 });
本译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。