A Python-based test automation framework using Playwright and pytest.
python3 -m venv env
source env/bin/activate #For mac/unix userspip install -r requirements.txt
playwright install # Install browser binaries# Run all tests
pytest
# Run specific test file
pytest src/tests/test_gap.py
# Run specific test
pytest src/tests/test_gap.py::test_search
# Run with verbose output
pytest -v
# Run in headed mode (see browser)
pytest --headed
# Run with slow motion (1000ms delay between actions)
pytest --headed --slowmo 1000# Generate HTML report in reports directory
pytest --html=reports/report.html --self-contained-html
# With verbose output
pytest -v --html=reports/report.html --self-contained-html
# Run specific test with HTML report
pytest src/tests/test_gap.py::test_search -v --html=reports/report.html --self-contained-htmlScreenshots are automatically captured when tests fail and saved to the screenshots/ directory.
Filename format: {test_name}_{timestamp}.png
playwright_demo/
src/
pages/ # Page Object Model classes
gap_home_page.py
bestbuy_home_page.py
tests/ # Test files
conftest.py # Pytest configuration and fixtures
test_gap.py # Test cases
test_bestbuy.py # Test cases
screenshots/ # Auto-generated screenshots on failure
reports/ # HTML test reports
pytest.ini # Pytest configuration
requirements.txt # Python dependencies
- Default log level: INFO
- Verbose output enabled
- Short tracebacks
- Custom log format with timestamps
- Browser viewport: 1920x1080
- Default expect timeout: 10s (configurable via
--expect-timeout) - Automatic screenshot capture on test failure
- Browser context and page fixtures
# Set custom expect timeout (in milliseconds)
pytest --expect-timeout=15000# Run all tests with HTML report
pytest -v --html=reports/report.html --self-contained-html
# Run search test in headed mode with report
pytest src/tests/test_gap.py::test_search -v --headed --html=reports/report.html --self-contained-html
# Debug mode: headed + slow motion + verbose
pytest src/tests/test_gap.py::test_search -v --headed --slowmo 1000