This project demonstrates how to automate login testing for saucedemo.com using both Playwright for TypeScript/JavaScript and Playwright for Python.
- Node.js (for TypeScript/JavaScript tests)
- Python 3 (preferably installed via Homebrew, for Python tests)
- uv (for Python dependency management)
- Install dependencies:
npm install
- Install Playwright browsers:
npx playwright install
- To run the login test in headless mode (no UI):
npx playwright test login.spec.ts - To run the test in headed mode (show browser UI):
npx playwright test login.spec.ts --headed
- Playwright for TypeScript/JavaScript provides an interactive UI for running and debugging tests.
- To launch the Playwright Test Runner UI:
npx playwright test --ui - This opens a graphical interface where you can select, run, debug, and inspect tests interactively.
- Note: The
--uiflag is not available in the Python version of Playwright.
- Create and activate the virtual environment (if not already):
uv venv --python $(which python3) .venv source .venv/bin/activate
- Install dependencies:
uv pip install -r requirements.txt playwright install
- To run the login test in headless mode (no UI):
pytest test_login_saucedemo.py
- To run the test in headed mode (show browser UI):
Edit
test_login_saucedemo.pyand changeheadless=Truetoheadless=Falsein the line:Then run:browser = p.chromium.launch(headless=True) # Change to: browser = p.chromium.launch(headless=False)
pytest test_login_saucedemo.py
login.spec.ts— Playwright test in TypeScripttest_login_saucedemo.py— Playwright test in Pythonrequirements.txt— Python dependenciespackage.json— Node.js dependencies
- Both test scripts perform login to saucedemo.com using the credentials:
- Username:
standard_user - Password:
secret_sauce
- Username:
- Make sure to install all dependencies and browsers before running tests.