ExtentReport has been a well-liked tool for creating regular email reports for years. Reporting is very important in test automation. It helps teams check results, spot problems, and make better choices. However, with advancements in automation testing happening at a rapid pace, old reporting tools are having trouble meeting the new needs for real-time updates, active dashboards, and better analysis. This is where ChainTest Report helps. Made for today’s test automation needs, ChainTest goes past regular reports. It offers real-time data, interactive dashboards, and better teamwork for testing groups. As automation moves to quicker integration and delivery, having a strong and flexible reporting tool is more important than ever.
This blog looks at how ChainTest changes test reporting. It explains why it is a great choice for teams that want to keep up in the fast-evolving world of automation testing.
Key Highlights
- Say goodbye to ExtentReport and welcome ChainTest for better Selenium reporting.
- Access real-time analytics and track historical data for smart insights.
- Enjoy easy connection with popular test frameworks like JUnit, TestNG, and Cucumber. PyTest support is coming soon.
- Make reporting easier with simple setup, Docker support, and a friendly interface.
- Get ahead in automation testing with thorough, attractive, and informative reports.
Key Features of ChainTest
- Real-Time Analytics: Teams can view their test runs as they happen, helping them quickly find and fix issues. Watching updates on test progress, like failures and successes, provides helpful insights.
- Historical Data Storage: ChainTest saves past test runs, helping teams analyze trends and code changes to improve their strategies.
- Simple Setup: Using Docker makes the setup process fast and hassle-free, so teams can focus on writing and executing tests instead of fixing dependencies.
Understanding the Basics of ChainTest and Selenium Integration
ChainTest and Selenium are great partners. They help you improve the quality of your testing work. ChainTest adds smart insights to Selenium. It records key details of your test runs and presents them clearly.
With ChainTest, you can make great reports for your Selenium tests. These reports show everything about your tests. They include helpful charts, logs, and screenshots. ChainTest also makes it easy to share your results with both technical and non-technical people.
Introduction to ChainTest for Selenium Users
Transitioning from ExtentReport to ChainTest is a major improvement for your Selenium reporting. ExtentReport was a solid beginning, but ChainTest goes beyond that. It offers better insights and a smoother experience for users.
Do you remember having problems with static test results and historical data? ChainTest fixes these issues. It provides dynamic, attractive reports and tracks your historical data effectively. ChainTest helps you explore your Selenium test results. You can discover hidden patterns and make smart decisions to enhance your testing.
ChainTest offers more. It provides real-time analytics. You can watch your tests as they happen. You don’t need to wait until test runs are over to get information. With ChainTest, you stay updated all the time. This allows you to find and fix issues faster. As a result, you enjoy quicker releases and a better product.
Setting Up Your Environment for ChainTest Reports
Are you ready to make your Selenium reporting better with ChainTest? The good news is that it’s simple to get started. ChainTest fits nicely with your existing Selenium test suites. It won’t change your workflow too much.
Setting it up is easy. You just need to install the right tools and set up Selenium to work with ChainTest. The process is simple, even if you are new to advanced reporting tools. Let’s improve your testing toolkit with ChainTest and find new ways to get helpful information.
Installing Necessary Dependencies
Before we begin creating great ChainTest reports, we need to prepare our environment.. Here is a step-by-step guide to help you.
First, choose a ChainTest repository that fits your testing framework. ChainTest works well with well-known frameworks like JUnit, TestNG, and Cucumber. Picking the right repository makes sure it works well with your current test setup.
- Next, add the ChainTest dependency to your project easily. This helps your testing framework work better with the ChainTest server. It also makes it easy to create useful reports.
- Finally, choose how you want to deploy the ChainTest server. A Docker image is a simple and fast option. It provides a pre-set environment, so you can get started quickly.
Step 1: Setting Up ChainTest in Selenium Project
First, you need to add ChainTest to your Selenium project. If you are using Maven, put this dependency in your pom.xml:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>Selenium-ChainTest-Demo</artifactId> <version>1.0-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <selenium-version>4.17.0</selenium-version> <testng.version>7.10.2</testng.version> <maven.compiler.plugin.version>3.6.1</maven.compiler.plugin.version> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> <aspectj.version>1.9.6</aspectj.version> <maven.surefire.plugin.version>3.0.0-M5</maven.surefire.plugin.version> </properties> <build> <plugins> <!-- Compiler Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven.compiler.plugin.version}</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> </configuration> </plugin> <!-- Surefire Plugin for Test Execution --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${maven.surefire.plugin.version}</version> <configuration> <suiteXmlFiles> <suiteXmlFile>TestNG.xml</suiteXmlFile> </suiteXmlFiles> <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" </argLine> </configuration> </plugin> </plugins> </build> <dependencies> <!-- Selenium Java --> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>${selenium-version}</version> </dependency> <!-- TestNG --> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>${testng.version}</version> <scope>test</scope> </dependency> <!-- AspectJ Weaver --> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> <!-- ChainTest Library --> <dependency> <groupId>com.aventstack</groupId> <artifactId>chaintest-testng</artifactId> <version>1.0.9</version> </dependency> <!-- Apache Commons IO --> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.11.0</version> </dependency> <!-- Logging Dependencies --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>2.0.16</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.5.9</version> </dependency> </dependencies> </project>
Run mvn clean install to make sure all needed files are installed correctly.
Step 2: Writing a Selenium Test with TestNG
To make a straightforward Selenium script with TestNG that runs a test case and records the results, follow these steps:
- Set up your project in your favorite IDE.
- Add the required Selenium and TestNG libraries to your project.
- Write a simple test method using TestNG.
- Use Selenium to open a web page and perform actions.
- Log the outcome of the test.
This basic script can help you automate web testing easily.
Property Reader
package ChainTestDemo.Utils; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; public class PropertyReader { private static WebDriver driver; private static Properties properties; static { properties = new Properties(); try { FileInputStream fis = new FileInputStream("src/test/resources/config.properties"); properties.load(fis); } catch (IOException e) { e.printStackTrace(); } } public static String getProperty(String key) { return properties.getProperty(key); } public static WebDriver getDriver() { if (driver == null) { driver = new ChromeDriver(); } return driver; } public static void quitDriver() { if (driver != null) { driver.quit(); driver = null; } } }
Login page
package ChainTestDemo.pages; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; public class LoginPage { private WebDriver driver; @FindBy(id = "username") private WebElement usernameField; @FindBy(id = "password") private WebElement passwordField; @FindBy(id = "submit") private WebElement submitButton; public LoginPage(WebDriver driver) { this.driver = driver; PageFactory.initElements(driver, this); } public void enterUsername(String username) { usernameField.sendKeys(username); } public void enterPassword(String password) { passwordField.sendKeys(password); } public void clickSubmit() { submitButton.click(); } public void login(String username, String password) { enterUsername(username); enterPassword(password); clickSubmit(); } }
home page
package ChainTestDemo.pages; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; public class HomePage { private WebDriver driver; @FindBy(className = "post-title") private WebElement postTitle; public HomePage(WebDriver driver) { this.driver = driver; PageFactory.initElements(driver, this); } public String getPostTitle() { return postTitle.getText(); } }
Login Test
package ChainTestDemo.Tests; import ChainTestDemo.Utils.PropertyReader; import ChainTestDemo.pages.HomePage; import ChainTestDemo.pages.LoginPage; import com.aventstack.chaintest.plugins.ChainTestListener; import org.apache.commons.io.FileUtils; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.testng.Assert; import org.testng.ITestResult; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import java.io.File; import java.io.IOException; @Listeners(com.aventstack.chaintest.plugins.ChainTestListener.class) public class LoginTest { private LoginPage loginPage; private HomePage homePage; private PropertyReader propertyReader; private ChainTestListener chainTestListener; @BeforeMethod public void setUp() { try { propertyReader = new PropertyReader(); WebDriver driver = propertyReader.getDriver(); if (driver == null) { throw new RuntimeException("WebDriver is not initialized!"); } loginPage = new LoginPage(driver); homePage = new HomePage(driver); driver.get(propertyReader.getProperty("url")); driver.manage().window().maximize(); // Ensure chainTestListener is initialized chainTestListener = new ChainTestListener(); } catch (Exception e) { throw new RuntimeException("Setup failed: " + e.getMessage()); } } @Test public void testSuccessfulLogin() { try { chainTestListener.log("Entering username and password"); loginPage.login(propertyReader.getProperty("username"), propertyReader.getProperty("password")); captureAndEmbedScreenshot("Entered username and password"); chainTestListener.log("Verifying the home page title"); Assert.assertEquals(homePage.getPostTitle(), "Logged In Successfully", "Home page title mismatch"); captureAndEmbedScreenshot("Verified home page title"); chainTestListener.log("Login test executed successfully"); } catch (Exception e) { chainTestListener.log("Test failed due to exception: " + e.getMessage()); Assert.fail("Test failed: " + e.getMessage()); } } @AfterMethod public void tearDown(ITestResult result) { if (result.getStatus() == ITestResult.FAILURE) { String screenshotPath = captureScreenshot(propertyReader.getDriver(), result.getName()); if (screenshotPath != null) { chainTestListener.embed(new File(screenshotPath), "image/png"); } chainTestListener.log("Test failed: " + result.getName()); } propertyReader.quitDriver(); } private String captureScreenshot(WebDriver driver, String testName) { try { File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); String screenshotPath = "screenshots/" + testName + "_" + System.currentTimeMillis() + ".png"; FileUtils.copyFile(screenshot, new File(screenshotPath)); return screenshotPath; } catch (IOException e) { e.printStackTrace(); return null; } } private void captureAndEmbedScreenshot(String stepDescription) { try { // Take screenshot at current test step File screenshot = ((TakesScreenshot) propertyReader.getDriver()).getScreenshotAs(OutputType.FILE); String screenshotPath = "screenshots/" + stepDescription.replaceAll("\s+", "_") + ".png"; // Use step description as filename FileUtils.copyFile(screenshot, new File(screenshotPath)); // Log the step chainTestListener.log(stepDescription); // Embed screenshot to the report chainTestListener.embed(new File(screenshotPath), "image/png"); } catch (IOException e) { e.printStackTrace(); } } }
Ensure flawless software quality with expert QA services, including automation, performance, security, and API testing.
Step 3: Running Tests and Generating Reports
- Run the test with TestNG (testng.xml).
- The ChainTest framework saves logs, screenshots, and steps of the execution.
- After running, an HTML report (TestReport.html) is created in the project directory.
Chaintest Properties
# general chaintest.project.name=chaintest-testng-example # storage chaintest.storage.service.enabled=false ## [azure-blob, aws-s3] chaintest.storage.service= ## s3 bucket or azure container name chaintest.storage.service.container-name= # generators: ## chainlp chaintest.generator.chainlp.enabled=false chaintest.generator.chainlp.class-name=com.aventstack.chaintest.generator.ChainLPGenerator chaintest.generator.chainlp.host.url=http://localhost/ chaintest.generator.chainlp.client.request-timeout-s=30 chaintest.generator.chainlp.client.expect-continue=false chaintest.generator.chainlp.client.max-retries=3 ## simple chaintest.generator.simple.enabled=true chaintest.generator.simple.document-title=chaintest chaintest.generator.simple.class-name=com.aventstack.chaintest.generator.ChainTestSimpleGenerator chaintest.generator.simple.output-file=Report/chaintest/QAResults.html chaintest.generator.simple.offline=true chaintest.generator.simple.dark-theme=true chaintest.generator.simple.datetime-format=yyyy-MM-dd hh:mm:ss a chaintest.generator.simple.js= chaintest.generator.simple.css= ## email chaintest.generator.email.enabled=true chaintest.generator.email.class-name=com.aventstack.chaintest.generator.ChainTestEmailGenerator chaintest.generator.email.output-file=target/chaintest/Email.html chaintest.generator.email.datetime-format=yyyy-MM-dd hh:mm:ss a
Testng.xml
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"> <suite name="TestSuite"> <test name="SampleTest"> <classes> <class name="ChainTestDemo.Tests.LoginTest" /> </classes> </test> </suite>
Step 4: Viewing the ChainTest Report
- Open TestReport.html in your web browser.
- The report will have:
- Test Steps with time entries
- Pass/Fail Status
- Screenshots taken during the test
- Execution time and logs
What Can You Modify in ChainTest Report?
ChainTest allows extensive customization to tailor reports to your needs. Here are the key areas you can modify:
1. Report Layout & Design
- Customize Themes & Colors – Modify the appearance to align with your brand.
- Change Dashboard View – Adjust widgets, charts, and test summary format.
- Modify Report Structure – Configure sections like test details, logs, and execution timeline.
2. Data & Logging Customization
- Set Log Levels – Choose between INFO, WARN, ERROR, or DEBUG for better filtering.
- Enable/Disable Real-Time Updates – Control whether test results update dynamically.
- Add Custom Tags & Metadata – Include test environment details, execution time, and versioning.
3. Test Execution & History Management
- Store or Purge Historical Data – Decide how long test results should be retained.
- Enable Database Integration – Choose between MySQL, PostgreSQL, H2 for history tracking.
- Filter Test Runs – View reports by date, test suite, or execution status.
4. Screenshot & Attachment Settings
- Attach Screenshots on Failures – Store images via AWS S3, Azure Blob, or local storage
- Embed Videos – Capture execution sessions and include them in reports.
- Attach Logs & Debug Files – Add external logs for better debugging insights.
.
5. Report Export & Sharing Options
- Generate Reports in Multiple Formats – Export as HTML, PDF, JSON, or XML.
- Enable Email Notifications – Send reports automatically to stakeholders.
- Integrate with CI/CD Pipelines – Share results via Jenkins, GitHub Actions, Azure DevOps, etc.
6. Customizing ChainTest Properties
Modify haintest.properties file to set default configurations:
chaintest.project.name=MyTestProject chaintest.generator.chainlp.enabled=true chaintest.generator.chainlp.class-name=com.aventstack.chaintest.generator.ChainLPGenerator chaintest.generator.chainlp.host.url=http://localhost/ chaintest.report.format=HTML, PDF chaintest.screenshot.storage=AWS_S3
Here’s an example setup that shows how different test frameworks work together. It also allows you to adjust the way the dashboard looks.
Configuration Key | Description |
---|---|
chaintest.project.name | Specifies the project name, enabling you to organize and filter reports effectively |
chaintest.generator.chainlp | Dictates the module responsible for generating reports in various formats, such as HTML or PDF |
Understanding Chain LP Generator in Chain Test Report
What is Chain LP?
Chain LP Generator is a report generator in Chain Test Report that enables real-time test reporting while maintaining a historical record of test executions.
How Does Chain LP Work?
ChainLP is a Spring Boot-based server with a front-end packaged as a Docker image. To generate Chain Test Reports using the Chain LP Generator, the Chain LP server must be running.
Docker image is available from https://hub.docker.com/r/anshooarora/chaintest.
Maintaining Test History in Chain LP
Chain LP stores test execution history by connecting to a database (DB) on the server machine. It supports various RDBMS databases, including:
- MySQL
- PostgreSQL
- H2 Database
Related Blogs
Setting Up Chain LP Server
To run the Chain LP server, we can use Docker Compose files provided by developers or create our own based on specific database requirements.
Starting Chain LP Server with H2 Database
Use the following command to launch the Chain LP server backed by an H2 database:
docker compose -f docker-compose-h2.yml up
Configuring Chain LP Generator in BDD Framework
Once the Chain LP server is up, the next step is to configure the Chain LP Generator in BDD (Behavior-Driven Development) tests.
Updating the chaintest.properties File
Add the following properties to the chaintest.properties configuration file:
chaintest.generator.chainlp.enabled=true chaintest.generator.chainlp.class-name=com.aventstack.chaintest.generator.ChainLPGenerator chaintest.generator.chainlp.host.url=http://localhost/
Executing Test Cases with Chain LP
After configuring Chain LP, we can proceed to execute test cases. The results will be automatically stored and displayed in the Chain Test Report.
Viewing Test Results in Chain LP
To view test execution reports, open the URL defined in chaintest.generator.chainlp.host.url in a web browser.
Attaching Screenshots to Chain LP Reports on Failure
To attach screenshots of test failures in Chain LP Reports, use a cloud storage solution such as:
- Azure Blob Storage
- AWS S3 Bucket
Conclusion
In conclusion, learning ChainTest for Selenium is a great way to boost your test automation skills. It offers many benefits over ExtentReport. By using its main features, you can make your testing faster and smoother. Linking ChainTest with Selenium allows you to create detailed and helpful test reports.
To set up your environment for ChainTest reports, just install the necessary tools and configure Selenium easily. Use this powerful tool to improve your testing quality and obtain clear reports with no hassle.
For more help with ChainTest and Selenium, take a look at our FAQ section or reach out to our experts for personal support.
Frequently Asked Questions
-
How Does ChainTest Improve Selenium Test Reports?
ChainTest improves how Selenium test reports are made by adding real-time analytics. You get quick insights right away. It stores historical data which helps in looking at trends. It also makes detailed reports for better clarity. With these features, teams can enhance their automation work and boost software quality.
-
Can ChainTest Be Integrated With Existing Selenium Projects?
ChainTest works great with all types of Selenium projects. It has a flexible design that works well with popular testing tools, including Java Spring Boot. Setting it up is simple. This makes it a good choice to enhance the reporting features of your existing Selenium tests.
-
What Are the Key Benefits of Using ChainTest for Selenium Reporting?
ChainTest is a better option than ExtentReport for reporting in Selenium. It offers several advantages. Users can see real-time analytics and appealing dashboards. They can also check historical data. ChainTest helps users grasp their test results more clearly. It simplifies communication and allows them to make data-driven decisions. This can lead to ongoing improvement in their work. In summary, it boosts the success of their test automation efforts.
-
Is There a Learning Curve to Master ChainTest with Selenium?
ChainTest is easy to use. It has a friendly design and offers a lot of helpful information. It works well with common testing tools, making it simple to learn. Testers familiar with automation and Java can quickly grasp how it functions. They can start enjoying better reporting in no time
The post ChainTest Report Generation with Selenium appeared first on Codoid.
Source: Read More