Discussion:
[Cucumber] [JVM] Need help on embedding scenario to the serenity reports!!!
(too old to reply)
Anji Prassana
2017-12-12 15:16:01 UTC
Permalink
Hi,
I am using cucumber jvm to create the scenarios and to implement the
steps. But, for running we are using cucumberWithSerenity.class as
follows...
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
features = "classpath:features",
plugin = {"pretty", "html:target/cucumber-html-report"},
tags = {"@UserAccounts"}
)
public class RunCukesTest{
}

we are using serenity maven plugin for generating the reports.
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>1.8.1</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>

I have the teardown method where we are embedding the screenshots...
@After
public void tearDown(Scenario scenario) throws IOException,
InterruptedException {

if(scenario.isFailed()) {
try {
scenario.write("Current Page URL is " + driver.getCurrentUrl());
//wait for 5 secs for the page loads to finish
Thread.sleep(5000);
*Serenity.takeScreenshot();*
//byte[] screenshot = getScreenshotAs(OutputType.BYTES);

File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String fileName =
System.getProperty("user.dir")+"//Screenshots//"+scenario.getName().replaceAll(":",
"")+
System.currentTimeMillis()+".png";
System.out.println("writing screenshot to the file: "+fileName);
File destFile = new File(fileName);

if(!destFile.exists())
destFile.createNewFile();

FileUtils.copyFile(srcFile, destFile);
*scenario.embed(((TakesScreenshot)driver).getScreenshotAs(OutputType.BYTES),
"image/png");*
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
System.err.println(somePlatformsDontSupportScreenshots.getMessage());
}

}
driver.quit();
}


Its giving me the screenshot in cucumber generated html report in
*target/cucumber-html-report* folder. But the serenity generated report
under *target/site/serenity* doesn't contain the screenshots. I even tried
serenity.properties file configuration but its affecting the project name
in the report but no screenshots are displaying.

serenity.project.name = Kelvatek Web Test Automation Results
serenity.take.screenshots = FOR_FAILURES

can someone please help me out!!!
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Koen Prins
2017-12-13 18:39:50 UTC
Permalink
I would recommend posting your question in the serenity group. As you point
out yourself is it working under Cucumber but not Serinity.
Post by Anji Prassana
Hi,
I am using cucumber jvm to create the scenarios and to implement the
steps. But, for running we are using cucumberWithSerenity.class as
follows...
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
features = "classpath:features",
plugin = {"pretty", "html:target/cucumber-html-report"},
)
public class RunCukesTest{
}
we are using serenity maven plugin for generating the reports.
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>1.8.1</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
I have the teardown method where we are embedding the screenshots...
@After
public void tearDown(Scenario scenario) throws IOException,
InterruptedException {
if(scenario.isFailed()) {
try {
scenario.write("Current Page URL is " + driver.getCurrentUrl());
//wait for 5 secs for the page loads to finish
Thread.sleep(5000);
*Serenity.takeScreenshot();*
//byte[] screenshot = getScreenshotAs(OutputType.BYTES);
File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String fileName =
System.getProperty("user.dir")+"//Screenshots//"+scenario.getName().replaceAll(":",
"")+
System.currentTimeMillis()+".png";
System.out.println("writing screenshot to the file: "+fileName);
File destFile = new File(fileName);
if(!destFile.exists())
destFile.createNewFile();
FileUtils.copyFile(srcFile, destFile);
*scenario.embed(((TakesScreenshot)driver).getScreenshotAs(OutputType.BYTES),
"image/png");*
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
System.err.println(somePlatformsDontSupportScreenshots.getMessage());
}
}
driver.quit();
}
Its giving me the screenshot in cucumber generated html report in
*target/cucumber-html-report* folder. But the serenity generated report
under *target/site/serenity* doesn't contain the screenshots. I even
tried serenity.properties file configuration but its affecting the project
name in the report but no screenshots are displaying.
serenity.project.name = Kelvatek Web Test Automation Results
serenity.take.screenshots = FOR_FAILURES
can someone please help me out!!!
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...