Cucumber-JVM 4 Report generation using ExtentReports Adapter plugin

Introduction

This article deals with generating Extent reports for Cucumber-JVM version 4 using the extentreports-cucumber4-adapter plugin. The article details out the procedure to create HTML, Logger and Spark reports.

IMPORTANT – ExtentReports has been updated to version 5, which has resulted in multiple reporters getting deprecated. Currently this supports only Spark, Klov and Json reports. Due to this, in the latest adapter version (1.2.x) only these three reports will be generated. To work with ExtentReports version 4, add the 1.0.12 adapter version. Refer to the ‘POM Dependencies’ section for more details.

The various steps required for this are to add the plugin to the runner, add the adapter dependency to the POM, enable report generation and change report settings. The versions of the extentreports-cucumber4-adapter jar which will be used here are from version 1.0.8 and upwards.

An older version of this article dealing with adapter version 1.0.7 can be found here. An article of creating Extent Report using Cucumber-JVM 5 adapter can be found here and for a Cucumber-JVM 6 adapter can be found here.

To create Extent Report using a Maven plugin, which uses the Cucumber JSON report and runs in the post-integration-test phase, refer to this article. This plugin is independent of Cucumber version and works for JSON report generated with Cucumber versions 4.3.0 and above.

Source

The source code for the article is located here. The source code for extentreports-cucumber4-adapter plugin is located here.

Plugin addition

The extentreports-cucumber4-adapter plugin needs to be added to the CucumberOptions annotation of the runner.

@CucumberOptions(plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"})

Add the colon ‘:’ at the end of the plugin argument, else below exception is thrown.

cucumber.runtime.CucumberException: You must supply an output argument to com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter.

POM Dependencies

The complete POM using version 1.2.1 is located here. For dealing with adapter version 1.0.7 refer to this article.

The version 1.0.8, 1.0.11, 1.0.12 of the adapter plugin generates the reports successfully with all the releases of Cucumber JVM 4. There are some issues with the 1.0.9 and 1.0.10 versions which are mentioned in a later section. Some tweaks regarding testng dependency are required to generate reports for version 1.2.0 and 1.2.1 which are mentioned in a later section.

The latest version of extentreports-cucumber4-adapter dependency needs to be added to the POM, to work with ExtentReports version 5.

<dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports-cucumber4-adapter</artifactId>
        <version>1.2.1</version>
        <scope>test</scope>
</dependency>

In case of lambda style step definitions using cucumber-java8 dependency, the cucumber-java version 4.7.4 which is included by the adapter jar needs to be excluded by using the exclusion tag. Otherwise the cucumber-java version used in the test project will not be included in the dependencies list.

<dependency>
	<groupId>com.aventstack</groupId>
	<artifactId>extentreports-cucumber4-adapter</artifactId>
	<version>1.2.1</version>
	<exclusions>
		<exclusion>
			<groupId>io.cucumber</groupId>
			<artifactId>cucumber-java</artifactId>
		</exclusion>
	</exclusions>
        <scope>test</scope>
</dependency>

The below version of extentreports-cucumber4-adapter dependency needs to be added to the POM , to work with ExtentReports version 4. The same exclusion case for the cucumber-java8 jar applies here also.

<dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports-cucumber4-adapter</artifactId>
        <version>1.0.11</version>
        <scope>test</scope>
</dependency>

Report Activation

First way of activating the report generation is to place extent.properties file in the src/test/resources folder or in the src/test/resources/com/avenstack/adapter folder to be picked up by the adapter. This is ideal for setting up large number of properties. The complete settings for logger and html can be found here. Below examples show the case of the html report.

extent.reporter.spark.start=true 
extent.reporter.spark.out=test-output/SparkReport/ExtentSpark.html

Second way is to add the required key and value pairs to the System properties. There are again two ways of achieving it. First method is to add the properties to the configuration section of the Maven Surefire or Failsafe plugin. This is also ideal for setting up large number of properties.

<configuration>     
      <systemPropertyVariables>         
           <extent.reporter.spark.start>true</extent.reporter.spark.start>
           <extent.reporter.spark.out>test-output/SparkReport/ExtentSpark.html</extent.reporter.html.out>     
      </systemPropertyVariables>
</configuration>

Second method is to pass the property key-values in the Maven command. This is useful for small number of properties.

mvn clean install -DargLine="-Dextent.reporter.spark.start=true -Dextent.reporter.spark.out=test-output/SparkReport/ExtentSpark.html"

Report Settings

The configurations like report activation and location can be mentioned in the extent.properties or using maven settings as shown in the section above. To change settings like theme, title, encoding etc, a separate xml file eg. extent-config.xml is required. The location for this file eg. html report needs to be mentioned as value for the key extent.reporter.html.config.

extent.reporter.spark.config=src/test/resources/extent-config.xml

This xml location key-value pair can also be set using Maven plugin configuration or command line as in the section above.

All that is left to execute the POM and check the reports.

Report Attachments

To add attachments, like screen images, two settings need to be added to the extent.properties. First property, named screenshot.dir, is the directory where the attachments are stored. Second is screenshot.rel.path, which is the relative path from the report file to the screenshot directory. In the below setting, the Spark report (named index.html by default) will navigate to the saved attachments by using the relative path setting.

extent.reporter.spark.out=test-output/SparkReport/

screenshot.dir=test-output/
screenshot.rel.path=../

A more expanded scenario could be storing the images in a folder named ‘screenshots’ and the reports generated in the ‘test-output’ folder. The ‘screenshots‘ and the ‘test-output‘ folders are at the same level. The report will need to step down two folder levels and then move to the required directory.

extent.reporter.spark.out=test-output/SparkReport/

screenshot.dir=screenshot/
screenshot.rel.path=../../screenshot/

Adapter version 1.2.0 and 1.2.1 Report Tweaks

The adapter version 1.2.0 and 1.2.1 have a transitive dependency on extent jar 5.0.0 and 5.0.1 respectively. In turn the extent jars have a transitive dependency on the testng 7.1.0. This is due the missing test scope in the testng dependency in the extent report POM. Now if the test project uses cucumber-testng to run tests, the testng version used is 6.14.3 which is overridden by 7.1.0. This can be fixed by explicitly add the extent dependency and excluding the testng jar.

<dependency>
	<groupId>com.aventstack</groupId>
	<artifactId>extentreports</artifactId>
	<version>5.0.1</version>
	<exclusions>
		<exclusion>
			<groupId>org.testng</groupId>
			<artifactId>testng</artifactId>
		</exclusion>
	</exclusions>
	<scope>test</scope>
</dependency>

This has been fixed in the latest extent reports POM. So the latest extent report jar can also be added explicitly.

<dependency>
	<groupId>com.aventstack</groupId>
	<artifactId>extentreports</artifactId>
	<version>5.0.3</version>
        <scope>test</scope>
</dependency>

Adapter version 1.0.9 and 1.0.10 Report Errors

The adapter plugin has the extent-report jar as a transitive dependency. For adapter version 1.0.9 it is extent report version 4.1.0 and in case of 1.0.10 it is version 4.1.1.

In case of version 1.0.9 with the default extent report jar, the following error is thrownjava.lang.NoClassDefFoundError: Could not initialize class com.aventstack.extentreports.service.ExtentService$ExtentReportsLoader, and none of the reports are generated.

In case of version 1.0.10 with the default extent report jar, a Freemarker exception is thrownfreemarker.core.InvalidReferenceException, due to this the Logger report is not generated while the HTML and Spark report are successfully created. This occurs when an extent-config.xml settings file, which contains the custom scripts tag, is mentioned for the extent.reporter.logger.config property. Refer to the next section for workarounds to avoid this exception.

Below is the result of running both the adapter plugins with different extent report jar versions by explicitly adding the dependency in the POM. The Freemarker Logger report exception is contingent on running with the settings described in the previous paragraph.

Extent Report VersionAdapter Version 1.0.9 Adapter Version 1.0.9 Result Adapter Version 1.0.10Adapter Version 1.0.10 Result
4.0.9ExplicitNo report generated – java.lang.NoClassDefFoundErrorExplicitNo report generated – java.lang.NoClassDefFoundError
4.1.0TransitiveNo report generated – java.lang.NoClassDefFoundErrorExplicitNo report generated – java.lang.NoClassDefFoundError
4.1.1ExplicitLogger report not generated – freemarker.core.InvalidReferenceExceptionTransitiveLogger report not generated – freemarker.core.InvalidReferenceException
4.1.2ExplicitLogger report not generated – freemarker.core.InvalidReferenceExceptionExplicitLogger report not generated – freemarker.core.InvalidReferenceException
4.1.3ExplicitLogger report not generated – freemarker.core.InvalidReferenceExceptionExplicitLogger report not generated – freemarker.core.InvalidReferenceException

Logger Report Workaround

The Freemarker exception mentioned in the previous section is caused by the custom scripts tag in the settings extent-config.xml file of the Logger report. Removing this tag generates the report successfully for adapter versions 1.0.9 and 1.0.10.

extent.reporter.logger.config=src/test/resources/extent-config.xml
<!-- custom javascript -->
<scripts>
<![CDATA[
$(document).ready(function() {
});
]]>
</scripts>

If there is no need for custom settings, easiest way is to remove the value of the extent.reporter.logger.config from extent.properties file.

If custom settings are required then another settings file for Logger report needs to be created which does NOT contain the scripts tag. Below are the steps to modify the existing source.

Execute the tests and all the reports along with the Logger report should be generated successfully.

Parallel And\Or Multiple Runner Execution

There is no additional configuration settings required for parallel execution with a single or multiple runners. This is also true for single threaded multiple runner execution.

For parallel execution using JUnit refer here and for TestNG refer here.

69 thoughts on “Cucumber-JVM 4 Report generation using ExtentReports Adapter plugin”

  1. Hello Mounish,
    I am using extent adapter and spark report. Is it possible to show Feature List on Dashboard screen or pie chart on Tests screen.
    It is a requirement from management side and I am stuck here. Please help

  2. Hi

    How can we not overwrite extent report with extent.property file, because now each time when I run the test I get a new report without saving the older one

    so I want to save the older reports and get new report each time when I run in that folder

    1. U could bypass the report ‘out’ property value mentioned in the extent.properties file by passing it from the maven command line. Not sure if extent code supports pattern matching when reading from extent.properties file.

  3. Hi Mounish:

    Is there a way to put a timestamp in the reports, in the extent.properties?

    extent.reporter.html.out=target/extent-reports/test-output/HtmlReport (Date here)/ExtentHtml.html
    extent.reporter.logger.out=target/extent-reports/test-output/Logger (Date here)
    extent.reporter.spark.out=target/extent-reports/test-output/Spark (Date here)

  4. Do we have a way to automatically rerun the failure test cases again and generated the consolidated extent html report? so that we don’t have duplicate test results in a single extent report.

      1. So what would you suggest to rerun failure cases and get a single extent report for complete execution of cucumber suite. Say I have 100 test cases and 10 got failed. Then I have executed those 10 cases and then I wanted to get a single report of 100 cases with final test results.

        1. Maybe look at merging the html files.
          There was an option in version 3 html extent report to append test results to an existing report. This is now only available in pro (license purchase) version 4. Even then in version 3, you would need to modify the adapter code to make use of this functionality.
          U could use cluecumber(https://github.com/trivago/cluecumber-report-plugin#maven-pom-settings) which consolidates all cucumber-json files to create the final report. Though not sure how it deals with reruns.

  5. Hi,

    Thank you for your post. It seems quite a few people here are having issues with screenshot embeding into extenreport. I am using cucumber 4.8.1 version for all cucumber dependencies and tried 1.0.8 and 1.0.10 for cucumber adapter4. Here is how i am setting all configurations;

    Runner:
    @CucumberOptions(features=”Feature”
    ,glue={“StepDefinitions”}
    ,plugin={“com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:”}
    ,monochrome=true)

    Extent.proerties in src/test/resources:

    extent.reporter.avent.start=false
    extent.reporter.bdd.start=false
    extent.reporter.cards.start=false
    extent.reporter.email.start=false
    extent.reporter.html.start=true
    extent.reporter.klov.start=false
    extent.reporter.logger.start=true
    extent.reporter.tabular.start=false
    extent.reporter.spark.start=true

    extent.reporter.avent.config=
    extent.reporter.bdd.config=
    extent.reporter.cards.config=
    extent.reporter.email.config=
    extent.reporter.html.config=src/test/resources/extent-config.xml
    extent.reporter.klov.config=
    extent.reporter.logger.config=
    extent.reporter.tabular.config=

    extent.reporter.avent.out=test-output/AventReport/
    extent.reporter.bdd.out=test-output/BddReport/
    extent.reporter.cards.out=test-output/CardsReport/
    extent.reporter.email.out=test-output/EmailReport/ExtentEmail.html
    extent.reporter.html.out=test-output/HtmlReport/ExtentHtml.html
    extent.reporter.logger.out=test-output/LoggerReport/
    extent.reporter.tabular.out=test-output/TabularReport/
    extent.reporter.spark.out=test-output/SparkReport/
    screenshot.dir=test-output/HtmlReport/

    Screen capture and embed code in After hook:

    try {
    if (scenario.isFailed()) {
    /
    TakesScreenshot ts = (TakesScreenshot) context.getBrowser().getDriver();
    byte[] screenshot = ts.getScreenshotAs(OutputType.BYTES);
    scenario.write(“this is my failure message……….”);
    scenario.embed(screenshot, “image/png”);

    }
    }catch(Exception e) {
    System.out.println(“status: “+scenario.getStatus()+” Exception: “+e.toString());
    }

    I am not able to generate screenshots in output folder let alone see it in report. Tried all three reports (HTML, Logger and Spark). Am i missing something here? Report is generated fine with correct information its just image is not generating and attaching.

    When i use usual pretty report plugin, it works perfectly fine with same code.

    Regards,
    Reehan

    1. Will have a look into this. Have u tried with some other version of cucumber. Last time i had worked with extent screenshot, maybe 3 months ago, the image was available in logger and spark reports. There was a pull request which supposedly fixed this. The link is somewhere in the comments section, did u by any chance had a look at it?

      1. Hi,

        Could you please share your code? I am using testng as runner. Cant seem to figure out whats wrong here. When i use Extentreport Api and its classes i can generate reports with images succesfully but with plugin its not working for me.

        Also lately i observed that all extentreport reports dashboards always show summary/piechart of Features and Scenarios as pass even if my test is failing. It does show correct reslts for tests, exceptions and tag sections. Exception part of the report also shows correct exception.

        My test is failing due to a random NoElementFoundException, its not due to assertion failure. Is there any other setting or configuration i need to do?

        Thanks,
        Reehan

  6. Getting following error :
    io.cucumber.core.exception.CucumberException: Couldn’t load plugin class: com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter
    Caused by: java.lang.NoClassDefFoundError: cucumber/api/event/ConcurrentEventListener
    Caused by: java.lang.ClassNotFoundException: cucumber.api.event.ConcurrentEventListener

    used versions:
    5.3.0
    3.141.59
    3.8.0
    1.0.10

  7. Wrt: Extent Report
    Sir, Wow was looking for this article…Thank You

    As I have just started reading Cucumber have query for the extent report sample that is shared
    In the Runner file that has been shared I observed that no glue , feature path was specified .. so in this case how does the runner know from where the files are picked up…

    Thanks VS

    1. Cucumber will automatically pick up the step definition classes and feature files as they are located in the same package structure as the runner class.

  8. This is a Design Question & not related to Cucumber..I could not find any post Relevant, so posting it here. Sorry..

    Design Questions

    1) How not to Duplicate code? Favour Composition Over inheritance (As suggested by many) or Use inheritance?
    Lets take this example of website – https://statsRoyale.com–&gt; Here we could find something like Cards on top of page and on clicking cards we get info about specific cards (i.e specific player of warrior).

    Now the Question.. Every card is similar, just the card name differs and on clickin any card the card details info is also similar and details differ..How do we model this on selenium Page object..I can create a class for every card and every card details,but its duplicate for me. So i had two other thoughts,
    a) – either use inheritance. i.e have a base page and then have generic cards page inherit base page & other specific cards page inherit generic cards page..So i will have webelements specific to each cards on specific cards page, and functions doing actions for cards on Generic cards page..so from test would interact with specific cards page which would interact with generic cards page. I would use generics (pass specific card page class as arguments) for differentiating each specific page in Generic cards page as Argument and for logging in reports
    b) Favour Composition Over inheritance – Hold an instance of Generic cards page on each specific cards page.So when navigating to specific cards page, i would instanciate generic cards page. Here again,i will have webelements specific to each cards on specific cards page,and functions for doing actions on cards in Generic cards page. I would use generics (pass specific card page class as arguments) for differentiating each specific page in Generic cards page as Argument and for logging in reports.

    Which one looks good & if not what would be your suggestion. I have come across many times similar scenarios, wherein many components would be there,just the name and ID,XPATH would be different, whereas the behaviour would be same for all..

    2). Lets take 3 test cases A,B,C (My testng test case would have only one @test method per class & i want to strictly follow the same model). A has 10 steps, B has 12 Steps & C has 15 steps.B’s first 10 steps are same as A, 2 unique to B & C 10 is same as A and next 2 is same as B. So only last 3 is unique to C. So the way i thought to design this is..
    A – Have B test class repeat 10 steps of A + its 2 unique steps & have C test class repeat 10 + 2 steps of A & B and its 3 Unique steps.. My issues – Lots & Lots of duplication here.
    B) – Create a common test class which inherits Basetest & put common steps of A and B as seperate methods and then use them in specific tests class of A,B & C. have unique steps in these specific test class implemented. For A, we only have to do assertion as all steps are in parent class.B would have 1 method called + its Unique step + assertion. C would have 2 methods called from parent, its unique steps + Assertion.
    C) – May be use Composition instead of inheritance..
    D) – Any other suggestions..

    1. What is ur email id? Can we discuss this there as I feel this query is not related to the post topic, as u also have mentioned.

  9. When I execute tests, the Hook class method names are mentioned in the logs.

    Web Authentication fail—————> The Test scenario
    ServiceHooks.initializeTest(Scenario)—–> The @before Hook
    Given Open Application and Enter url———> The Step definition Step

  10. I have tried the plugin, and it is impressive how well it works. However, I am facing with an issue wherein the class name of the Hook file and the method names are shown in the report. is there a way by which this can be avoided in the reports?

    Testing the Box Management feature

    – Scenario: The Scenario

    – Create a new Box 4
    – ServiceHooks.initializeTest(Scenario) —-> tring to get rid of this in the extent report
    – ServiceHooks.reportingStepDetails(Scenario)
    – Given Open Application and Enter url
    – ServiceHooks.reportingStepDetails(Scenario)

  11. Hi Mounish – Can we do it like this.. I want to have time stamp with reports, so that the same reports are not overwritten again.

    So in testNG Beforesuite – i felt i can do something like this.. Let me know your thoughts pls.. If this can be achieved, we don’t need to have extent.properties file in Src/test/resources folder..

    System.setProperty(“extent.reporter.html.start”, “true”);
    System.setProperty(“extent.reporter.logger.start”, “true”);
    Other System settings ————

    String time = “XyZ”
    String reportfolderpath = “MyPath” + time
    System.setProperty(“extent.reporter.html.out”, “reportfolderpath “);
    System.setProperty(“extent.reporter.logger.out”, “reportfolderpath “);
    System.setProperty(“extent.reporter.spark.out”, “reportfolderpath “);
    System.setProperty(“screenshot.dir”, “reportfolderpath “);

    Let me know if this sounds correct!!
    Thanks a Ton

  12. How do you embed a screenshot? I tried everything, still can’t do embed a screenshot to the `ExtentHtml.html` report file.

    “`
    @After
    public void teardown(Scenario scenario) {
    try {
    scenario.embed(((TakesScreenshot)driver).getScreenshotAs(OutputType.BYTES), “image/png”);
    driver.quit();
    driver = null;
    } catch (Exception e) {
    System.out.println(” @After Teardown method failed, Exception : ” + e.getMessage());
    }
    }
    “`

    1. I can see the ExtentHtml.html report generating pass/fail results.
    2. I can see the screenshots being generated in `test-output` per extent.properties dir.

    But the report html, doesnt contain the screenshots on fail.

      1. The one from the `logger` doesn’t work.
        I can see the “img” tag, but whenever you click it – the image doesn’t load and returns a 404.
        Screenshots are taken, stored, but not loaded on to the report properly.
        Checking the console – it returns a 404 due to a `localhost: ####` suffix being generated

        1. I tried with cucumber version 4.4.0 and the extent adapter 1.0.8 (one described here) and it worked. Was able to see the images in both (index.html) logger and spark reports. If possible share the relevant code and setup, will have a look. Thx

  13. Hi,
    I am able to generate report as per above information.However i am not able to add step log into html report. My Reporter.addsteplog method is not working.

    How to add step logs and screenshot path to the html report (cucumber adapter 4 plugin)?
    Like we can add in com.cucumber.lister plugin using below code
    Reporter.addsteplog(“Sample”);

  14. Thanks for response. Yes , i would be using testng. I faintly remember doing this about 8 months back with parallel = classes & it did not invoke three browsers. I tried parallel= tests as well and it did work either. Hopefully it works now.

    Ok I ll consider the other reports as well..
    Thanks a ton

  15. Hi Mounish – i have gone through your posts below and also your answers in stackoverflow (link below)
    http://grasshopper.tech/824/
    http://grasshopper.tech/466/
    https://stackoverflow.com/questions/55955236/extent-report-plugin-not-working-with-testng-cucumber
    https://stackoverflow.com/questions/55763356/extentreport-support-for-cucumber-jvm-4-0-io-cucumber

    I just have 2 questions.

    1) I am planning to run cucumber features/sceenarios in parallel using testNG.I know that since cucumber v 4.0.0, parallel execution is supported natively (no more teymers is required).So what would be the best extent report to go with this.. Vimal selvam one or i have been hearing about extent reporter cucumber adapter recently or Extent report 4 . Will this help me generate report without issues..

    2 ) i would have 3 runners (IE,FF & chrome). Now, i need to run these 3 browsers in parallel, but each of scenarios sequentially in each browser. I thought of two ways. either have all runners under one test tag and run with config as parallel =”classes” or create 3 test tag and under each test tag have one runner i.e chrome, ie,firefox & then Some thing like testng’s parallel = “tests”. Which one would work and also would extent report be generated properly..
    pls share your valuable advice.

    Thanks..

    1. For the first point go with the adapter for a simple reason it does not mess with the testing code. All extent report creation is performed in the plugin. Only con is that if you want some custom stuff u might have to modify the plugin code.

      The second point I think the easiest approach would be to run with three runners and parallel setting to ‘classes’. In the runners no need to override scenarios() method just extend the normal AbstractTestNGCucumberTests. Mention three different locations for the extent report generation. Would have to try it to be sure.
      U can refer to this comment in this post – http://grasshopper.tech/732/ from a person named ‘MJ’. Kind off similar to your requirements.

      Are you using testng.xml to run tests as u mentioned ‘test’ tags?

      For reporting, if u have not finalized extent, u should consider this one – https://github.com/trivago/cluecumber-report-plugin.

  16. Hi,

    Is there any solution for attaching the screenshot in extent report using ExtentReportsCucumber4Adapter plugin?
    Kindly help me in resolving this issue.
    Thanks in advance.

    1. You can use the embed() method of scenario object in the hooks. Extent will automatically add it to the logger and spark reports. It somehow does not appear in the html report.

  17. Excellent blog you have got here.. It’s difficult
    to find quality writing like yours nowadays. I seriously appreciate individuals like you!
    Take care!!

  18. Excellent post. I used to be checking constantly this weblog and I’m inspired!
    Very useful information specifically the last part 🙂
    I handle such info a lot. I used to be seeking this certain information for a very long time.
    Thanks and best of luck.

  19. Hi,

    I have gone through most of the articles here and implemented in the same way. In my project i need to close the browser and launch the new browser. When i am trying to close the browser i am getting NoSessionException. I have CloseBroser step definition in src\test\java\stepdef\StepDefinition.java and using the step in src\test\resources\features\feat1.feature file. Please help me out like how can i close the browser and launch the new browser. Thanks in Advance.

    1. Do u need to open close the browser with each scenario? Can you share your code on github? If not then create a sample of your code with the issue and share?

      1. Hi

        Please find the path of github project https://github.com/VakkalaBhavya/Automation . This project is cloned from your blog.

        I tried to add close browser which is not happening and giving me NoSessionException. Shared Driver concept is the one of the good implementation which i have come across so far.

        Below are the 2 Scenarios i want to implement
        1.Closing and Opening the browser within the same Scenario(addDriver and removeDriver to storedDriver).
        2. Adding morethan and removing driver, the scenario outline is as below:
        ScenarioOutline: Google Search for Cucumber
        Given Open Browser
        Then Go to google page
        When Enter search “cucumber”
        And Close Browser
        Examples : |BrowserType|
        |Chrome|
        |Firefox|

        I am Struck with this implementation. Need Your Help.
        Thanks for this great post

        1. Are you looking at running all the scenarios in the eight feature files in parallel? The cases you have mentioned above is contrary to what a SharedDriver is meant to be used for. U will have better luck using a separate runner and executing these scenarios without a SharedDriver and managing the driver creation in the before and after hook.

  20. com.aventstack
    extentreports-cucumber4-adapter
    1.0.8
    system
    D:/extentreports-cucumber4-adapter.jar

  21. Can anyone help how to add the system path in the build.gradle.

    In the above article mentioned the below dependency to add in the pom.xml

    com.aventstack
    extentreports-cucumber4-adapter
    1.0.8
    system
    D:/extentreports-cucumber4-adapter.jar

    In Gradle how to implement the and

  22. In the Cucumber higher version more than 4.2.0, to add the URLOutputStream as a source *How to import the sources and use with maven to install the jar in the local repository* ??

  23. เครื่องชาร์จแบตเตอรี่รถยนต์ราคา says:

    Hi there i am kavin, its my first occasion to commenting anywhere, when i read this article i thought i could also make comment due to this good article.

    1. Are u getting any errors? U need to remove “not @Api” from the hook methods. This was relevant to the other user but not your case.

      1. I am stuck and seriously need some help regarding this issue.

        As suggested, I have added the webhook “Hook.java” and added @AfterStep and @After – methods to capture the screenshots using
        final byte[] screenShot = ((TakesScreenshot) DriverFactory.getDriver())
        .getScreenshotAs(OutputType.BYTES);
        scenario.embed(screenShot, “image/png”);

        On running “mvn install” – Reports got generated by using extentreports-cucumber4-adapter and cluecumber-report-plugin.

        For some reason, the extentReport HTML report doesn’t add the screenshot but looking into Spark report the screenshot image got embedded .
        “extent.reporter.html.out=test-output/HtmlReport/ExtentHtml.html”
        cluecumber-report-plugin report embedded the image correctly to the report.

        I want to write custom messages from the step definition to report

        @When(“Enter search {string}”)
        public void when(String search) {
        gsPO = ghPO.performSearch(search);
        System.out.format(“\nCount results for %s search is %d.\n”, search, gsPO.searchResultCount());
        //Logger message “Scenarios.write” messages but couldn’t finding any workaround to add those messages.
        }
        I need to add additional messages to the report.
        Updated project: https://github.com/automatenew/testngmultiplebrowser

        Thanks in advance.

        1. Not sure why the screenshot is not appearing in the extent report. Have to go deeper but you can use the spark or logger report as it is basically the same.
          To add custom messages from the step definition methods, there is no easy way. U would need to modify the extent-adapter itself to get hold of the step text. The link to the source is in the article.

  24. Now i wanted to implement the extent report in my framework. Can you tell me how to do it using plugin which which add the logs same as the cucumber statement added in the feature file.

    1. If you are referring to the steps in the feature file they are already present in the extent report

  25. Could you please show the example in a project that uses TestNG to run cucumber feature files parallel such as your previous post?

    1. It does not matter if u are running in parallel. No additional settings are required to generate the extent report. It is mentioned as such in the last section too. If I misunderstood, can u expand on what u are looking for?

      1. I did try the extent report integration on the testng parallel framework that you have showed earlier and the HTML report was looking like a broken page. I was not sure what was wrong. I thought something I did wrong with the set up. But realized it is a browser issue that the js and style sheets are not loading due to browser settings.Pl ignore my earlier comment.
        Can I have your email id to ask couple of cucumber jvm 4 specific questions?

Leave a Reply

Your email address will not be published. Required fields are marked *