Using Serenity.takeScreenShot() without @Steps

1,120 views
Skip to first unread message

m...@itscope.de

unread,
Feb 12, 2016, 9:44:14 AM2/12/16
to Serenity BDD Users Group
Hi everyone!

Our company has decided to use Serenity BDD as automated acceptance tests reporting library. As we already have a full blown test suite for our web app, serenity has to adapt to our current testing structure. With little adjustment, Serenity is running fine with our testframe, both local in Intellij and Console, and on a Jenkins server. JIRA integration works also well.

Our problem is, when it comes to screenshots. We don't use the @Steps and @Step annotation, because the current test suite wasn't designed with that in mind, and adapt to it would mean major changes. Okay I thought, lets use Serenity.takeScreenshot() to force Serenity making ones, and aggregating it to the @Test method in the report. Well, good thought, but made me fail: Serenity.takeScreenShot() goes to

public static void takeScreenshot() {
StepEventBus.getEventBus().takeScreenshot();
}

goes to

public void takeScreenshot() {
getBaseStepListener().takeScreenshot();
}

goes to 

public void takeScreenshot() {
take(MANDATORY_SCREENSHOT);
}

goes to

private void take(final ScreenshotType screenshotType) {
take(screenshotType, UNDEFINED);
}

goes to 

private void take(final ScreenshotType screenshotType, TestResult result) {
if (shouldTakeScreenshots()) {...

goes to

private boolean shouldTakeScreenshots() {
return (currentStepExists() && browserIsOpen() && ...

goes to

private boolean currentStepExists() {
return !currentStepStack.isEmpty();
}

and obviously and silently fails to make a screenshot. currentStepStack is of course empty, because no @Step was declared in the first place. It seems, the mandatory screenshot isn't as mandatory as I thought.

My wish would be to make us able to use Serenity.takeScreenshot(). Either by removing currentStepExists() in the 5-fold logical expression in shouldTakeScreenshots(), or by making another check, if @Step(s) is null/empty, and then associating the screenshot to the @Test method in the report. 

Silently failing a 5-fold logical expression with no logging trace is a bit weird, as there are other people having problems to get screenshots in their reports.
https://groups.google.com/forum/#!topic/thucydides-users/SfiihhcUzCc

Making it possible to force screenshots at will would give at least a better-than-blind option. It would be even nicer, if something like Serenity.takeScreenshot("Here I log in") would exist, to put a string to the forced screenshot in the report. Forcing a screenshot, even between two @Step isn't as handy as knowing WHY the screenshot has been forced.

if(mischief){
    Serenity.takeScreenshot("mischief has happened");
    pulldown();
}

Or is there another way to have screenshots be taken without using a Step library? 


Greetings




PS: All plugins and dependancies are at their latest release version in the pom.xml, except for serenity-junit, as it puts all passed and pending tests to :/ pending in version 1.1.24. Therefore, we use 1.1.21


Jorge Desilvestro

unread,
Mar 31, 2016, 12:24:21 PM3/31/16
to Serenity BDD Users Group
did you make any progress on this? im having the same problem.
thanks!
Reply all
Reply to author
Forward
0 new messages