At first, Run the initial install command: | Karan Kataria

editor-img
Karan Kataria
Dec 10, 2022

Install Playwright: Most Reliable Web Automation Tool.

We can use yarn or npm. Or Alternatively a VScode Extension can also serve the purpose.

Lets have a look how to get playwright using npm.

At first, Run the initial install command:

npm init playwright@latest

*if you don't have Node.js, first run the following commands on cmd/terminal

brew update

brew install node

Playwright will download the browsers needed as well as create some files.

You'll get the following packages installed:

  • playwright.config.ts
  • package.json
  • package-lock.json
  • tests/
  • tests-examples/

The playwright.config is where you can add configuration for Playwright including modifying which browsers you would like to run Playwright on. If you are running tests inside an already existing project then dependencies will be added directly to your package.json.

The tests folder contains a basic example test to help you get started with testing. For a more detailed example check out the tests-examples folder which contains tests written to test a todo app.

By default tests will be run on all 3 browsers, chromium, firefox and webkit using 3 workers. This can be configured in the playwright.config file. Tests are run in headless mode meaning no browser will open up when running the tests. Results of the tests and test logs will be shown in the terminal.

Use the following command to run tests configured in playwright.config file

npx playwright test

To be continued in next post...

Tagged users
editor-img
Avni
@74-faunie
Integrating Software Development and Quality Assurance with Engineering Team @ GlueLabs.
Checkout related posts on: