Taking Screen Shots using Cucumber

896 views
Skip to first unread message

Swaroop Swaroop

unread,
Oct 18, 2015, 2:21:29 AM10/18/15
to Cukes
Hello Everyone,

I have been trying to implement how can the different capabilities of Cucumber can be utilized in an automation Framework.

I have come across the following on my research on the internet.

1. Animated Results can be attached to Final Reports of cucumber - Could anybody give a small example with Cucumber Webdriver.
2. Screenshots taken can be attached into the reports.html

However when i tried to implement it in my automation framework which integrates WebDriver and Cucumber; I am unable to get the proper integration.

Attached is the screenshot of my project. Please help and suggest asap. I have the code inserted here with @After annotation. However i do not know where and how it will be called when steps fail during execution.

1. I have tried failing the steps but at that time this screenshot must have been called. I did not receive any indication of this.
2. I have created this method under a Java class. Should i create it under a Separate class and if yes how do i call it since step definitions do not allow extending to other classes.

Appreciate your time and help in this regard.

Regards,
Swaroop
Cucumber Screen Shot Example.png

aslak hellesoy

unread,
Oct 18, 2015, 4:34:04 AM10/18/15
to Cucumber Users
On Sun, Oct 18, 2015 at 7:21 AM, Swaroop Swaroop <swaro...@gmail.com> wrote:
Hello Everyone,

I have been trying to implement how can the different capabilities of Cucumber can be utilized in an automation Framework.

I have come across the following on my research on the internet.

1. Animated Results can be attached to Final Reports of cucumber - Could anybody give a small example with Cucumber Webdriver.

Can you be more specific what you mean by animated results? Do you mean an .mp4 file? Something else?
 
2. Screenshots taken can be attached into the reports.html

However when i tried to implement it in my automation framework which integrates WebDriver and Cucumber; I am unable to get the proper integration.

Attached is the screenshot of my project. Please help and suggest asap.

Don't you feel a bit weird using the word "asap" when you're not paying the people you're asking for help?
 
I have the code inserted here with @After annotation. However i do not know where and how it will be called when steps fail during execution.

1. I have tried failing the steps but at that time this screenshot must have been called. I did not receive any indication of this.
2. I have created this method under a Java class. Should i create it under a Separate class and if yes how do i call it since step definitions do not allow extending to other classes.


The 2nd argument to the Scenario.embed method should be a MIME type, not a file path. Try this:

scenario.embed(screenshot, "image/png");

Cheers,
Aslak
 
Appreciate your time and help in this regard.

Regards,
Swaroop

--
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Swaroop Swaroop

unread,
Oct 18, 2015, 4:58:48 AM10/18/15
to cu...@googlegroups.com
Dear Aslak,

Thanks for the quick response.

I found about the Animated reports at the below link:
https://advancedweb.hu/2015/04/28/animated-failure-reports-with-selenium-and-cucumber/

Next regarding taking screenshots i also have tried mime type. But not able to get it.
Below is the code I am using with @After annotation.
@After
public void embedScreenshot(Scenario scenario) {
	if (scenario.isFailed()) {
		try {
			byte[] screenshot = ((TakesScreenshot) FeatureTest.driver)
					.getScreenshotAs(OutputType.BYTES);
			scenario.embed(screenshot, "image/png");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Regards,
Swaroop



You received this message because you are subscribed to a topic in the Google Groups "Cukes" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cukes/Th6Fev42Vs4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cukes+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Thanks & Regards,
Swaroop
Reply all
Reply to author
Forward
0 new messages