This is a Selenium + Cucumber + Java + Maven test automation framework with:
- Fluent Page Object Model design pattern
- BasePage with reusable methods
- AllPages class for centralized page object management
- Parallel execution support
- Multiple browser support (Chrome, Firefox, Edge)
- REST Assured integration for API testing
- ConfigReader for configuration management
- Cucumber BDD for readable test scenarios
test-automation/
├── src/
│ ├── main/java/
│ └── test/
│ ├── java/
│ │ └── com/bazaarstores/
│ │ ├── pages/
│ │ │ ├── BasePage.java
│ │ │ ├── AllPages.java
│ │ │ ├── LoginPage.java
│ │ │ ├── RegistrationPage.java
│ │ │ └── DashboardPage.java
│ │ ├── stepDefinitions/
│ │ │ ├── Hooks.java
│ │ │ └── LoginSteps.java
│ │ ├── runners/
│ │ │ ├── TestRunner.java
│ │ │ ├── SmokeTestRunner.java
│ │ │ └── ApiTestRunner.java
│ │ └── utilities/
│ │ ├── ConfigReader.java
│ │ ├── DriverManager.java
│ │ └── ApiUtil.java
│ └── resources/
│ ├── features/
│ └── Login.feature
│
├── target/
│ ├── cucumber-reports/
│ └── screenshots/
├── pom.xml
└── configuration.properties
- Java 21 or higher
- Maven 3.6+
- IDE (IntelliJ IDEA)
- Clone or download the framework
- Import as Maven project
- Update
configuration.propertiesif needed - Run
mvn clean installto download dependencies
mvn clean test# Smoke Tests
mvn clean test -Dtest=SmokeTestRunner
# API Tests
mvn clean test -Dtest=ApiTestRunner
# Regression Tests
mvn clean test -Dtest=TestRunner# Chrome (default)
mvn clean test -Dbrowser=chrome
# Firefox
mvn clean test -Dbrowser=firefox
# Edge
mvn clean test -Dbrowser=edge
# Headless Chrome
mvn clean test -Dbrowser=chrome -Dheadless=true# Run Smoke tests
mvn clean test -Dcucumber.filter.tags="@Smoke"
# Run Customer tests
mvn clean test -Dcucumber.filter.tags="@Customer"
# Run Admin tests
mvn clean test -Dcucumber.filter.tags="@Admin"
# Run API tests
mvn clean test -Dcucumber.filter.tags="@API"
# Run multiple tags
mvn clean test -Dcucumber.filter.tags="@Smoke and @Customer"
# Exclude tags
mvn clean test -Dcucumber.filter.tags="@Regression and not @API"# Run Smoke tests in Firefox
mvn clean test -Dtest=SmokeTestRunner -Dbrowser=firefox
# Run specific tags with browser
mvn clean test -Dcucumber.filter.tags="@Login" -Dbrowser=chrome
# Run in headless mode with specific runner
mvn clean test -Dtest=SmokeTestRunner -Dbrowser=chrome -Dheadless=true# Execute with 3 threads
mvn clean test -DthreadCount=3
# Execute with 5 threads
mvn clean test -DthreadCount=5| Tag | Description |
|---|---|
@Regression |
All regression tests |
@Smoke |
Critical smoke tests |
@Login |
Login functionality tests |
@Customer |
Customer role tests |
@Admin |
Admin role tests |
@StoreManager |
Store Manager role tests |
@API |
API tests using REST Assured |
@Negative |
Negative test scenarios |
Contains reusable methods:
- Click methods (click, clickWithJS)
- Send keys methods
- Wait methods (explicit waits)
- Verification methods (isDisplayed, isEnabled)
- Select dropdown methods
- Action methods (hover, drag-drop, double-click)
- JavaScript executor methods
- Alert handling
- Window/Frame switching
- Screenshot capture
Centralized page object management with getter methods:
AllPages allPages = new AllPages(driver);
allPages.getLoginPage().enterEmail("test@test.com");
allPages.getDashboardPage().isDashboardPageDisplayed();Chain methods for readable test code:
allPages.getLoginPage()
.enterEmail("customer@sda.com")
.enterPassword("Password.12345")
.clickLoginButton();Use API calls within UI tests:
@When("user logs in via API with valid credentials")
public void user_logs_in_via_api_with_valid_credentials() {
String token = ApiUtil.loginAndGetToken(email, password);
// Continue with UI test
}All test data in configuration.properties:
base.url=https://bazaarstores.com
customer.email=customer@sda.com
admin.email=admin@sda.com
default.password=Password.12345Access via ConfigReader:
String email = ConfigReader.getCustomerEmail();
String password = ConfigReader.getDefaultPassword();@YourTag
Feature: Your Feature Name
Scenario: Your test scenario
Given user is on some page
When user performs some action
Then user should see expected resultpublic class YourSteps {
AllPages allPages = new AllPages(DriverManager.getDriver());
@Given("user is on some page")
public void user_is_on_some_page() {
// Your implementation
}
}public class YourPage extends BasePage {
private final By elementLocator = By.cssSelector("elementLocator");
public YourPage(WebDriver driver) {
super(driver);
}
public YourPage enterData(String data) {
sendKeys(elementLocator, data);
return this;
}
}public class AllPages {
private YourPage yourPage;
public YourPage getYourPage() {
if (yourPage == null) {
yourPage = new YourPage(driver);
}
return yourPage;
}
}After execution, reports are generated in:
- HTML Report:
target/cucumber-reports/cucumber.html - JSON Report:
target/cucumber-reports/cucumber.json - XML Report:
target/cucumber-reports/cucumber.xml - Screenshots:
target/screenshots/(on failure)
Edit configuration.properties:
browser=chrome # chrome, firefox, edge
headless=false # true for headless modeimplicit.wait=10 # Implicit wait in seconds
explicit.wait=15 # Explicit wait in seconds
page.load.timeout=30 # Page load timeoutcustomer.email=customer@sda.com
admin.email=admin@sda.com
storemanager.email=storemanager@sda.com
default.password=Password.12345- Start: Maven command triggers runner
- @Before Hook: Initialize driver, navigate to base URL
- Feature Execution: Run scenarios based on tags
- Step Definitions: Execute test steps using AllPages
- Page Objects: Interact with UI using BasePage methods
- API Verification: Optional REST Assured calls
- @After Hook: Take screenshot on failure, quit driver
- Report Generation: Create HTML/JSON/XML reports
- Create feature file in
src/test/resources/features/ - Create step definitions in
stepDefinitionspackage - Create page objects in
pagespackage extending BasePage - Add page getter to AllPages class
- Update configuration if needed
- Use fluent design pattern for page objects
- Keep step definitions clean and readable
- Use ConfigReader for all test data
- Use BasePage methods instead of raw Selenium
- Add meaningful tags to scenarios
- Write descriptive scenario names
- Use AllPages for centralized page management
- Application URL: https://bazaarstores.com/
- Swagger API: https://bazaarstores.com/api/documentation
- Framework: Selenium 4.15.0 + Cucumber 7.14.0
- Build Tool: Maven
- Language: Java 21
This framework demonstrates:
- Industry-standard project structure
- Page Object Model with fluent design
- BDD approach with Cucumber
- Parallel execution capabilities
- Cross-browser testing
- API + UI hybrid testing
- Centralized configuration management
- Reusable components (BasePage, AllPages)
You can:
- Add new test scenarios easily
- Practice BDD writing
- Learn POM design pattern
- Understand fluent interfaces
- Execute tests with various configurations
- Generate professional reports