Playwright-Framework-Template - This project is based on Microsoft Playwright, Appium, Artillery which enables reliable end-to-end testing, Web testing, API testing, Mobile testing, load testing. It is a single unified for your entire testing suite : UI, API, Mobile, Load testing.
☝ If you liked the project, please give a ⭐ on GitHub. It will motivate me to add more such project.
_☝ If you want new feature to be added or you believe you've encountered a bug [Open an issue] (https://github.com/abhaybharti/playwright-framework-template/issues) .
- Cross-Browser Testing: Chromium, Firefox,WebKit, Edge
 - Multipel Test Types: UI, API, Mobile, Load Testing, Visual Testing
 - Page Object Model: Scalable & maintainable test architecture
 - JSON Config: Build script
 - Dependency Injection: Custom Fixtures, TypeScript Decorators for clean test & function code
 - Comprehenisve Reporting: HTML, Log file, Video, Trace, Screenshot,
 - Capture API: HTML, Log file, Video, Trace, Screenshot,
 
- Easy to Configure
 - Auto wait for all elements & checks
 - Generate HTML report
 - Generate detailed trace file which helps to debug
 - Generate snapshot for each step
 - Record video for test case execution
 - Support Web automation with support for chrome, Edge, Firefox and Safari
 - Support Mobile automation with support for Android native, web and hybrid apps automation
 - Support iOS native, web and hybrid apps automation
 - Support execution of Web tests on Microsoft Azure (can scale on demand)
 - Support API testing (GET, POST, PUT, DELETE HTTP methods)
 - Dynamic data handling using external JSON files
 - Support taking screenshots
 - Run functional test for load testing using Artillery
 - Support Serial and Parallel execution
 - Environment configuration using .env files
 
- PlayWright - for web/API automation/Mobile Device Emulation Testing
 - Artillery - for load testing
 - Appium - for mobile app automation
 - ESLint - pinpoint issues and guide you in rectifying potential problems in both JavaScript and TypeScript.
 - Prettier - for formatting code & maintain consistent style throughout codebase
 - Dotenv - to load environment variables from .env file
 - Secrets - to load secrets from AWS Secrets Manager
 - TypeScript - for type safety
 - Joi - for data validation
 - Moment - for date & time handling
 - Winston - for logging
 - Mocha - for test runner
 - Chai - for assertion
 
srchelper/api/apiHelper.tscontains functions for making HTTP requests/load/loadHelper.tscontains functions generating load on UI/Api/mobile/mobileHelper.tscontains functions for interacting with mobile apps/web/webHelper.tscontains functions for interacting with browser
testscontains utility functionsapiplace to write api testsexamplecontains example api tests using this framework
webplace to write web testsexamplecontains example api tests using this framework
loadplace to write load testsexamplecontains example api tests using this framework
mobileplace to write mobile testsexamplecontains example api tests using this framework
utilscontains utility functionsconfigcontains config filesreportcontains report function filesdataStore.jsacts as a in-memory data store. It is used to save data that needs to be shared between different test case
test-resultscontains test resultsharcontains har file generated by playwright testslogscontains logs
nodejs: Download and install Node JS fromhttps://nodejs.org/en/downloadVisual Studio Code/Aqua/IntelliJ: Download and install code editor
- 
clone the repo using below URL
https://github.com/abhaybharti/playwright-framework-template.git - 
Navigate to folder and install npm packages using:
npm install - 
For first time installation use below command to download required browsers:
npx playwright install - 
In case you want to do fresh setup of playwright
- Create a folder & run command 
npm init playwright@latest - select 
TypeScript& select default for other options 
 - Create a folder & run command 
 
- For browser configuration, change required parameters in playwright.config.ts
 - To run your suite on MS Azure, copy the below code in 
azure-pipeline.ymlandplaywright.service.config.tsto root folder, update following key & run your suite- PLAYWRIGHT_SERVICE_ACCESS_TOKEN
 - PLAYWRIGHT_SERVICE_URL=XXX
 
 
- run command 
npx playwright codegen - Browser gets opened & navigate to web app & perform test actions
 
Playwright test generator generates tests and pick locator for you. It uses role,text and test ID locators.
To pick a locator, run the codegen command followed by URL, npx playwright codegen https://opensource-demo.orangehrmlive.com/web/index.php/auth/login
- Create test files in 
src/testsfolder 
Note: Refer to sample-web-test
Pls go through different \*.ts file, which has tests example for different purpose.
Note: Refer to sample-web-test
Note: Refer to sample-api-test
Pls go through different \*.ts files, which has tests example for different api tests.
npx playwright test (name-of-file.spec.ts) --headedto run test in ui modenpx playwright test (name-of-file.spec.ts) --headed --config=playwright.config.chrome.tsto run test in ui mode on chrome browsernpx playwright test (name-of-file.spec.ts) --headed --config=playwright.config.firefox.tsto run test in ui mode on firefox browsernpx playwright test (name-of-file.spec.ts) --headed --config=playwright.config.edge.tsto run test in ui mode on edge browser
npx playwright test --workers=5 --headed --repeat-each=5
- This will run test 5 times, at a time 5 instance will run. 
--workers=5will run 5 instances 
npx playwright test --workers=1 --headed --repeat-each=5
- This will run test 5 times, at a time single instance will run, 
--repeat-each=5will run 5 times 
artillery run artillery-script.yml --output report.json
npx playwright test --grep @smoke This will run only test tagged as @smoke
- Open 
https://trace.playwright.dev - Upload 
trace.zipfile to above site, it will show trace details 
npx playwright test UIBasictest.spec.js --debug
This will start running script in debug mode & open PlayWright inspector
artillery report report.json --output report.html
Create isolated test cases: Each test case should be independent.Write Meaningful Test Case Titles: Make your test case titles descriptive and meaningful.Follow the AAA (Arrange-Act-Assert) Pattern: Align your Test-Driven Development (TDD) approach with the clarity of Arrange, Act, and Assert.Maintain Cleanliness: Separate additional logic from tests for a tidy and focused codebase.
We love our contributors! Here's how you can contribute:
- Open an issue if you believe you've encountered a bug.
 - Make a pull request to add new features/make quality-of-life improvements/fix bugs.
 
g