for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
use Behat\Behat\Hook\Scope\AfterStepScope;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\MinkExtension\Context\RawMinkContext;
use Behat\Testwork\Tester\Result\TestResult;
class ScreenShotAfterFailContext extends RawMinkContext
You can fix this by adding a namespace to your class:
namespace YourVendor; class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
{
/**
* @AfterStep
* @param AfterStepScope $scope
*/
public function takeScreenShotAfterFailedStep(AfterStepScope $scope)
if ($scope->getTestResult()->getResultCode() !== TestResult::FAILED) {
return;
}
$driver = $this->getSession()->getDriver();
if (!($driver instanceof Selenium2Driver)) {
$fileName = basename($scope->getFeature()->getFile()) . '_' . $scope->getStep()->getLine();
file_put_contents($this->getScreenShotDir() . $fileName . '.png', $this->getSession()->getDriver()->getScreenshot());
* @return string
private function getScreenShotDir()
return '/app/tests/app/var/screens/';
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.