Skip to content

AbrarRagib/Amazon-UI-Automation

Repository files navigation

🛒 Amazon UI Automation — Selenium + Python

End-to-end UI test automation framework for Amazon.com, built with Selenium WebDriver and Python using the Page Object Model.

Selenium UI Tests Python Selenium pytest Allure POM CI

Covers the full shopper journey — registration, login, search, filtering & sorting, product details, cart, checkout, and profile — with data-driven testing, cross-browser execution, rich reporting, and CI/CD.

A portfolio project demonstrating a production-style QA / SDET automation framework. Sister project (same coverage with Playwright): daraz-ui-automation


🎯 What this project demonstrates (CV skill map)

# Skill area How it's implemented here
1 Test Automation Development Selenium WebDriver scripts, Page Object Model, reusable BasePage + utility methods, explicit-wait strategy (zero sleep-driven flakiness), pytest for execution & assertions
2 Functional Testing Registration, Login/Logout, Search, Filter & Sort, Product Details, Add to Cart, Update Qty, Remove Item, Checkout, Order Confirmation, Profile
3 Validation Activities UI elements, form validation, error messages, product info, price-format checks, cart totals, order summary, navigation & footer links (soft assertions)
4 Cross-Browser Testing Chrome, Firefox, and Microsoft Edge via a single --browser switch (Selenium Manager auto-resolves drivers — no binaries in the repo)
5 Data-Driven Testing External CSV, JSON, and Excel data via pytest.mark.parametrize (the Python/Selenium equivalent of TestNG @DataProvider)
6 Reporting pytest-html (self-contained) + Allure reports, automatic screenshots & page-source capture on failure
7 Version Control Git + GitHub, clean structure, .gitignore, secrets kept out of the repo (.env + example template)
8 CI/CD GitHub Actions (3-browser matrix, scheduled weekly regression, manual dispatch with marker selection, merged Allure report) and a Jenkinsfile pipeline
9 Bug Reporting docs/BUG_REPORT_TEMPLATE.md + docs/SAMPLE_BUG_REPORTS.md with reproduction steps, each mapped to its automated regression guard
10 Regression Testing regression marker + a suite run after feature changes; bugs mapped to regression guards; flake control with pytest-rerunfailures

Note on auth & checkout: Login, registration, checkout, and profile flows on live Amazon are protected by OTP / captcha / device verification, and this suite never places a real order and never bypasses a captcha. Those flows have full page objects and tests, but the credentialed portions are skipped by default (enable via env flags). Public flows — search, filters, sorting, product pages, cart math, and negative form validation — run for real. The CheckoutPage object deliberately has no method that can click "Place your order", so an accidental purchase is impossible by design. This is the correct, honest way to automate a real production site.


🧰 Tech Stack

Layer Tool
Language Python 3.11+
Automation Selenium WebDriver 4 (Selenium Manager for drivers)
Runner / assertions pytest
Design pattern Page Object Model + factory + soft assertions
Data openpyxl (Excel), csv, json
Reporting pytest-html, allure-pytest
Parallelism / stability pytest-xdist, pytest-rerunfailures
Config / secrets python-dotenv
CI/CD GitHub Actions + Jenkins

📁 Project Structure

Amazon-UI-Automation/
├── config/
│   └── config.py                 # Env-driven settings + feature flags
├── pages/                        # Page Object Model
│   ├── base_page.py              # Waits, safe click, popups, anti-bot detection
│   ├── home_page.py
│   ├── search_results_page.py    # + sorting / filtering / pagination
│   ├── product_page.py
│   ├── cart_page.py              # qty update / remove / totals
│   ├── login_page.py
│   ├── registration_page.py
│   ├── checkout_page.py          # cannot place an order — by design
│   ├── order_confirmation_page.py
│   └── profile_page.py
├── tests/
│   ├── conftest.py               # Fixtures, --browser option, failure screenshots
│   ├── test_home_page.py
│   ├── test_navigation.py
│   ├── test_search.py
│   ├── test_filter_sort.py
│   ├── test_product_details.py
│   ├── test_cart.py
│   ├── test_registration.py
│   ├── test_login.py             # + data-driven negative cases (CSV)
│   ├── test_checkout.py          # sign-in wall asserted; never orders
│   ├── test_profile.py
│   ├── test_validations.py       # prices / totals / formats / links
│   └── test_data_driven.py       # JSON + Excel driven
├── utils/
│   ├── driver_factory.py         # Chrome / Firefox / Edge factory
│   ├── logger.py
│   ├── data_reader.py            # CSV / JSON / Excel readers
│   └── assertions.py             # soft assertions
├── data/
│   ├── login_data.csv
│   ├── search_terms.json
│   └── products.xlsx
├── docs/
│   ├── BUG_REPORT_TEMPLATE.md
│   └── SAMPLE_BUG_REPORTS.md
├── .github/workflows/selenium.yml
├── Jenkinsfile
├── .env.example
├── pytest.ini
├── requirements.txt
├── Makefile
└── README.md

🚀 Getting Started

1. Prerequisites

  • Python 3.11+ and Git
  • Chrome, Firefox, or Edge installed (Selenium Manager fetches the matching driver automatically)

2. Clone & create a virtual environment

git clone https://github.com/AbrarRagib/Amazon-UI-Automation.git
cd Amazon-UI-Automation

python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt

4. Configure environment

cp .env.example .env             # Windows: copy .env.example .env

Edit .env for your details. .env is git-ignored — never commit it.


▶️ Running Tests

pytest                      # full suite, headless
pytest --headed             # watch it in a real browser
pytest -m smoke             # smoke only
pytest -m regression        # regression suite
pytest -m validation        # validation checks
pytest -m data_driven       # CSV/JSON/Excel-driven
pytest -m "cart or search"  # combine markers
pytest tests/test_search.py # a single file
pytest -n 4                 # parallel (4 workers)
pytest --reruns 1           # auto-retry flaky network hiccups once

Cross-browser

pytest --browser chrome
pytest --browser firefox
pytest --browser edge

Make shortcuts

make smoke | make regression | make parallel | make firefox | make report

📊 Reporting

  • pytest-html — a single self-contained file at reports/report.html with embedded failure screenshots.
  • Allureallure serve reports/allure-results for an interactive dashboard (features, steps, history, attachments: screenshot and page source for every failure).
  • Logs — timestamped run log at reports/test_run.log.

🔁 CI/CD

  • 3-browser matrix (Chrome / Firefox / Edge) on every push & PR
  • Weekly scheduled regression (Mondays 03:00 UTC)
  • Manual dispatch with a marker input (run just smoke, regression, …)
  • Uploads per-browser HTML reports + screenshots and a merged Allure report as artifacts
  • One flake-retry per test to absorb live-site network noise

Jenkins — Jenkinsfile

Parameterized pipeline (browser + suite choice), publishes the pytest-html report, Allure results, and failure screenshots.


🔐 Auth & Checkout — the honest approach to a live production site

Flow Default Why
Search / Filter / Sort / Product / Cart ✅ runs for real Public, safe, deterministic
Login & Registration negative validation ✅ runs for real Client-side alerts need no credentials
Guest checkout → sign-in wall ✅ runs for real Asserts auth protection without ordering
Credentialed login / logout ⛔ gated RUN_AUTH_TESTS Live OTP / captcha / device verification
Order review validation ⛔ gated RUN_CHECKOUT_TESTS Requires auth; Place Order is never clicked — the page object has no method for it
Profile / Your Account ⛔ gated RUN_PROFILE_TESTS Requires auth

If Amazon serves its anti-bot interstitial, the affected test skips with a clear reason instead of failing on a misleading locator error — and the suite never attempts to solve or bypass a captcha.


🧪 Test Design Highlights

  • Explicit waits onlyWebDriverWait + expected conditions everywhere; implicit wait pinned to 0.
  • Self-healing locatorsfind_first_present(*locators) tries ordered fallbacks to survive Amazon's A/B-tested layouts.
  • Safe click — retry on interception/staleness, JS-click as last resort.
  • Fresh browser per test — zero cross-test state leakage.
  • Soft assertions — validation suites report every broken check in one run, not just the first.
  • Failure forensics — screenshot plus full page source attached to Allure automatically.

🐞 Bug Reporting & Regression

Defects are written against docs/BUG_REPORT_TEMPLATE.md; see docs/SAMPLE_BUG_REPORTS.md for four worked examples (severity/priority, environment, repro steps, evidence) — each mapped to the regression-marked test that now guards it.


⚖️ Disclaimer

Educational portfolio project. Not affiliated with Amazon. It exercises only public UI flows at low volume, never bypasses security controls, and never completes a purchase or registration. Respect the site's Terms of Service.

📄 License

MIT

About

Selenium + Python UI automation framework for Amazon.com — POM, pytest, cross-browser, Allure reports, CI/CD.

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors