A robust UI automation framework for the QACart Todo App using Java, Selenium WebDriver, Cucumber, and TestNG. Follows the Page Object Model (POM), supports multi-browser execution, and is optimized for maintainability and CI/CD pipelines.
- ✅ BDD Approach: Gherkin scenarios for business-readable tests
- 🌐 Cross-Browser: Chrome/Firefox/Edge support
- ⚙️ Environment Configs: Local/Staging/Production setups
- 🧵 Thread-Safe: Parallel execution ready
- 📊 CI/CD: GitHub Actions integration
- 📄 Logging: Detailed execution logs
📁 src/test
├── 📁 java
│ └── 📁 com.qacart.todo
│ ├── 📁 base # Core WebDriver setup
│ ├── 📁 factory # Browser instantiation
│ ├── 📁 hooks # Test lifecycle management
│ ├── 📁 pages # POM classes (LoginPage, TodoPage)
│ ├── 📁 runners # TestNG cucumber runners
│ ├── 📁 steps # Gherkin step implementations
│ └── 📁 utils # Config helpers
└── 📁 resources
├── 📁 features # Business scenarios
└── 📁 properties # Environment configs
- Java 21+
- Maven 3.8+
# Default: Chrome + STAGING
mvn clean test
# Custom environment and browser
mvn test -Dbrowser=firefox -Denv=PRODUCTION
Edit properties in:
src/test/resources/properties/
├── local.properties
├── staging.properties
└── production.properties
Supported browsers via -Dbrowser
flag:
chrome | firefox | edge
Feature File (user.feature)
:
Feature: User Features
Scenario: User should be able to login
Given User is at the login page
When User fill the email and password and login
Then Welcome message should be displayed
Step Definition:
@Given("User is at the login page")
public void userIsAtTheLoginPage() throws IOException {
// Initialize the WebDriver using the DriverFactory
driver = DriverFactory.getDriver();
// Navigate to the login page of the application
new LoginPage(driver).load(EnvUtils.getInstance().getUrl() + "/login");
}
@When("User fill the email and password and login")
public void userFillTheEmailAndPassword() throws IOException {
// Log in to the application by using the LoginPage class
new LoginPage(driver).login(EnvUtils.getInstance().getEmail(), EnvUtils.getInstance().getPassword());
}
@Then("Welcome message should be displayed")
public void welcomeMessageShouldBeDisplayed() {
// Verify that the welcome message is displayed after login
boolean isWelcomeDisplayed = new TodoPage(driver).isWelcomeMessageDisplayed();
Assert.assertTrue(isWelcomeDisplayed, "Welcome message is not displayed");
}
Runs on push to master
branch (.github/workflows/test.yml
):
on:
push:
branches: ["main"]
jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '21'
- uses: browser-actions/setup-chrome@latest
- run: mvn clean test
- HTML Reports: target/cucumber-reports/
- Logs: logs/ via Log4j2
# Sample log output
[DEBUG] Initializing ChromeDriver...
[INFO] Loading PRODUCTION environment
- Page Object Model (POM): Each page = single class
- Environment abstraction via EnvUtils
- Reusable steps: Modular, easy to maintain
- Parallel execution with ThreadLocal WebDriver
Distributed under the MIT License. See the LICENSE file for more details.