drevops / behat-screenshot
Behat extension and step definitions to create HTML and image screenshots on demand or when tests fail
Installs: 752 115
Dependents: 10
Suggesters: 0
Security: 0
Stars: 22
Watchers: 5
Forks: 7
Open Issues: 5
Requires
- php: >=8.2
- behat/behat: ^3.13.0
- friends-of-behat/mink-extension: ^2.7
- symfony/finder: ^6.4 || ^7.0
- symfony/http-client: ^6.0 || ^7.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.8
- behat/mink-browserkit-driver: ^2.2
- dantleech/gherkin-lint: ^0.2.3
- dealerdirect/phpcodesniffer-composer-installer: ^1
- drevops/behat-phpserver: ^1.2
- drupal/coder: ^8.3
- dvdoug/behat-code-coverage: ^5.3
- ergebnis/composer-normalize: ^2.44
- escapestudios/symfony2-coding-standard: ^3
- lullabot/mink-selenium2-driver: ^1.7
- lullabot/php-webdriver: ^2.0.4
- mikey179/vfsstream: ^1.6
- opis/closure: ^3.6
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^11
- rector/rector: ^1.0.0
- symfony/process: ^6.4 || ^7.0
- dev-main
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
- 0.8.0
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.0
- 0.1.0
- dev-feature/increase-coverage
- dev-feature/strict-types
- dev-feature/add-php84
- dev-feature/added-gherkinlint
- dev-feature/remove-docker-compose
- dev-renovate/docker-setup-buildx-action-3.x
- dev-feature/move-ci-gha
- dev-feature/114-move-to-selenium
- dev-feature/add-composer-normaliser
- dev-renovate/drevops-ci-runner-24.x
This package is auto-updated.
Last update: 2024-11-04 12:15:13 UTC
README
Behat Screenshot Extension
Behat extension and step definitions to create HTML and image screenshots on demand or when tests fail.
Features
- Create a screenshot using
I save screenshot
orsave 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 inbehat.yml
). - Screenshots can be purged after every test run by setting
purge: true
( useful during test debugging) or setting environment variableBEHAT_SCREENSHOT_PURGE=1
.
Installation
composer require --dev drevops/behat-screenshot
Usage
Example behat.yml
with default parameters:
default: suites: default: contexts: - DrevOps\BehatScreenshotExtension\Context\ScreenshotContext - FeatureContext extensions: DrevOps\BehatScreenshotExtension: ~
or with parameters:
default: suites: default: contexts: - DrevOps\BehatScreenshotExtension\Context\ScreenshotContext - FeatureContext extensions: DrevOps\BehatScreenshotExtension: dir: '%paths.base%/screenshots' fail: true fail_prefix: 'failed_' purge: false filenamePattern: '{datetime:u}.{feature_file}.feature_{step_line}.{ext}' filenamePatternFailed: '{datetime:u}.{fail_prefix}{feature_file}.feature_{step_line}.{ext}'
In your feature:
Given I am on "http://google.com"
Then I save screenshot
You may optionally specify size of browser window in the screenshot step:
Then I save 1440 x 900 screenshot
And I save 800 x 600 screenshot
Options
Supported tokens
Maintenance
Local development setup
Install dependencies.
composer install
Start Chrome container.
docker run -d -p 4444:4444 selenium/standalone-chromium:130.0
Lint code
composer lint
Fix code style
composer lint-fix
Run tests
composer test-unit # Run unit tests. composer test-bdd # Run BDD tests.
Repository created using https://getscaffold.dev/ project scaffold template