Skip to content
Behat context to make screenshots
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
scripts
src/IntegratedExperts/BehatScreenshotExtension
tests/behat
.gitignore
README.md
behat.yml
behat.yml.dist
composer.json
docker-compose.yml
phpcs.xml.dist

README.md

Behat Screenshot Extension

Behat extension and a step definition to create HTML and image screenshots on demand or test fail.

CircleCI Latest Stable Version Total Downloads License

Features

  • Make screenshot using I save screenshot or save screenshot step definition.
  • Make screenshot when test fails.
  • Screnshot is saved as HTML page for Goutte driver.
  • Screnshot 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.

Installation

composer require integratedexperts/behat-screenshot

Usage

Example behat.yml:

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

In your feature:

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

Options

  • dir:path/to/dir

    Path to directory to save scereenshots. Directory structure will be created if the directory does not exist.

  • fail: true/false

    Prefix failed screenshots with 'fail_' string. Useful to distinguish failed and intended screenshots.

  • purge: false/false

    Remove all files from the screenshots directory on each test run. Useful during debugging of tests.

Local development

  1. Install Docker.
  2. Run composer docker:start.

Running tests

composer test

Cleanup an environment

composer cleanup
You can’t perform that action at this time.