Last active
January 30, 2017 08:59
-
-
Save mustafaileri/2c85d83347933020695c075abac4b0bc to your computer and use it in GitHub Desktop.
save screenshot and document on behat test fail
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 | |
use Behat\MinkExtension\Context\MinkContext; | |
class BaseContext extends MinkContext | |
{ | |
... | |
... | |
/* | |
* @AfterStep | |
*/ | |
private function logErrors(AfterStepScope $event) | |
{ | |
$driver = $this->getSession()->getDriver(); | |
$screenshot = $driver->getWebDriverSession()->screenshot(); | |
$fileName = $file = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $event->getStep()->getText()); | |
$content = $this->getSession()->getPage()->getContent(); | |
if ($event->getTestResult()->getResultCode() == TestResult::FAILED) { | |
$this->saveDocument($fileName, $content); | |
$thi->saveScreenShot($fileName, $screenshot); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment