Installing Playwright Test Runner
Playwright is an open-source framework developed by Microsoft for web testing and automation. It enables testing on all modern rendering engines, including Chromium, Firefox, and Webkit, with a single API. Playwright enables cross-browser web automation that is reliable, capable, and fast.
Playwright has its own test runner to accommodate end-to-end testing needs.
Getting Started with Playwright Test Runner
Using init command
From project’s root directory, run the following command:
npm init playwright@latest
Choose the default options
A configuration file, a GitHub Action workflow, and a first test example.spec.ts are created.
playwright.config.ts
package.json
package-lock.json
tests/
example.spec.ts
tests-examples/
demo-todo-app.spec.ts
Manually
Run the following commands to install dependencies and browsers:
npm i -D @playwright/test
# install supported browsers
npx playwright install
Installing specific browsers
# to install webkit
npx playwright install webkit
# to install firefox
npx playwright install firefox
# to install chromium
npx playwright install chromium
Using branded browsers
By default, Playwright uses open-source Chromium builds. That is, if Google Chrome is on version N, then Playwright's latest version supports Chromium N+1, which will be released in Google Chrome and Microsoft Edge a few weeks later.
Tip: Always keep Playwright up to date so the tests can catch failures on the upcoming browser version.
However, sometimes there could be a requirement to run the tests against branded browsers. To enable test runs on stable Chrome version, go to `playwright.config.ts` and add a new project to use the chrome channel:
export default defineConfig({
projects: [
/* Test against branded browsers. */
{
name: 'Google Chrome',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
},
...other browsers
],
});