A comprehensive test automation framework built with Selenium WebDriver for frontend testing, RestAssured for API testing, TestNG for test execution, and Page Object Pattern for maintainable code structure.
- β Selenium WebDriver - Frontend UI automation
- β RestAssured - API testing
- β TestNG - Test execution and reporting
- β Page Object Pattern - Maintainable and reusable page objects
- β Log4j2 - Comprehensive logging
- β Multi-Environment Support - Dev, Staging, Production configurations
- β WebDriverManager - Automatic browser driver management
- β Maven - Dependency management and build tool
.
βββ src/
β βββ main/
β β βββ java/
β β β βββ com/automation/
β β β βββ base/ # Base test classes
β β β βββ pages/ # Page Object classes
β β β βββ utils/ # Utility classes
β β βββ resources/
β β βββ config/ # Environment properties
β β βββ log4j2.xml # Logging configuration
β βββ test/
β βββ java/
β βββ com/automation/
β βββ tests/
β βββ api/ # API test classes
β βββ frontend/ # Frontend test classes
βββ logs/ # Log files directory
βββ test-suites/ # Test suite configurations
β βββ smoke-suite.xml # Smoke test suite
β βββ regression-suite.xml # Regression test suite
β βββ full-suite.xml # Full test suite
β βββ api-suite.xml # API test suite
β βββ frontend-suite.xml # Frontend test suite
βββ pom.xml # Maven dependencies
βββ testng.xml # Default TestNG configuration
βββ run-tests.sh # Test runner script
βββ README.md # This file
- Java 11 or higher
- Maven 3.6 or higher
- Chrome/Firefox/Edge browser installed
-
Clone or download the project
-
Install dependencies
mvn clean install
-
Configure environment properties
- Edit
src/main/resources/config/dev.properties - Edit
src/main/resources/config/staging.properties - Edit
src/main/resources/config/prod.properties - Update URLs, credentials, and other configuration values
- Edit
-
Create logs directory
mkdir logs
mvn test# Run smoke tests on dev environment
mvn test -DsuiteXmlFile=test-suites/smoke-suite.xml -Denvironment=dev
# Run regression tests on staging environment
mvn test -DsuiteXmlFile=test-suites/regression-suite.xml -Denvironment=staging
# Run full suite on production
mvn test -DsuiteXmlFile=test-suites/full-suite.xml -Denvironment=prod
# Run API tests only
mvn test -DsuiteXmlFile=test-suites/api-suite.xml -Denvironment=dev
# Run frontend tests only
mvn test -DsuiteXmlFile=test-suites/frontend-suite.xml -Denvironment=dev# Run smoke tests on dev (default environment)
./run-tests.sh smoke
# Run regression tests on staging
./run-tests.sh regression staging
# Run full suite on production
./run-tests.sh full prod
# Run API tests
./run-tests.sh api dev
# Run frontend tests
./run-tests.sh frontend staging-
smoke-suite.xml - Quick smoke tests for critical functionality
- Runs:
testValidLogin,testHomePageElements,testGetUser - Environment: dev (default)
- Runs:
-
regression-suite.xml - Full regression test suite
- Runs: All tests with
regressiongroup - Environment: staging (default)
- Runs: All tests with
-
full-suite.xml - Complete test suite
- Runs: All tests (frontend + API)
- Environment: dev (default)
-
api-suite.xml - API tests only
- Runs: All API tests
- Environment: dev (default)
-
frontend-suite.xml - Frontend tests only
- Runs: All frontend tests
- Environment: dev (default)
-
testng.xml - Default suite
- Runs: All tests
- Environment: dev (default)
mvn test -Dtest=LoginPageTest# Run only smoke tests
mvn test -Dgroups=smoke
# Run only regression tests
mvn test -Dgroups=regressionAll test suites are configured for parallel execution. Adjust thread-count in the suite XML files as needed.
Each environment has its own properties file:
dev.properties- Development environmentstaging.properties- Staging environmentprod.properties- Production environment
base.url- Frontend application URLapi.base.url- API base URLbrowser- Browser to use (chrome, firefox, edge)headless- Run browser in headless mode (true/false)implicit.wait- Implicit wait time in secondsexplicit.wait- Explicit wait time in secondspage.load.timeout- Page load timeout in secondsapi.timeout- API request timeout in millisecondsusername- Test usernamepassword- Test password
The framework uses Page Object Pattern for better maintainability:
BasePage- Base class with common methodsLoginPage- Login page objectHomePage- Home page object
- Create a new class extending
BasePage - Use
@FindByannotations for element locators - Create methods for page actions
Example:
public class NewPage extends BasePage {
@FindBy(id = "element-id")
private WebElement element;
public void performAction() {
click(element);
}
}The framework includes RestAssured for API testing:
ApiClient- Base API client with request/response specificationsBaseAPITest- Base class for API testsUserAPITest- Example API test class
Response response = ApiClient.getRequestSpec()
.when()
.get("/users/1")
.then()
.extract()
.response();Logs are configured using Log4j2:
- Console output for immediate feedback
- File output in
logs/automation.log - Automatic log rotation (daily and size-based)
The framework supports:
- Chrome (default)
- Firefox
- Edge
Browser drivers are automatically managed by WebDriverManager.
Tests are organized into groups for flexible test execution:
- smoke - Critical tests that verify basic functionality
- regression - Comprehensive tests for full regression testing
Add groups to your test methods:
@Test(priority = 1, description = "Test description", groups = {"smoke", "regression"})
public void testMethod() {
// Test implementation
}Each test suite XML file can:
- Specify which tests to run (by class, method, or group)
- Set default environment
- Configure parallel execution
- Set thread count for parallelization
- Page Object Pattern: Always use Page Objects for UI interactions
- Logging: Use logger for important actions and assertions
- Wait Strategies: Use explicit waits instead of Thread.sleep()
- Environment Configuration: Keep sensitive data in properties files
- Test Data: Externalize test data when possible
- Clean Code: Follow naming conventions and code organization
- Test Groups: Organize tests into groups (smoke, regression) for flexible execution
- Test Suites: Use appropriate test suites for different scenarios
WebDriverManager should handle this automatically. If issues persist:
- Check internet connection
- Manually download drivers and add to PATH
- Ensure properties files are in
src/main/resources/config/ - Check file names match environment parameter
- Create
logsdirectory in project root - Ensure write permissions
- Follow the existing code structure
- Add appropriate logging
- Update documentation as needed
- Test your changes
This project is for educational and testing purposes.