Created
November 26, 2020 17:31
-
-
Save vivrichards600/ae658e9f4c5b3d9787a68879d0be3b25 to your computer and use it in GitHub Desktop.
Scala/Cucumber - take a screenshot after each step
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hooks extends ScalaDsl with EN with BrowserDriver { | |
AfterStep { scenario: Scenario => | |
if (scenario.isFailed) { | |
val screenshotName = scenario.getName.replaceAll(" ", "_") | |
val screenshot = driver.asInstanceOf[TakesScreenshot].getScreenshotAs(OutputType.BYTES) | |
scenario.attach(screenshot, "image/png", screenshotName) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment