2017 © Pedro Peláez
 

library behat-screenshot

Behat Context to capture screenshots from failed tests

image

integratedexperts/behat-screenshot

Behat Context to capture screenshots from failed tests

  • Friday, June 15, 2018
  • by alexdesignworks
  • Repository
  • 2 Watchers
  • 8 Stars
  • 32,383 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 18 Versions
  • 33 % Grown

The README.md

Behat Screenshot Extension

Behat extension and step definitions to create HTML and image screenshots on demand or when tests fail., (*1)

CircleCI Latest Stable Version Total Downloads License, (*2)

Features

  • Create a screenshot using I save screenshot or save screenshot step definition.
  • Create a screenshot when test fails.
  • Screenshot is saved as HTML page for Goutte driver.
  • Screenshot is saved as both HTML and PNG image for Selenium driver.
  • Screenshot directory can be specified through environment variable BEHAT_SCREENSHOT_DIR (useful for CI systems to override values in behat.yml).
  • Screenshots can be purged after every test run by setting purge: true (useful during test debugging) or setting environment variable BEHAT_SCREENSHOT_PURGE=1.

Installation

composer require --dev drevops/behat-screenshot

Usage

Example behat.yml with default parameters:, (*3)

default:
  suites:
    default:
      contexts:
        - DrevOps\BehatScreenshotExtension\Context\ScreenshotContext
        - FeatureContext
  extensions:
    DrevOps\BehatScreenshotExtension: ~

or with parameters:, (*4)

default:
  suites:
    default:
      contexts:
        - DrevOps\BehatScreenshotExtension\Context\ScreenshotContext
        - FeatureContext
  extensions:
    DrevOps\BehatScreenshotExtension:
      dir: '%paths.base%/screenshots'
      fail: true
      fail_prefix: 'failed_'
      purge: false

In your feature:, (*5)

  Given I am on "http://google.com"
  Then I save screenshot

You may optionally specify size of browser window in the screenshot step:, (*6)

  Then I save 1440 x 900 screenshot
  And I save 800 x 600 screenshot

Options

  • dir: path/to/dir (default %paths.base%/screenshots), (*7)

    Path to directory to save screenshots. Directory structure will be created if the directory does not exist., (*8)

  • fail: true or false (default true), (*9)

    Capture screenshots for failed tests., (*10)

  • fail_prefix: (default failed_), (*11)

    Prefix failed screenshots with fail_ string. Useful to distinguish failed and intended screenshots., (*12)

  • purge: true or false (default false), (*13)

    Remove all files from the screenshots directory on each test run. Useful during debugging of tests. Can be overridden with BEHAT_SCREENSHOT_PURGE environment variable set to 1 or true., (*14)

Maintenance

Local development setup

  1. Install Docker.
  2. Start environment: docker-compose up -d --build.
  3. Install dependencies: docker-compose exec phpserver composer install --ansi --no-suggest.

Lint code

docker-compose exec phpserver vendor/bin/phpcs

Run tests

docker-compose exec phpserver vendor/bin/behat

Enable Xdebug

XDEBUG_ENABLE=true docker-compose up -d phpserver

To disable, run, (*15)

docker-compose up -d phpserver

The Versions

15/06 2018
30/05 2018

dev-feature/remove-drupal-extension

dev-feature/remove-drupal-extension

Behat Context to capture screenshots from failed tests

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

by Alex Skrypnyk
by Alexander Sharkov

26/03 2018

dev-feature/fix-selenium-version

dev-feature/fix-selenium-version

Behat Context to capture screenshots from failed tests

  Sources   Download

GPL-2.0-or-later

The Requires

 

The Development Requires

by Alex Skrypnyk
by Alexander Sharkov

08/01 2018

dev-feature/driver-support

dev-feature/driver-support

Behat Context to capture screenshots from failed tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk
by Alexander Sharkov

07/08 2017

dev-revert-14-htmlpngoptions

dev-revert-14-htmlpngoptions

Behat Context to capture screenshots from failed tests

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

by Alex Skrypnyk
by Alexander Sharkov