Created
June 2, 2015 17:38
-
-
Save jmauerhan/19a13e9c277e7242a25f to your computer and use it in GitHub Desktop.
An AfterScenario function for behat that takes and saves a screenshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @AfterScenario */ | |
public function after($event) | |
{ | |
if($event->getResult() == Event\StepEvent::FAILED) | |
{ | |
$imagePathPrefix = 'http://mysite.local'; | |
errorImagesDir = '/'; | |
$imageData = $this->getSession()->getDriver()->getScreenshot(); | |
$imagePath = $errorImagesDir . time() . '.png'; | |
file_put_contents($imagePath, $imageData); | |
$imageUrl = $imagePathPrefix . $imagePath; | |
$this->printDebug($imageUrl . PHP_EOL); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment