This project contains automated UI tests for the Demoblaze website using Selenium, structured with the Page Object Model and powered by Pytest.
These tests were designed to:
- Scrape product data for use in analysis or test databases.
- Automate a full purchase flow using the shopping cart.
- Validate cart contents with one or more products.
- Demonstrate good practices: waits, fixtures, modularity.
- Python 3.9+
- Google Chrome
- ChromeDriver (auto-managed via
webdriver-manager)
Install dependencies:
pip install -r requirements.txtIf no
requirements.txtexists, install manually:
pip install selenium pytest webdriver-managerFrom the root of the project:
Run all tests:
pytest -vRun only required tests:
pytest -v -m mandatoryRun only optional/bonus tests:
pytest -v -m optional.
├── pages/
│ ├── home_page.py # Home interactions
│ ├── product_page.py # Product detail page
│ └── cart_page.py # Cart and checkout
│
├── tests/
│ └── test_scraper.py # All test cases (scraping + purchase + optional)
│
├── products.txt # Output from the scraping testtest_scrape_products: saves info from the first 2 pages toproducts.txttest_purchase_flow_add_to_cart: completes a full product purchase
test_multiple_products_cart_total: adds 2 products to the cart and validates them
- The
--headlessmode can be disabled indriver()fixture to watch the tests in Chrome. - The site is a demo and may return inconsistent results occasionally. All critical interactions use
WebDriverWait.
Andrea Balestra