Closed abhishekrhyme closed 4 years ago
@abhishekrhyme Please share your extent.properties
.
extent.reporter.html.start=true extent.reporter.logger.start=true extent.reporter.spark.start=true
extent.reporter.html.config=src/test/resources/extent-config.xml extent.reporter.logger.config=src/test/resources/extent-config.xml extent.reporter.spark.config=src/test/resources/extent-config.xml
extent.reporter.html.out=test-output/HtmlReport/ExtentHtml.html extent.reporter.logger.out=test-output/Logger extent.reporter.spark.out=test-output/Spark
screenshot.dir=test-output/ screenshot.rel.path=../
Use this:
extent.reporter.html.start=false
extent.reporter.logger.start=false
extent.reporter.spark.start=true
extent.reporter.html.config=src/test/resources/extent-config.xml
extent.reporter.logger.config=src/test/resources/extent-config.xml
extent.reporter.spark.config=src/test/resources/extent-config.xml
extent.reporter.html.out=test-output/HtmlReport/ExtentHtml.html
extent.reporter.logger.out=test-output/Logger/
extent.reporter.spark.out=test-output/Spark/
screenshot.dir=test-output/
screenshot.rel.path=../
I tried this but no luck stil the spark report without screenshots.
Can you make sure you have the latest snapshot? Can you force refresh the project along with all snapshots?
done still not working... here is my sample code
public class Steps {
private WebDriver driver;
@BeforeStep
public void beforeStep() throws InterruptedException {
Thread.sleep(250);
}
@AfterStep
public void afterStep(Scenario scenario) {
System.out.println("AFTER STEP");
TakesScreenshot ts = (TakesScreenshot) driver;
byte[] screenshot = ts.getScreenshotAs(OutputType.BYTES);
scenario.write("step is completed……….");
scenario.embed(screenshot, "image/png");
}
@Given("open facebook")
public void open_facebook() {
// System.setProperty("webdriver.chrome.driver", "chromedriver"); WebDriverManager.chromedriver().setup(); Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("profile.default_content_setting_values.notifications", 2); ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("prefs", prefs); options.setPageLoadStrategy(PageLoadStrategy.NONE); driver = new ChromeDriver(options); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS); driver.get("https://www.facebook.com"); driver.manage().window().maximize(); String title = driver.getTitle(); System.out.println(title); }
Can you share your HTML file?
attached
No attachments.
You are not using the latest snapshot:
https://github.com/abhishekrhyme/Cucumber4AdapterExample/blob/master/CucumAdaptar2/pom.xml#L19
Hi @anshooarora Updated the snapshot and dependency but the screenshots are still not attached. https://github.com/abhishekrhyme/extentadapter.git
Hi @anshooarora , Upon using, ExtentCucumberAdapter.addTestStepScreenCaptureFromPath(imagepath); - I enabled html report and was able to get the screenshots in html report. scenario.embed(Files.readAllBytes(Paths.get(imagepath)), "image/png”); - But in spark report screenshots are still missing.
My git repo is updated if you want to have a look at HTML reports. https://github.com/abhishekrhyme/extentadapter.git
I have used the latest snapshot
Please advise if you want me to try anything else.
Also one point, the screenshots are not inserted in html report, i believe its just a link, if the screenshots from folder are deleted, image is not opening.. in this case if we email html report alone to anybody without screenshots, image wont open from html report right?
I have same issue, in Spark there is no screenshots at all and in HTML report there are screenshot icons looking in right folders but thing is screenshots are saved in test-output no matter what I do
The feature to specify the screenshot save location, and its relative path to the HTML file has been added in 1.0.11-SNAPSHOT. I will publish the release and also share details of how to utilize this enhancement.
Please feel free to use the SNAPSHOT version until then, the instructions are towards the end of this ticket. The below 2 settings are available to use:
screesnshot.dir=test-output/
screenshot.rel.path=../
Please use the latest release 1.0.11
and refer to this section.
It’s not working please verify with user before closing defect. It is redundant process to keep creating defects for the same issue as there is no reopen option available. Behavior is same as before... only hooks in the report are not appearing now rest screenshots don’t appear anywhere with scenario.embed function.
@anshooarora tagging you to refer above comment.
Can you update your project with the latest updates?
Also see my comment here: https://github.com/extent-framework/extentreports-cucumber4-adapter/issues/20#issuecomment-612212611
If you are using @BeforeStep
or @AfterStep
, use 1.0.12-SNAPSHOT after enabling SNAPSHOTS. Otherwise, use the current release version.
Thanks for the comment. Sure will give it a try and let you know.
@anshooarora I have used 1.0.11 release and also didn’t use @AfterStep as you advised, but there are no screenshots saved under test-output folder or attached to HTML report.
This are the steps used for taking screenshot: byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); scenario.embed(screenshot, "image/png”);
Please check my updated repo and checkout the html reports and properties file. https://github.com/abhishekrhyme/extentadapter
Here is what I see:
There are 3 images attached.
yes, screenshots are showing in ur screenshot, but in the HTML report from repo I am seeing nothing. I am using mac and opening the HTML in chrome, not sure if any plugin is required. I can see only a paperclip icon attached to the scenario.
I see this as the path src='../embedded1.png'
https://github.com/abhishekrhyme/extentadapter/blob/master/test-output/Spark/Index.html#L172
but I do not see any images in this folder:
https://github.com/abhishekrhyme/extentadapter/tree/master/test-output
Why is that? No wonder nothing is showing for you because the screenshots are not being saved to test-output
.
@anshooarora It may be due to screenshot.rel.path attribute, yes screenshots are being generated but it is going in a different folder. It may be a Mac feature, any idea how to get this fixed other than not having space in the project location path.
My Project path is this location: /Users/abhisheksen/My Computer/My Projects/eclipse-workspace-v1/extentadapter/test-output
while screenshot are getting saved here: /Users/abhisheksen/My%20Computer/My%20Projects/eclipse-workspace-v1/extentadapter/test-output
And this is the very reason report is not displaying the screenshots though having the link if we move these screenshots in the original location, screenshots will display. The below images will give you a clear idea.
I am on windows and I have same issue as mentioned above but I do not see any screenshots in reports, I've moved all of my reports to test-output because of this, and still nothing, sometimes it generates screenshots but it is in that %20 folder, sometimes it doesn't even generate screenshot but at the end, there is no screenshot icon in html report nor spark report
@abhishekrhyme not sure if it helps but can you try ./test-output/
in extent.properties.
@vzenzo Are you using @After
or @AfterStep
? Version? Can you create a small snippet or project?
@vzenzo Are you using
@After
or@AfterStep
? Version? Can you create a small snippet or project?
I am using @AfterStep
@AfterStep
public void afterStep(Scenario scenario) {
TakesScreenshot ts = (TakesScreenshot) driver;
byte[] screenshot = ts.getScreenshotAs(OutputType.BYTES);
scenario.write("Step finished");
scenario.embed(screenshot, "image/png");
}
I am using it in Hooks class, the problem I am occurring is sometimes it doesn't even save picture and the report doesnt't have picture link. I am using 1.0.11
I have later made my own code to take screenshot, just don't know how to implement it into a report
Also some of the colors on charts are mixed up but thats another issue.
@AfterStep
- use version 1.0.12-SNAPSHOT.
Due to an error, the AfterStep hook was removed but is now included in the latest snapshot.
I tried by changing screenshot.dir but no help. It is still goin in %20 folders.
I referred to your screenshots above and this happens because the default way to save screenshots is by writing against a URL. See the official Cucumber HTML formatter. Any space would be replaced by %20
so I would advise you to not have any spaces, use -
or _
where necessary. This is also why I was unable to reproduce the behavior you are.
@anshooarora Got your point so in Spark report as screenshots look into the project folder to link screenshots, and if we have space in project path because of formatter it will go to %20 folder, so we need to keep this in mind. For now I have moved the screenshots (manually) to project folder, and spark report is showing the screenshots. Step is: scenario.embed(((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES), "image/png");
I would prefer using HTML report where I can actually attach the image by taking Base64 screenshot. In this way screenshots from the report won’t look to any folder, and if I email or check the report in a different system (which is actually my objective), the images won’t get lost. Step is: ExtentCucumberAdapter.addTestStepScreenCaptureFromPath(getBase64Screenshot(driver));
I have also updated the repo for reference. Repository: https://github.com/abhishekrhyme/extentadapter
Both my html and spark report is displaying screenshots now. Test Reports: Html: https://github.com/abhishekrhyme/extentadapter/tree/master/test-output/Extent Spark: https://github.com/abhishekrhyme/extentadapter/tree/master/test-output/Spark
Thanks for the update.
@anshooarora i have a query here,in html report you are attaching this as base64string.So we can share the report across no need to depends on the local image file.But in Spark report and even for additional logo also,attached image is depends on the local path and image .Just correct me if i am wrong,so my request is there anyway we can add the image in both these case also as similar to html report .
My requirement is to share the report via mail...... added logo and spark report attachments are missing beacuse of this dpendency i feel. aftre i shared the report across
@abhishekrhyme I went through your repo and I am using below code to capture screen shot in html report and its working as expected if(scenario.isFailed()) { ExtentCucumberAdapter.addTestStepScreenCaptureFromPath(getBase64Screenshot(Pojo.getDriver())); byte[] screenshotBytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); scenario.embed(screenshotBytes, "image/png"); }
But but it is strange that if I remove this snippet from the code byte[] screenshotBytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); scenario.embed(screenshotBytes, "image/png"); Then screenshots does not get attach with in the HTML report.
Any thought on this behaviour?
Didn’t understand , the lines u remove r for capturing screenshot. So u can’t remove them if u aim for screenshots
On Fri, Oct 16, 2020 at 3:55 PM vishal131991 notifications@github.com wrote:
@abhishekrhyme https://github.com/abhishekrhyme I went through your repo and I am using below code to capture screen shot in html report and its working as expected if(scenario.isFailed()) {
ExtentCucumberAdapter.addTestStepScreenCaptureFromPath(getBase64Screenshot(Pojo.getDriver())); byte[] screenshotBytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); scenario.embed(screenshotBytes, "image/png"); }
But but it is strange that if I remove this snippet from the code byte[] screenshotBytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); scenario.embed(screenshotBytes, "image/png"); Then screenshots does not get attach with in the HTML report.
Any thought on this behaviour?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/extent-framework/extentreports-cucumber4-adapter/issues/48#issuecomment-709962542, or unsubscribe https://github.com/notifications/unsubscribe-auth/APAGTYDIAE674PKKWPR5RADSLANSTANCNFSM4MDMYXPQ .
--
Thanks & Regards
Abhishek Sen
Contact: +91 7618769358
https://www.linkedin.com/in/senabhishek/ https://www.linkedin.com/in/senabhishek/
https://github.com/extent-framework/extentreports-cucumber4-adapter/issues/20 as this is closed so raising a new one.. same issue not able to attach a screenshot in report. I looked into other issues but couldnt get my issue fixed.
I am not getting screenshots in spark report/logger report, only blue icon is displayed.
using adapter 1.0.8 and cucumber 4.8.1 also, 1.0.11-SNAPSHOT repo not available. Here is the screenshot.