Skip to content

pun33th45/selenium-ecommerce-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Selenium E-Commerce Automation Framework

Industry-style Selenium automation framework for an e-commerce website using Java, Selenium WebDriver, TestNG, Maven, Page Object Model, Log4j2, screenshots, and Extent Reports.

Tech Stack

  • Java 17
  • Selenium WebDriver
  • TestNG
  • Maven
  • Page Object Model
  • WebDriverManager
  • Log4j2
  • Extent Reports

Project Structure

selenium-ecommerce-framework
|-- pom.xml
|-- testng.xml
|-- README.md
|-- src
|   |-- main
|   |   |-- java
|   |   |   |-- com/ecommerce
|   |   |   |   |-- factory
|   |   |   |   |   |-- DriverFactory.java
|   |   |   |   |-- utils
|   |   |   |   |   |-- ConfigReader.java
|   |   |   |   |   |-- ExtentReportManager.java
|   |   |   |   |   |-- ScreenshotUtils.java
|   |   |   |   |   |-- WaitUtils.java
|   |-- test
|   |   |-- java
|   |   |   |-- com/ecommerce
|   |   |   |   |-- base
|   |   |   |   |   |-- BaseTest.java
|   |   |   |   |-- listeners
|   |   |   |   |   |-- ExtentTestListener.java
|   |   |   |   |-- pages
|   |   |   |   |   |-- CartPage.java
|   |   |   |   |   |-- CheckoutPage.java
|   |   |   |   |   |-- LoginPage.java
|   |   |   |   |   |-- PaymentPage.java
|   |   |   |   |   |-- ProductsPage.java
|   |   |   |   |-- tests
|   |   |   |   |   |-- AddToCartTest.java
|   |   |   |   |   |-- CheckoutTest.java
|   |   |   |   |   |-- LoginTest.java
|   |   |   |   |   |-- ProductSearchTest.java
|   |   |-- resources
|   |   |   |-- config
|   |   |   |   |-- config.properties
|   |   |   |-- log4j2.xml
|-- logs
|-- reports
|-- screenshots
|-- target

Automated Scenarios

  • Login with valid credentials
  • Product search
  • Add product to cart
  • Checkout and order placement

Configuration

Update test data in:

src/test/resources/config/config.properties

Create it from the sample file:

Copy-Item src/test/resources/config/config.example.properties src/test/resources/config/config.properties

Important values:

baseUrl=https://automationexercise.com
browser=chrome
headless=false
validEmail=your_registered_email
validPassword=your_password
searchProductName=top

Supported browsers:

chrome
firefox
edge

How To Run

Run the full TestNG suite:

mvn clean test

Run a single test class:

mvn -Dtest=LoginTest test
mvn -Dtest=ProductSearchTest test
mvn -Dtest=AddToCartTest test
mvn -Dtest=CheckoutTest test

Run using testng.xml from an IDE:

  1. Open the project as a Maven project.
  2. Open testng.xml.
  3. Right-click and select Run.

Reports

TestNG/Surefire reports:

target/surefire-reports/index.html
target/surefire-reports/emailable-report.html

Extent Reports:

reports/ExtentReport_<timestamp>.html

Open the latest HTML file in a browser after test execution.

Sample Extent Report:

Extent Report

Logs

Framework logs are generated at:

logs/framework.log

Logs include browser setup, test start, test pass, test failure, and teardown events.

Screenshots

Failure screenshots are saved at:

screenshots

Screenshots are also attached to Extent Reports for failed tests.

Common Issues

If Maven is not recognized:

mvn -version

If Java is not recognized:

java -version
javac -version

If login fails, verify the email and password manually on the website first.

If an element is not found, increase the explicit wait in config.properties:

explicitWait=20

Validation Checklist

  • Project builds successfully
  • Login test passes
  • Product search test passes
  • Add to cart test passes
  • Checkout test passes
  • TestNG report is generated
  • Extent report is generated
  • Logs are generated
  • Screenshot is captured on failure

About

Industry-level Selenium Java automation framework for an e-commerce website using TestNG, Maven, Page Object Model, Log4j2, screenshots, and Extent Reports.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages