Skip to content

Instantly share code, notes, and snippets.

@fadonascimento
Created December 11, 2016 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fadonascimento/39d338c011ebf2911dc12ca5d6b94530 to your computer and use it in GitHub Desktop.
Save fadonascimento/39d338c011ebf2911dc12ca5d6b94530 to your computer and use it in GitHub Desktop.
Take screenshot with behat
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Behat\Hook\Scope\AfterStepScope;
/**
* @When /^I take a screnshoot "([^"]*)"$/
*/
public function takeScreenShotAfterFailedStep($filePath)
{
$driver = $this->getSession()->getDriver();
if (!($driver instanceof Selenium2Driver)) {
return;
}
file_put_contents($filePath, $this->getSession()->getDriver()->getScreenshot());
}
I take a screnshoot "path/filename.png"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment