4

I am using serenity in combination with cucumber for automated screen tests and want to include full-page screenshots in my serenity report. The screenshots in the report are normally only a capture of the viewport. Oftentimes however, this doesn't provide enough information as this is only a part of the screen.

I found that the capturing of serenity screenshots is a part of driver implementation. As most drivers conform with the W3C definition of screenshots those drivers only capture the current viewport.

In this discussion I found that this is a common problem for test-automation. Comment 143 mentions this great library for customizing screenshots.

I got this to work in my code, however I would now like to integrate this into the serenity report and this is where I got stuck.

Does anyone know how to replace (or add) the standard screenshot-capturing-part of the serenity using the above library?

I would already be helped a lot if someone could tell me where the screenshot-capturing part of the serenity code is located.. Is it somewhere inside serenity-core?

74nine
  • 838
  • 7
  • 13
  • For now, I solve this problem by generating my most important report using FirefoxDriver, as this one does capture screenshots of the full page for now. However, I am still looking for the answer to this question as this isn't going to stay like this forever. For more information see my other question [to be posted]. – 74nine Jan 13 '17 at 08:06
  • [link to my other question](http://stackoverflow.com/questions/41630075/how-do-i-include-screenshots-of-the-full-page-in-my-serenity-report-and-not-onl/41630076#41630076) – 74nine Jan 13 '17 at 08:34

1 Answers1

1

The above mentioned Selenium - Shutterbug library can be used in combination with Serenity-BDD in a PageObject use the following line.

Shutterbug.shootPage(getDriver()).save();

Tip Serenity-BDD fine-tuning screenshots in your living documentation

Through the serenity.properties as shown below:

serenity.take.screenshots.for.tasks=after_each_step
serenity.take.screenshots.for.interactions=for_failure
serenity.take.screenshots.for.questions=after_each_step
Verhagen
  • 3,885
  • 26
  • 36
  • 1
    What you say is to specify the frequency of screenshots being taken. My problem is the implementation of the taking of screenshots; being only of the viewport instead of the whole page. To my knowledge this can't be done anywhere with Serenity's standard methods so I'm wishing for a way to alter Serenity's inner workings so to say. – 74nine Jan 11 '17 at 14:07
  • __Serenity-BDD__ uses Selenium, so I guess, also for taking screenshots. And there are issues with some browser, taking full page screenshots. What browser are you using ? See also for example: http://stackoverflow.com/questions/17885169/selenium-chrome-driver-makes-screenshot-just-of-visible-part-of-page – Verhagen Jan 12 '17 at 08:37
  • I might not understand you correctly, but you are not providing a way to integrate this custom screenshot in the report or are you? Like I said, I already got the custom screenshot to work at a time of my choosing, but I would like to let serenity use this custom method for the screenshots in the report. – 74nine Jan 12 '17 at 10:37
  • To answer your other question: ideally I would like this to work in Chrome, FF ánd IE. But initially I am trying to get it to work with Chrome – 74nine Jan 12 '17 at 10:40