Skip to content

Instantly share code, notes, and snippets.

@jhedstrom
Created December 8, 2015 17:38
Show Gist options
  • Save jhedstrom/38be8a6e263947d7e7c0 to your computer and use it in GitHub Desktop.
Save jhedstrom/38be8a6e263947d7e7c0 to your computer and use it in GitHub Desktop.
Behat Selenium driver screenshot
<?php
/**
* @AfterStep
*/
public function takeScreenShotAfterFailedStep(AfterStepScope $scope) {
if (99 === $scope->getTestResult()->getResultCode()) {
$driver = $this->getSession()->getDriver();
if (!($driver instanceof Selenium2Driver)) {
return;
}
file_put_contents('/path/to/screenshots/filename.png', $this->getSession()->getDriver()->getScreenshot());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment