Welcome to the Playwright API and UI Testing Project Framework.
This project uses Playwright with Typescript to create and run the Automated UI and API Tests for WebApps.
- Latest version of GitSCM is installed/supported on your system
- Latest version of NodeJS is installed/supported on your system
- IDE that supports ESLint & Prettier (VSCode will be used as the team standard)
- Clone the repo into a suitable folder on your local machine (preferably 'C:\repos' to keep the path as short as possible)
- Once cloned, open up the repository in your IDE of choice
- Ensure your working repository is '..\playwright-ui-component-test-skeleton' in your terminal for all commands below
-
Install the following extensions on your IDE:
-
Install all dependencies for project:
npm i
-
Install all browsers for playwright:
npx playwright install
-
Install the "dotenv" package for playwright:
npm install dotenv
-
Install monochart package for playwright:
npm i -D monocart-reporter
-
Create an '.env' file in the root directory
-
Or you can type the following in cmd at the root directory of the project:
CMD - 'type nul > .env' Powershell - 'ni .env' Terminal - 'touch .env'
-
-
Populate the .env file with the necessary variables values
-
The minimum required variables to be populated are:
-
LOGIN_URL=https://www.saucedemo.com/ USER1_ID= USER1_USERNAME= USER1_PASSWORD=
USER2_ID= USER2_USERNAME= USER2_PASSWORD=
USER3_ID= USER3_USERNAME= USER3_PASSWORD=
USER4_ID= USER4_USERNAME= USER4_PASSWORD=
USER_FIRST_NAME= USER_LAST_NAME= USER_POSTAL_CODE= ```
-
Run the tests using the Playwright Test for VSCode Extension or run the command below in terminal:
npx playwright test
- The test evidence aritifact will be in the monocart-report folder that will be created when you run command number 4
- When you run the pipeline on github the testevidence artifact can be downloaded from the upload playwright report folder
-
- Ensure you have the playwright browsers installed by running '
npx playwright install
'
- Ensure you have the playwright browsers installed by running '
-
- Ensure the
.env
file is created in the root directory of the project - Ensure all the required
.env
variables are populated
- Ensure the
-
Run all the the end-to-end tests:
npx playwright test
-
Start the interactive UI mode:
npx playwright test --ui
-
Run the tests only on Desktop Chrome:
npx playwright test --project=chromium
-
Run the tests in a specific file called 'example':
npx playwright test example
-
Run the tests in debug mode:
npx playwright test --debug
-
Auto generate tests with Codegen:
npx playwright codegen