bladeaweb / behat-screenshot

Behat context to make screenshots

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 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

Local development

Preparing local environment

  1. Install Vagrant and VirtualBox and Composer.
  2. Install all dependencies: composer install
  3. Provision local VM: vagrant up

Running tests

vagrant ssh
scripts/selenium-install.sh
scripts/selenium-start.sh
composer test

Cleanup an environment

composer cleanup

About

Behat context to make screenshots


Languages

Language:PHP 70.5%Language:Shell 24.6%Language:Gherkin 4.2%Language:HTML 0.6%