This is a Hybrid Test Automation Framework built using various tools and technologies, aimed at automating both UI and API tests. The framework integrates multiple services and utilities to provide a comprehensive solution for end-to-end testing.
The framework is structured in different layers to ensure modularity, scalability, and maintainability. Below is a breakdown of each layer and its components:
- TestNG: Manages and executes the tests, including both UI and API tests.
- Selenium WebDriver: Automates the browser and triggers UI tests.
- REST Assured: Automates API testing.
- Log4j2: Provides logging functionality for better traceability and debugging.
- ExtentReports: Generates detailed HTML reports of the test execution results.
- Apache Commons IO: Helps in handling files, including screenshots, during the test execution.
- Jenkins: Triggers and manages test execution, enabling continuous integration and delivery.
- Data Provider Utility: Handles test data, including data reading from files or databases for test execution.
- Configuration Reader: Reads configuration files for customizable test settings, such as environment-specific configurations, URLs, etc.
- WebDriver Factory: Creates WebDriver instances, ensuring consistent browser instances across tests.
- Login Page: Handles actions and elements related to the login page.
- Products Page: Handles actions and elements related to the products page.
- Cart Page: Handles actions and elements related to the shopping cart page.
The framework follows a well-defined flow to trigger tests and generate results:
-
Test Execution:
- TestNG triggers both Selenium WebDriver for UI tests and REST Assured for API tests.
- TestNG manages test execution and integrates with Log4j2 for logging and ExtentReports for generating detailed reports.
- TestNG also interacts with Apache Commons IO for handling files like screenshots and test data.
-
UI Test Execution:
- Selenium WebDriver interacts with various Page Objects (Login, Products, Cart) to automate browser actions.
- The WebDriver Factory ensures proper browser instances are created for each test.
-
API Test Execution:
- REST Assured handles all API test interactions.
-
Configuration:
- TestNG reads configurations from the Configuration Reader to set up environment-specific values and settings.
-
CI/CD:
- Jenkins triggers the test execution and continuously integrates the results into the CI pipeline.
To use the framework, follow these steps:
- Java (version 8 or higher)
- Maven (for dependency management)
- TestNG (for running tests)
- Selenium WebDriver (for browser automation)
- REST Assured (for API automation)
- Jenkins (for continuous integration)
-
Clone this repository to your local machine:
git clone https://github.com/rakesh-vardan/Learn_TestAutomationFramework.git
-
Navigate to the project directory:
cd Learn_TestAutomationFramework
-
Install the required dependencies using Maven:
mvn clean install
To run the tests use the respective TestNG.xml file, execute the following Maven command:
mvn clean test -DsuiteXMLFile=testng.xml