protected function WebDriverTestBase::createScreenshot in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::createScreenshot()
Creates a screenshot.
Parameters
string $filename: The file name of the resulting screenshot. If using the default phantomjs driver then this should be a JPG filename.
bool $set_background_color: (optional) By default this method will set the background color to white. Set to FALSE to override this behavior.
Throws
\Behat\Mink\Exception\UnsupportedDriverActionException When operation not supported by the driver.
\Behat\Mink\Exception\DriverException When the operation cannot be done.
1 call to WebDriverTestBase::createScreenshot()
- BrowserWithJavascriptTest::testCreateScreenshot in core/
tests/ Drupal/ FunctionalJavascriptTests/ BrowserWithJavascriptTest.php - Tests creating screenshots.
File
- core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php, line 204
Class
- WebDriverTestBase
- Runs a browser test using a driver that supports Javascript.
Namespace
Drupal\FunctionalJavascriptTestsCode
protected function createScreenshot($filename, $set_background_color = TRUE) {
$session = $this
->getSession();
if ($set_background_color) {
$session
->executeScript("document.body.style.backgroundColor = 'white';");
}
$image = $session
->getScreenshot();
file_put_contents($filename, $image);
}