Behat Screenshot Extension
Behat extension and a step definition to create HTML and image screenshots on demand or test fail.
Features
- Make screenshot using
I save screenshot
orsave 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 inbehat.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
- Install Vagrant and VirtualBox and Composer.
- Install all dependencies:
composer install
- Provision local VM:
vagrant up
Running tests
vagrant ssh
scripts/selenium-install.sh
scripts/selenium-start.sh
composer test
Cleanup an environment
composer cleanup