Playwright Project

This project is set up for automation testing using Playwright. It includes example tests and configurations to help you get started with end-to-end testing.
Project Structure
tests/: Contains all the test files.
- e2e/: End-to-end tests. - fixtures/: Test data and utility functions.
playwright.config.ts: Configuration file for Playwright.package.json: Lists dependencies and scripts.tsconfig.json: TypeScript configuration file.
Setup Instructions
Local Setup
- Clone the repository:
git clone
cd playwright-project- Install dependencies:
npm installDocker Setup
You can also run tests in Docker containers, which ensures consistent test environments and multi-browser testing:
- Make sure you have Docker and Docker Compose installed:
docker --version
docker-compose --version- Build the Docker containers:
docker-compose build- Run tests in all browsers (Chrome, Firefox, and WebKit):
docker-compose upOr run tests in specific browsers:
docker-compose up chrome-tests # Run only Chrome tests
docker-compose up firefox-tests # Run only Firefox tests
docker-compose up webkit-tests # Run only WebKit tests- To stop the containers:
docker-compose downThe Docker setup provides:
- Isolated test environment
- Parallel test execution across browsers
- Consistent browser versions
- No need to install browsers locally
- Set up environment variables:
cp .env.example .envEdit the .env file with your actual credentials. You can get the test credentials from: - https://www.saucedemo.com/ (for public test users) - Your team lead or project documentation (for private credentials)
IMPORTANT: - Never commit the .env file to the repository - Never share your credentials in public - If you accidentally commit credentials, change them immediately
- Run the tests:
npx playwright testContinuous Integration
This project uses GitHub Actions for continuous integration. The workflow:
- Runs on every push to main branch
- Runs on every pull request to main branch
- Installs dependencies and Playwright
- Sets up environment variables from GitHub Secrets
- Runs all tests
- Uploads test reports as artifacts
Setting up GitHub Secrets
Before the CI can run tests, you need to set up these secrets in your GitHub repository:
- Go to your repository settings
- Navigate to Secrets and Variables > Actions
- Add the following secrets:
- STANDARD_USER - STANDARD_PASSWORD - LOCKED_USER - LOCKED_PASSWORD - PROBLEM_USER - PROBLEM_PASSWORD - PERFORMANCE_USER - PERFORMANCE_PASSWORD
Test Reports
After each test run, a test report is generated and uploaded as an artifact. You can:
- Go to the Actions tab in your repository
- Click on the workflow run
- Download the playwright-report artifact
- Extract and open
playwright-report/index.htmlin your browser
Usage Guidelines
- Add your test cases in the
tests/e2e/directory. - Use the
tests/fixtures/test-data.tsfile to define any mock data or utility functions needed for your tests. - Modify the
playwright.config.tsfile to adjust settings as necessary.
License
This project is licensed under the MIT License.
