Skip to content

Instantly share code, notes, and snippets.

@schmittjoh
Forked from michalochman/gist:3175175
Created July 6, 2014 13:35
Show Gist options
  • Save schmittjoh/be041ce4ee00f80d5ed4 to your computer and use it in GitHub Desktop.
Save schmittjoh/be041ce4ee00f80d5ed4 to your computer and use it in GitHub Desktop.
/**
* Take screenshot when step fails.
* Works only with Selenium2Driver.
*
* @AfterStep
*/
public function takeScreenshotAfterFailedStep($event)
{
if (4 === $event->getResult()) {
$driver = $this->getSession()->getDriver();
if (!($driver instanceof Selenium2Driver)) {
//throw new UnsupportedDriverActionException('Taking screenshots is not supported by %s, use Selenium2Driver instead.', $driver);
return;
}
$screenshot = $driver->wdSession->screenshot();
file_put_contents('/tmp/test.png', base64_decode($screenshot));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment