serenity-bdd / serenity-cucumber-starter

A skeleton project for Serenity BDD and Cucumber JVM
Apache License 2.0
180 stars 285 forks source link

Unable to define when a screenshot is taken #57

Closed AvA0808 closed 2 years ago

AvA0808 commented 2 years ago

Hello @wakaleo

For my screenshots I have some lines of code in the @Step methods to: scroll the element into view, highlight it, and then un-highlight it at the end of the method.

This all works fine. The issue I am having is I can't get the screenshot to be taken on the actions inside the @Step method (on click, on type, etc.). The screen shot is taken after the @Step method so the element is not highlighted (because I un-highlight right at the end of the method).

I have tried:

But nothing has worked. Any suggestions on this? (is it possible to tell serenity exactly when to take the screenshot?)

wakaleo commented 2 years ago

You need to use Screenplay for this, or call Serenity.takeScreenshot() for one-off screenshots

AvA0808 commented 2 years ago

@wakaleo I am not sure how I did not find Serenity.takeScreenshot(); in my search.

Thank you for the help, it works for what I need.