public function afterStep(StepEvent $event) {
        $color = $this->getResultColorCode($event->getResult());
        $capture = $this->captureAll || $color == 'failed';
        if ($capture) {
            try {
                $screenshot = $this->driver->getScreenshot();
                if ($screenshot) {
                    $date = new \DateTime('now');
                    $fileName = $this->screenShotPrefix . $date->format('Y-m-d H.i.s') . '.png';
                    $file = $this->screenShotDirectory . DIRECTORY_SEPARATOR . $fileName;
                    file_put_contents($file, $screenshot);
                    $this->screenShotMarkup .= '<div class="screenshot">';
                    $this->screenShotMarkup .= sprintf('<a href="#" class="screenshot-toggler">Toggle screenshot for ' . $event->getStep()->getText() . '</a>');
                    $this->screenShotMarkup .= sprintf('<img src="%s" />', $fileName);
                    $this->screenShotMarkup .= '</div>';
                }
            } catch (\Exception $e) {
                $this->screenShotMarkup .= '<div class="screenshot">';
                $this->screenShotMarkup .= sprintf('<em>Error while taking screenshot for ' . $event->getStep()->getText() . ' : %s</em>', htmlspecialchars($e->getMessage()));
                $this->screenShotMarkup .= '</div>';
            }
        }
        if ($this->inBackground && $this->isBackgroundPrinted) {
            return;
        }

        if (!$this->inBackground && $this->inOutlineExample) {
            $this->delayedStepEvents[] = $event;

            return;
        }

        $this->printStep(
            $event->getStep(),
            $event->getResult(),
            $event->getDefinition(),
            $event->getSnippet(),
            $event->getException()
        );
        $this->writeln($this->screenShotMarkup);
        $this->screenShotMarkup = '';

    }
public function afterStep(StepEvent $event) {
        $color = $this->getResultColorCode($event->getResult());
        $capture = $this->captureAll || $color == 'failed';
        if ($capture) {
            try {
                $screenshot = $this->driver->getScreenshot();
                if ($screenshot) {
                    $date = new \DateTime('now');
                    $fileName = $this->screenShotPrefix . $date->format('Y-m-d H.i.s') . '.png';
                    $file = $this->screenShotDirectory . DIRECTORY_SEPARATOR . $fileName;
                    file_put_contents($file, $screenshot);
                    $this->screenShotMarkup .= '<div class="screenshot">';
                    $this->screenShotMarkup .= sprintf('<a href="#" class="screenshot-toggler">Toggle screenshot for ' . $event->getStep()->getText() . '</a>');
                    $this->screenShotMarkup .= sprintf('<img src="%s" />', $fileName);
                    $this->screenShotMarkup .= '</div>';
                }
            } catch (\Exception $e) {
                $this->screenShotMarkup .= '<div class="screenshot">';
                $this->screenShotMarkup .= sprintf('<em>Error while taking screenshot for ' . $event->getStep()->getText() . ' : %s</em>', htmlspecialchars($e->getMessage()));
                $this->screenShotMarkup .= '</div>';
            }
        }
        if ($this->inBackground && $this->isBackgroundPrinted) {
            return;
        }

        if (!$this->inBackground && $this->inOutlineExample) {
            $this->delayedStepEvents[] = $event;

            return;
        }

        $this->printStep(
            $event->getStep(),
            $event->getResult(),
            $event->getDefinition(),
            $event->getSnippet(),
            $event->getException()
        );
        $this->writeln($this->screenShotMarkup);
        $this->screenShotMarkup = '';

    }
public function afterStep ( StepEvent $ event ) { $ color = $ this -> getResultColorCode ( $ event -> getResult ( ) ) ; $ capture = $ this -> captureAll || $ color == 'failed' ; if ( $ capture ) { try { $ screenshot = $ this -> driver -> getScreenshot ( ) ; if ( $ screenshot ) { $ date = new \ DateTime ( 'now' ) ; $ fileName = $ this -> screenShotPrefix . $ date -> format ( 'Y-m-d H.i.s' ) . '.png' ; $ file = $ this -> screenShotDirectory . DIRECTORY_SEPARATOR . $ fileName ; file_put_contents ( $ file , $ screenshot ) ; $ this -> screenShotMarkup .= '<div class="screenshot">' ; $ this -> screenShotMarkup .= sprintf ( '<a href="#" class="screenshot-toggler">Toggle screenshot for ' . $ event -> getStep ( ) -> getText ( ) . '</a>' ) ; $ this -> screenShotMarkup .= sprintf ( '<img src="%s" />' , $ fileName ) ; $ this -> screenShotMarkup .= '</div>' ; } } catch ( \ Exception $ e ) { $ this -> screenShotMarkup .= '<div class="screenshot">' ; $ this -> screenShotMarkup .= sprintf ( '<em>Error while taking screenshot for ' . $ event -> getStep ( ) -> getText ( ) . ' : %s</em>' , htmlspecialchars ( $ e -> getMessage ( ) ) ) ; $ this -> screenShotMarkup .= '</div>' ; } } if ( $ this -> inBackground && $ this -> isBackgroundPrinted ) { return ; } if ( ! $ this -> inBackground && $ this -> inOutlineExample ) { $ this -> delayedStepEvents [ ] = $ event ; return ; } $ this -> printStep ( $ event -> getStep ( ) , $ event -> getResult ( ) , $ event -> getDefinition ( ) , $ event -> getSnippet ( ) , $ event -> getException ( ) ) ; $ this -> writeln ( $ this -> screenShotMarkup ) ; $ this -> screenShotMarkup = '' ; }
Listens to "step.after" event.

@param StepEvent $event

@uses printStep()
Listens to step . after event .