Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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