Selenium WebDriver
How to use Multiple Cucumber HTML Reporter with Selenium WebDriver + Cucumber in Java.
Multiple Cucumber HTML Reporter is now language independent, which means you are no longer tied to a specific language in order to generate the Cucumber Report.
All you need is a Cucumber formatter for JSON configured in your project and the Multiple Cucumber HTML Reporter CLI installed on your machine.
In this guide, you will learn how to configure the Selenium WebDriver + Cucumber Java project to generate Cucumber JSON report and convert it to beautiful HTML report using Multiple Cucumber HTML Reporer.
Tip
- Check out the example project under
examples/seleniumfolder in the reporter repository. - You can also refer to the GitHub Actions workflow for Selenium WebDriver along with the generated reports attached as artifact.
Steps to generate Multiple Cucumber HTML reporter
Generate Cucumber JSON reports
The multiple cucumber HTML reporter requires the Cucumber JSON report files in order to generate the beautiful HTML reports.
We have used the following dependencies to generate the Cucumber JSON report files:
io.cucumber / cucumber-javaio.cucumber / cucumber-junit-platform-engineorg.junit.platform / junit-platform-suitetools.jackson.core / jackson-databind
Cucumber configuration
Add the following config properties file in src/test/resources folder.
# junit-platform.properties
# Specify package containing step definitions
cucumber.glue=com.mchr.examples.selenium.steps
# Declare plugins for console output and generating the JSON report
cucumber.plugin=pretty, json:reports/json/cucumber.json
# Equivalent to monochrome = true
cucumber.ansi-colors.disabled=falseReporter configuration file
Run the mchr command in the project root folder and complete onboarding flow to create the config file.
By default, JSON based config file will be created in the folder.
Update the config file as per your requirements.
// .multiple-cucumber-html-reporter.json
{
"jsonDir": "./reports/json",
"reportPath": "./reports/html",
"emailReport": true,
"openReportInBrowser": true,
"useCDN": true,
"pageTitle": "My Selenium Java Sample",
"reportName": "Cucumber JS Report",
"customData": {
"projectName": "Selenium Java Example",
"testCycle": "${GITHUB_RUN_ID:'Cycle 1'}",
"buildNumber": "${GITHUB_RUN_NUMBER:'Build 1'}",
"environment": "production",
"ciPipeline": "GitHub Actions"
},
"metadata": {
"browser": {
"name": "chrome",
"version": "latest"
}
}
}Run the Tests
Execute your test cases by running the following command in the terminal:
mvn testThis command will execute all your test cases.
Last updated on