src/DrupalExtension/Context/ScreenShotContext.php
public function createScreenshot($file_name, $message, $ext = TRUE) {
    if ($this->getSession()->getDriver() instanceof Selenium2Driver) {
      if ($ext) {
        $file_name .= '.png';
      }
      $screenshot = $this->getSession()->getDriver()->getScreenshot();
      file_put_contents($file_name, $screenshot);
    }
    else {
      if ($ext) {
        $file_name .= '.html';
      }
      $html_data = $this->getSession()->getDriver()->getContent();
      file_put_contents($file_name, $html_data);
    }
    if ($message) {
      print strtr($message, ['@file_name' => $file_name]);
    }
  }
public function createScreenshot($file_name, $message, $ext = TRUE) {
    if ($this->getSession()->getDriver() instanceof Selenium2Driver) {
      if ($ext) {
        $file_name .= '.png';
      }
      $screenshot = $this->getSession()->getDriver()->getScreenshot();
      file_put_contents($file_name, $screenshot);
    }
    else {
      if ($ext) {
        $file_name .= '.html';
      }
      $html_data = $this->getSession()->getDriver()->getContent();
      file_put_contents($file_name, $html_data);
    }
    if ($message) {
      print strtr($message, ['@file_name' => $file_name]);
    }
  }
public function createScreenshot ( $ file_name , $ message , $ ext = TRUE ) { if ( $ this -> getSession ( ) -> getDriver ( ) instanceof Selenium2Driver ) { if ( $ ext ) { $ file_name .= '.png' ; } $ screenshot = $ this -> getSession ( ) -> getDriver ( ) -> getScreenshot ( ) ; file_put_contents ( $ file_name , $ screenshot ) ; } else { if ( $ ext ) { $ file_name .= '.html' ; } $ html_data = $ this -> getSession ( ) -> getDriver ( ) -> getContent ( ) ; file_put_contents ( $ file_name , $ html_data ) ; } if ( $ message ) { print strtr ( $ message , [ '@file_name' => $ file_name ] ) ; } }
Create a screenshot or save the html.

@param string $file_name
The filename of the screenshot (complete).
@param string $message
The message to be printed. @file_name will be replaced with $file name.
@param bool|true $ext
Whether to add .png or .html to the name of the screenshot.
Create a screenshot or save the html .