Skip to content

Instantly share code, notes, and snippets.

@vivrichards600
Created November 26, 2020 17:31
Show Gist options
  • Save vivrichards600/ae658e9f4c5b3d9787a68879d0be3b25 to your computer and use it in GitHub Desktop.
Save vivrichards600/ae658e9f4c5b3d9787a68879d0be3b25 to your computer and use it in GitHub Desktop.
Scala/Cucumber - take a screenshot after each step
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