Usage
Once installed, you can require
Playwright in a Node.js script, and launch any of the 3 browsers (chromium
, firefox
and webkit
).
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
// Create pages, interact with UI elements, assert values
await browser.close();
})();
Playwright APIs are asynchronous and return Promise objects. Our code examples use the async/await pattern to simplify comprehension. The code is wrapped in an unnamed async arrow function which is invoking itself.
(async () => { // Start of async arrow function
// Function code
// ...
})(); // End of the function and () to invoke itself
本译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。