dlabs/codeception-module-visualception
Composer 安装命令:
composer require dlabs/codeception-module-visualception
包简介
Visual regression tests for Codeception
README 文档
README
Visual regression tests integrated in Codeception.
This module can be used to compare the current representation of a website element with an expeted. It was written on the shoulders of codeception and integrates in a very easy way.
Example
How it works
VisualCeption uses a combination of the "make a screenshot" feature in webdriver, imagick and jquery to compare visual elements on a website. This comparison is done in five steps:
- Take a screenshot of the full page using webdriver.
- Calculate the position and size of the selected element using jquery.
- Crop the element out of the full screenshot using imagick.
- Compare the element with an older version of the screenshot that has been proofed as valid using imagick. If no previous image exists the current image will be used fur future comparions. As an effect of this approach the test has to be run twice before it works.
- If the deviation is too high throw an exception that is caught by Codeception.
Requirements
VisualCeption needs the following components to run:
- Codeception VisualCeption is a module for Codeception. It will need a running version of this tool.
- Imagick For comparing two images VisualCeption is using the imagick library for php. For more information visit php.net or the installation guide.
- WebDriver module This tool does only work with the webdriver module in Codeception the moment.
Installation
Bootstrap
Add the module to _bootstrap.php.
include_once "/path/to/module/VisualCeption.php";
Configuration
To use the VisualCeption module you have to configure it.
Example Configuration
modules: enabled: [WebDriver, VisualCeption] VisualCeption: referenceImageDir: /home/codeception/referenceImages/ # Path to the reference folder (optional, standard is # <datadir>/VisualCeption/) maximumDeviation: 5 # deviation in percent saveCurrentImageIfFailure: true # if true, VisualCeption saves the current # image in debug dir (default: false)
- referenceImageDir VisualCeption uses an "old" image for calculating the deviation. These images have to be stored in the system. This is the corresponding directory.
- maximumDeviation When comparing two images the deviation will be calculated. If this deviation is greater than the maximum deviation the test will fail.
- saveCurrentImageIfFailure When the test fails, the current image will be saved too, so it's easier to change the reference image with this one. The image will appear beside the compare image with the prefix "current."
Usage
VisualCeption is really easy to use. There are only two method that will be added to your WebGuy seeVisualChanges and dontSeeVisualChanges.
$I->seeVisualChanges( "uniqueIdentifier1", "elementId1" ); $I->dontSeeVisualChanges( "uniqueIdentifier2", "elementId2" ); $I->dontSeeVisualChanges( "uniqueIdentifier3", "elementId3" [, array("excludeElement1", "excludeElement2")] );
- uniqueIdentifier For comparing the images it is important to have a stable name. This is the corresponding name.
- elementId It is possible to only compare a special div container. The element id can be passed. You can use all locators that can be used in jQuery.
- excludeElements Optional parameter as string or an array of strings to exclude an element from the screenshot. Maybe there is an animated image in your test container, so you can ignore it. You can use all locators that can be used in jQuery.
Example Usage
$I->seeVisualChanges( "subNavigation", "#subNav" ); $I->dontSeeVisualChanges("content", "div.content", array("#intro"));
If you need more information about the test run please use the command line debug option (-d).
Restriction
VisualCeption uses the WebDriver module for making the screenshots. As a consequence we are not able to take screenshots via google chrome as the chromedriver does not allow full page screenshots.
dlabs/codeception-module-visualception 适用场景与选型建议
dlabs/codeception-module-visualception 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.25k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 01 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「codeception」 「imagick」 「selenium」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dlabs/codeception-module-visualception 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dlabs/codeception-module-visualception 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dlabs/codeception-module-visualception 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Connection 'Db' codeception module to 'Yii2' module database settings
Mailtrap module for Codeception
Stand-alone zoomify tile generator (format Zoomify) for use with OpenSeadragon, OpenLayers and various viewers.
Qase TMS Codeception reporter.
Selenium4 (WebDriver) driver for Mink framework
PHP Library for Selenium
统计信息
- 总下载量: 3.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-20