Industry-style Selenium automation framework for an e-commerce website using Java, Selenium WebDriver, TestNG, Maven, Page Object Model, Log4j2, screenshots, and Extent Reports.
- Java 17
- Selenium WebDriver
- TestNG
- Maven
- Page Object Model
- WebDriverManager
- Log4j2
- Extent Reports
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
- Login with valid credentials
- Product search
- Add product to cart
- Checkout and order placement
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.propertiesImportant values:
baseUrl=https://automationexercise.com
browser=chrome
headless=false
validEmail=your_registered_email
validPassword=your_password
searchProductName=topSupported browsers:
chrome
firefox
edge
Run the full TestNG suite:
mvn clean testRun a single test class:
mvn -Dtest=LoginTest test
mvn -Dtest=ProductSearchTest test
mvn -Dtest=AddToCartTest test
mvn -Dtest=CheckoutTest testRun using testng.xml from an IDE:
- Open the project as a Maven project.
- Open
testng.xml. - Right-click and select Run.
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:
Framework logs are generated at:
logs/framework.log
Logs include browser setup, test start, test pass, test failure, and teardown events.
Failure screenshots are saved at:
screenshots
Screenshots are also attached to Extent Reports for failed tests.
If Maven is not recognized:
mvn -versionIf Java is not recognized:
java -version
javac -versionIf 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- 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
