Playwright launches headless browsers by default. Headless browsers don't display a UI, so instead you must use the command line. You can also configure Playwright to run full (non-headless) Microsoft Edge as well.
Install Playwright and browsers
Pastaba
Playwright requires Node.js version 12 or above. Run node -v from the command line to make sure you have a compatible version of Node.js. The browser binaries for Chromium, Firefox and WebKit work across Windows, macOS, and Linux. For more information, see Playwright System Requirements.
To install browsers, run the following command, which downloads Chromium, Firefox, and WebKit:
Console
npx playwright install
Run a basic test
The approach used by Playwright will be familiar to users of other browser-testing frameworks, such as WebDriver or Puppeteer. You can create an instance of the browser, open a page in the browser, and then manipulate the page by using the Playwright API.
Playwright Test, which is Playwright's test-runner, launches a browser and context for you. An isolated page is then passed into every test, as shown in the following, basic test:
To run your tests in Microsoft Edge, you need to create a config file for Playwright Test, such as playwright.config.ts. Inside the config file, create one project, using Microsoft Edge.
example.js is a simple demonstration of the automation and testing scenarios that are enabled by Playwright. To take screenshots in other web browsers, change the above code from await playwright.chromium.launch to the following code:
Firefox:
JavaScript
const browser = await playwright.firefox.launch({
WebKit:
JavaScript
const browser = await playwright.webkit.launch({
For more information about Playwright and Playwright Test, go to the Playwright website. Check out the Playwright repo on GitHub. To share your feedback on automating and testing your website or app with Playwright, file an issue.
In this module, you'll learn how to use Playwright to test a sample web application. You'll learn how to run tests, view test reports, and understand the structure of a Playwright project. You'll also learn how to use Visual Studio Code to run tests, debug tests, and record new tests.