-
-
Save Dustin4444/9c754d8e973f186ad84f27d68cdd9f1d to your computer and use it in GitHub Desktop.
Take screenshot with Behat/Mink after failed step
This file contains hidden or 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
| /** | |
| * 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); | |
| return; | |
| } | |
| $screenshot = $driver->wdSession->screenshot(); | |
| file_put_contents('/tmp/test.png', base64_decode($screenshot)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment