Skip to content

Instantly share code, notes, and snippets.

@akuzemchak
Created March 7, 2014 14:18
Show Gist options
  • Save akuzemchak/9412280 to your computer and use it in GitHub Desktop.
Save akuzemchak/9412280 to your computer and use it in GitHub Desktop.
Take screenshot of failed Behat step
<?php
use Behat\Behat\Event\StepEvent;
use Behat\Behat\Event\SuiteEvent;
use Behat\MinkExtension\Context\MinkContext;
class FeatureContext extends MinkContext
{
/**
* @AfterStep
*/
public function after(StepEvent $event)
{
if ($event->hasException()) {
$title = $event->getLogicalParent()->getTitle();
$this->saveScreenshot($title . '.png', __DIR__ . '/../../logs');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment