Creating a complete Maven structured framework with all the specified features and integrations is beyond the scope of a single response. However, I can provide you with a step-by-step guide to help you set up the framework and achieve the mentioned functionalities. This guide assumes that you are familiar with Java, Selenium, TestNG, Maven, and Jenkins.learnAutomation
seleniumautomation
cucumber
My way of Developing of Automation framework Using Maven , TestNG Using Selenium .
I just Provided The skeleton of upcoming End To End Framework.
🎯 Create Maven Structured Framework with all necessary Automation
dependencies
🎯Select Sample Application to Automate the end-to-end flow
Implement Page object Model mechanism to drive the locators from
respective classes
🎯Drive object creation within Page object classes encapsulating it from Tests
🎯Create Base Test which sets browser configuration details and Global
properties
🎯Decide the Test Strategy, how tests should be clubbed & distributed with
appropriate annotations
🎯Create TestNG runner file to trigger the tests with one Single point of
execution control
🎯Introduce Grouping in TestNG.xml to categorize tests with different tags of execution
🎯Implement Data driven testing & Parameterization using TestNG Data
provider Hash Map & Json File readers
🎯Implement TestNG Listeners to capture Screenshot on automatic test
failures and logging
🎯Create Extent Report wrapper to generate excellent HTML reports for the
application
🎯Make Framework necessary changes to support parallel execution with
Thread safe mechanism
🎯Implement TestNG retry mechanism to rerun the failed flaky tests in the
application
🎯Run the Framework tests with Maven commands with TestNG Maven
integration plugin
🎯Implement Maven Run time variables to replace global parameters of test
data at run time
🎯Integrate the Framework with Jenkins with Parameterized Build Pipeline
Jobs & Schedule the jobs on specific time frames
🎯Add Cucumber Wrapper to existing framework with Cucumber TestNG
Runner
🎯Create Feature files & Step definitions to support Cucumber execution of
Selenium Tests
🎯Understanding how cucumber tags, Data driven & Parameterization works in
running the tests.
pom.xml:3.Create a BaseTest class to set up browser configuration and global properties.
package com.example.framework.base;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
public class BaseTest {
protected WebDriver driver;
@BeforeMethod
public void setUp() {
// Set up browser configuration
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
driver = new ChromeDriver();
}
@AfterMethod
public void tearDown() {
// Close the browser
driver.quit();
}
}
Step 6: TestNG Annotations and Groups
Use TestNG annotations to control the test execution flow and group your tests.
package com.example.framework.tests; import com.example.framework.base.BaseTest; import com.example.framework.pages.HomePage; import org.testng.annotations.Test; public class LoginTest extends BaseTest { @Test(groups = "smoke") public void loginTest() { HomePage homePage = new HomePage(driver); homePage.clickLogin(); // Add login validation/assertions } }
Step 7: Data-Driven Testing
Implement data-driven testing using TestNG DataProvider, HashMap, and JSON file readers.
@DataProvider(name = "loginData") public Object[][] getLoginData() { // Read data from Excel, CSV, JSON, or any other source return new Object[][] { {"username1", "password1"}, {"username2", "password2"}, // Add more test data }; } @Test(dataProvider = "loginData") public void loginTest(String username, String password) { // Use username and password for login }
Step 8: TestNG Listeners
Implement TestNG listeners for capturing screenshots on test failures and logging.
public class CustomListener implements ITestListener { @Override public void onTestFailure(ITestResult result) { // Capture screenshot // Log the failure details } }
Step 9: Extent Reports
Create an Extent Report wrapper to generate HTML reports.
public class ExtentReportListener implements ITestListener { private ExtentReports extent = new ExtentReports(); @Override public void onStart(ITestContext context) { // Set up Extent Report configuration } @Override public void onTestSuccess(ITestResult result) { // Log success details in the report } @Override public void onTestFailure(ITestResult result) { // Log failure details in the report } @Override public void onFinish(ITestContext context) { // Flush and close the Extent Report extent.flush(); extent.close(); } }
Step 10: Parallel Execution
Make your framework thread-safe to support parallel execution.
public class ThreadSafeTest extends BaseTest { @Test(threadPoolSize = 3, invocationCount = 3, timeOut = 10000) public void parallelTest() { // Your test logic } }
logic
}
}
Comments
Post a Comment