Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Take screenshot with Behat/Mink after failed step
* 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);
$screenshot = $driver->wdSession->screenshot();
file_put_contents('/tmp/test.png', base64_decode($screenshot));
Copy link

AlexSkrypnyk commented May 26, 2017

Another dedicated extension with support for Mink (Goutte) and Selenium screenshots

Copy link

forceedge01 commented Sep 12, 2018

Another extension that gives more than just a screenshot with minimal setup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment