diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
index 41e5b79..0598de3 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
@@ -79,4 +79,25 @@ protected function assertJsCondition($condition, $timeout = 1000, $message = '')
     $this->assertTrue($result, $message);
   }
 
+  /**
+   * Creates a screenshot.
+   *
+   * @param string $filename
+   *   The file name of the resulting screenshot. If using the default phantomjs
+   *   driver then this should be a JPG filename.
+   *
+   * @throws \Behat\Mink\Exception\UnsupportedDriverActionException
+   *   When operation not supported by the driver.
+   * @throws \Behat\Mink\Exception\DriverException
+   *   When the operation cannot be done
+   */
+  protected function createScreenshot($filename, $background = 'white') {
+    $driver = $this->getSession()->getDriver();
+    if (!empty($background)) {
+      $driver->executeScript("document.body.style.backgroundColor = '" . $background . "';");
+    }
+    $image = $driver->getScreenshot();
+    file_put_contents($filename, $image);
+  }
+
 }
