Table of Contents
About the Project
Technology
Prerequisites
Installation
Using Inspector
Command lines
Allure Report
Table of Contents
- Playwright
- Typescript
- excel-js
- adm-zip
- ESLint
- Lighthouse
- pdfjs-dist-es5
- allure-playwright
- allure-commandline
You need the following prerequisites installed on your device to be able to run and contribute to this project:
- Git -> Download Git or Download GitHub Desktop
- Visual Studio Code -> Download VSCode
- NodeJS -> Download NodeJS
- Getting start from the Playwright docs
- Playwright marketplace-> Installing Playwright test for VS Code
Note: Always make sure to download the latest stable version compatible with your OS and CPU architecture.
- Clone the project using GitHub Dekstop.
- Ensure that you've installed the official Playwright VS Code plugin, and ran this Command line in the project root directory.
npm install
- Open the project folder in VS Code by clicking
File > Open Folder...
. - Open the terminal by clicking and run this commnad line
npm init playwright@latest
- Updae Node JS
npm i
- Update playwright
npm install -D @playwright/test@latest
- Check version
npx playwright --version
For better inspector run this command and click on any element to inspect it.
npx playwright codegen playwright.dev
👉 Click here to see the command lines
- Update packages
npm i
- Check Playwright Current Version
npx @playwright/test --version
- Update Playwright to the latest version
npm install @playwright/test@latest
- Running All tests run this command
npx playwright test
- Running the tests in headless mode run this command
npx playwright test --headed
- Running a single test run this command
npx playwright test googleTest.spec.ts
- Running a set of test run this command
npx playwright tests/googleTests
- Generating the report run this command
npx playwright show-report reports/playwright-report
- Generate and serve a temporary allure report by running this command
allure serve reports/allure-results
- Generate and open report by running this command to generate the report
allure generate reports/allure-results -o allure-report --clean
and then this command to open the report
allure open allure-report
- Open the monocart-report -which provides a lightweight tree view for all your tests in a single file- by opening this file in your preferred browser
reports/monocart-report/report.html
. - Open the native playwright-report by opening this file in your preferred browser
reports/playwright-report/index.html
. - You can open the saved trace using Playwright CLI or in your browser on trace.playwright.dev.
npx playwright show-trace path/trace.zip
- You can download the
trace.zip
file from any of the reports, or explore them manually under thereports/test-artifacts/
directory. To open a playwright trace report you should use your preferred browser to navigating to Playwright Trace Viewer, and then drag/drop the trace archive file to open it.
👉 Steps to using allure report
- Step 1: install the allure-playwright node package
npm i -D allure-playwright
- Step 2: Install the allure-commandline node package. Allure Commandline is a tool to generate Allure report from test results. Allure requires Java 8 or higher. To install, use the command:
npm i -D allure-commandline
- Step 3: Now to run the tests with allure-playwright reporter we will use the command:
npx playwright test --reporter=line, allure-playwright
- Step 4: Using the allure commandline we will now generate the allure report. To do that we will use the command:
npx allure generate ./allure-results --clean
- Step 5: Finally, we will open the HTML report on a browser using the command:
npx allure open ./allure-report
👉 Click here to see the project structure
📦 Test Automation using Playwright
┣ 📂.github
┃ ┗ 📂workflows
┃ ┃ ┗ 📜CI.yml
┣ 📂reports
┃ ┣ 📂allure-results
┃ ┣ 📂downloads
┃ ┣ 📂lightHouse-report
┃ ┣ 📂logd
┃ ┣ 📂monocart-report
┃ ┣ 📂playwright-report
┃ ┣ 📂test-artifacts
┣ 📂src
┃ ┣ 📂lib
┃ ┃ ┣ 📜ApiActions.ts
┃ ┃ ┣ 📜BaseFixtures.ts
┃ ┃ ┣ 📜CustomeReporter.ts
┃ ┃ ┣ 📜DBActions.ts
┃ ┃ ┣ 📜FakerData.ts
┃ ┃ ┣ 📜FileActions.ts
┃ ┃ ┣ 📜Helper.ts
┃ ┃ ┣ 📜PageBase.ts
┃ ┃ ┣ 📜WebActions.ts
┃ ┣ 📂pages
┃ ┃ ┣ 📂examples
┃ ┃ ┣ 📂google
┃ ┃ ┣ 📂nopCommerce
┣ 📂tests
┃ ┣ 📂data
┃ ┣ 📂e2e
┣ 📂typescript
┣ 📜.gitignore
┣ 📜config.ts
┣ 📜global-setup.js
┣ 📜global-tearDown.js
┣ 📜package-lock.json
┣ 📜package.json
┣ 📜playwright.config.json
┣ 📜README.md
┗ 📜tsconfig.xml