src/DrupalExtension/Context/ScreenShotContext.php
public function screenshotForPhpNotices(AfterStepScope $event) {
    $environment = $event->getEnvironment();
    // Make sure the environment has the MessageContext.
    $class = 'Drupal\DrupalExtension\Context\MessageContext';
    if ($environment instanceof InitializedContextEnvironment && $environment->hasContextClass($class)) {
      /** @var \Drupal\DrupalExtension\Context\MessageContext $context */
      $context = $environment->getContext($class);
      // Only check if the session is started.
      try {
        if ($context->getMink()->isSessionStarted()) {
          try {
            $context->assertNotWarningMessage('Notice:');
          }
          catch (\Exception $e) {
            // Use the step test in the filename.
            $step = $event->getStep();
            if (function_exists('transliteration_clean_filename')) {
              $file_name = transliteration_clean_filename($step->getKeyword() . '_' . $step->getText());
            }
            else {
              $file_name = str_replace(' ', '_', $step->getKeyword() . '_' . $step->getText());
              $file_name = preg_replace('![^0-9A-Za-z_.-]!', '', $file_name);
            }
            $file_name = substr($file_name, 0, 30);
            $file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat-notice__' . $file_name;
            $message = "Screenshot for behat notice in step created in @file_name";
            $this->createScreenshot($file_name, $message);
            // We don't throw $e any more because we don't fail on the notice.
          }
        }
      }
      catch (DriverException $driver_exception) {

      }
    }
  }
public function screenshotForPhpNotices(AfterStepScope $event) {
    $environment = $event->getEnvironment();
    // Make sure the environment has the MessageContext.
    $class = 'Drupal\DrupalExtension\Context\MessageContext';
    if ($environment instanceof InitializedContextEnvironment && $environment->hasContextClass($class)) {
      /** @var \Drupal\DrupalExtension\Context\MessageContext $context */
      $context = $environment->getContext($class);
      // Only check if the session is started.
      try {
        if ($context->getMink()->isSessionStarted()) {
          try {
            $context->assertNotWarningMessage('Notice:');
          }
          catch (\Exception $e) {
            // Use the step test in the filename.
            $step = $event->getStep();
            if (function_exists('transliteration_clean_filename')) {
              $file_name = transliteration_clean_filename($step->getKeyword() . '_' . $step->getText());
            }
            else {
              $file_name = str_replace(' ', '_', $step->getKeyword() . '_' . $step->getText());
              $file_name = preg_replace('![^0-9A-Za-z_.-]!', '', $file_name);
            }
            $file_name = substr($file_name, 0, 30);
            $file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat-notice__' . $file_name;
            $message = "Screenshot for behat notice in step created in @file_name";
            $this->createScreenshot($file_name, $message);
            // We don't throw $e any more because we don't fail on the notice.
          }
        }
      }
      catch (DriverException $driver_exception) {

      }
    }
  }
public function screenshotForPhpNotices ( AfterStepScope $ event ) { $ environment = $ event -> getEnvironment ( ) ; // Make sure the environment has the MessageContext. $ class = 'Drupal\DrupalExtension\Context\MessageContext' ; if ( $ environment instanceof InitializedContextEnvironment && $ environment -> hasContextClass ( $ class ) ) { /** @var \Drupal\DrupalExtension\Context\MessageContext $context */ $ context = $ environment -> getContext ( $ class ) ; // Only check if the session is started. try { if ( $ context -> getMink ( ) -> isSessionStarted ( ) ) { try { $ context -> assertNotWarningMessage ( 'Notice:' ) ; } catch ( \ Exception $ e ) { // Use the step test in the filename. $ step = $ event -> getStep ( ) ; if ( function_exists ( 'transliteration_clean_filename' ) ) { $ file_name = transliteration_clean_filename ( $ step -> getKeyword ( ) . '_' . $ step -> getText ( ) ) ; } else { $ file_name = str_replace ( ' ' , '_' , $ step -> getKeyword ( ) . '_' . $ step -> getText ( ) ) ; $ file_name = preg_replace ( '![^0-9A-Za-z_.-]!' , '' , $ file_name ) ; } $ file_name = substr ( $ file_name , 0 , 30 ) ; $ file_name = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR . 'behat-notice__' . $ file_name ; $ message = "Screenshot for behat notice in step created in @file_name" ; $ this -> createScreenshot ( $ file_name , $ message ) ; // We don't throw $e any more because we don't fail on the notice. } } } catch ( DriverException $ driver_exception ) { } } }
Make sure there is no PHP notice on the screen during tests.

@AfterStep
Make sure there is no PHP notice on the screen during tests .