The project automates functional testing of the SauceDemo website using Selenium WebDriver, pytest and Page Object Model (POM).
- Python 3.11+
- Selenium 4.x
- pytest 8.x
- webdriver-manager 4.x
- Firefox / Chrome
- pytest-html (raporty w HTML)
- Clone repository:
git clone <repo-url>
cd <project-folder>- Create virtual environment:
python -m venv .venv3.Activate virtual environment: Windows
.venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtpytest -v- Tests use Firefox by default.
- All tests automatically open the browser, perform actions, and close it after the test.
You can generate reports in HTML using pytest-html:
pytest --html=reports/report.html --self-contained-htmlThe report will be saved in the reports/ folder (you'll need to create it if it doesn't exist). It contains test details, results, etc.
project/
│
├── core/ # Configuration and global settings
│ └── config.py # URLs, test data, constants
│
├── pages/ # Page Object Models
│ ├── base_page.py
│ ├── login_page.py
│ ├── inventory_page.py
│ ├── cart_page.py
│ └── checkout_page.py
│
├── tests/ # Automated tests
│ ├── test_login.py
│ ├── test_inventory.py
│ ├── test_cart.py
│ └── test_checkout.py
│
├── conftest.py # Pytest fixtures
├── requirements.txt # Dependency list
├── reports/ # HTML test reports
└── README.md # Documentation
- Page Object Model – each page has its own class in pages/.
- Private locators begin with __, helper methods begin with _.
- Public methods describe user actions (e.g., login, add_to_cart, checkout_overview).
- checkout_overview).
- Configuration data (URLs, logins, passwords) is located in core/config.py.
- Login success and failure (test_login.py)
- Sorting products by name and price (test_inventory.py)
- Adding/removing products from the cart (test_cart.py)
- Checkout and price total verification (test_checkout.py)