Open Snehaveeranna opened 1 year ago
Also, please help in achieving this. I need to integrate extent report to my Cucumber with Playwright framework. Presently i am using extent cucumber adaptor and since we are not able to call the extent report, my reports are overlapping. Could you please suggest me some work around, where report should have scenario name and Steps inside this and insider each steps i can add customized logs.
In the adapter you can access the currently executing step and scenario by using the static methods. https://github.com/grasshopper7/extentreports-cucumber7-adapter/blob/049d5b823ce9c2c29bc90c901876ca4f96b9eb19/extentreports-cucumber7-adapter/src/main/java/com/aventstack/extentreports/cucumber/adapter/ExtentCucumberAdapter.java#L515. You do not need to write code that creates the extent test structure.
To add your custom logs to the step you can also use the cucumber log methods.
I am already using Addstep method, but when element is not found sometimes report is overlapping. Is there any way to start and close the extent report?
What do you mean by overlapping? Can you add an image of this?
This is not the proper way of reporting right?
Nope this is not correct. Is this the report generated when you use only the adapter?
Also is this the HTML report? Have you tried with the Spark report?
Can you give some more details when this is happening?
Hi, yes even in Spark report we are facing same issue. When we are running test cases in batch using Cucumber format, if element is not identified in once step then it will continue to next step. during these scenarios it is failing.
Hi, Can you create a sample code in a public repo which is generating this error? I am unable to recreate this. Would be very helpful.
Hi, is there any sample project where extent report is used with cucumber Java?
Hi,
Is it possible to identify the issue if i provide complete HTML for correct report and overlapped report?
That would help. Can you replicate the issue with sample code?
I have tried to replicate this issue in numerous ways but unable to replicate it. Seems to be some HTML character which is causing the report display to be spoiled. I would need your help on this by providing the report and if possible a sample code.
Hi, I am unable to replicate with sample code. But i have correct and corrupted html details of that. I will add that here. Overlapped report.txt Correct Report.txt
Thanks I will have a look at these files.
And i also observed combining of logs. When 2 test cases fails then logs are combining. The second test case logs are not fully displayed. I have attached screenshot and HTML for reference. [Uploading Combining report.txt…]()
The previous file is not uploaded. Can you try again? Can you also share the correct and incorrect reports with the Spark report.
Spark Overalapped report.txt Combining report.txt
I dont have spark correct report. But i have attached combined report with spark.
What i observed in combining report issue is, i can see all steps for 2nd testcase in HTML but it is not showing in report UI.
What does the 'Student groups and Student Ledger' feature file contain (from the Spark report). I mean does it contain scenario outlines also? Just send me the list of scenario\scenariooutline with names.
One more info, if you use these two lines together for same step it is combining or sometimes even wont log anything after this.
ExtentCucumberAdapter.getCurrentStep().log(Status.FAIL, MediaEntityBuilder.createScreenCaptureFromBase64String(PlaywrightFactory.takeScreenshot()).build()); ExtentCucumberAdapter.getCurrentStep().log(Status.FAIL, e.getMessage());
Hi Can you also add the feature file(s)? It will be very helpful.
Why are you adding log for exception and screen images? The adapter will handle it automatically. This is confusing.
Refer to the sample project Screenshots -> https://github.com/grasshopper7/cuke7-extent-adapter-report/blob/59bc1098f7dfb74495564fcc03ea0e4fce7dfbe2/cuke7-extent-adapter-report/src/test/java/stepdefs/Stepdefs.java#L218 -- Using scenario.attach()
Text log -> https://github.com/grasshopper7/cuke7-extent-adapter-report/blob/59bc1098f7dfb74495564fcc03ea0e4fce7dfbe2/cuke7-extent-adapter-report/src/test/java/stepdefs/Stepdefs.java#L109 -- Using scenario.log()
Exception -> Any exception thrown by selenium or playwright is sent to the adapter by cucumber events and is added to the step test. -> https://github.com/grasshopper7/extentreports-cucumber7-adapter/blob/049d5b823ce9c2c29bc90c901876ca4f96b9eb19/extentreports-cucumber7-adapter/src/main/java/com/aventstack/extentreports/cucumber/adapter/ExtentCucumberAdapter.java#L190
I am not sure why you have such a messed up report. I would comment all the custom logs or tests you might have added in the step definition and run the test. Do not add your own custom tests to the currently executing step or scenario.
So we should use scenario.log instead of adaptor log. Then where and when can we use adaptor log?
only in cases where the scenario object is not accessible. Best to be avoided.
I think you are explicitly adding extent tests to the scenario object in your code.
Previously i was using only adaptor log and screenshot, as you have suggested i have updated everything to scenario.log. It was working fine when i ran 2 feature file in batch but when i tried with 6 feature file it again overlapped.
Check if you have added extent tests to scenario test. Try running features individually and check.
Individually it was working fine. Let me explain you the scenario. I have 1 class where i have overridden page class methods and after the method i want to log the actions in extent report, this is one scenario. And i have page class where i am doing action and here i am comparing 2 values if it is matching i want to print in extent report as it is matching if not then not matching. So should i use in these case?
Hard to comment without access to code. As long as the page methods are called from stepdefinitions method everything should work. Log actions using scenario.log() in step definition and for assertions just use the assert() method. No need to explicitly log this.
There is one bug in this html report. If you click on the Test case hyperlink it will not go to the same test case step.
How to add logs like "opening broswers" in cucumber report under Steps.
Below is the sample step i am following: ExtentTest feature = extent.createTest(new GherkinKeyword("Feature"), "Refund item"); ExtentTest scenario = feature.createNode(new GherkinKeyword("Scenario"), "Jeff returns a faulty microwave"); scenario.createNode(new GherkinKeyword("Given"), "Jeff has bought a microwave for $100").pass("pass"); feature.info("logging"); scenario.createNode(new GherkinKeyword("And"), "he has a receipt").pass("pass"); scenario.createNode(new GherkinKeyword("When"), "he returns the microwave").pass("pass"); scenario.createNode(new GherkinKeyword("Then"), "Jeff should be refunded $100").fail("fail");
Here, i am trying to log but its not showing in report. Attached screenshot for reference.