drevops / behat-relativity
此包已被弃用且不再维护。未建议替代包。
相对元素测试的Behat上下文。
0.4.0
2023-03-11 20:44 UTC
Requires
- behat/behat: ^3
- behat/mink: ^1
- behat/mink-browserkit-driver: ^1.3
- behat/mink-extension: ^2
- behat/mink-goutte-driver: ^1
- behat/mink-selenium2-driver: ^1
- symfony/config: ^3.0 || ^4.0 || ^5.0
This package is auto-updated.
Last update: 2023-11-11 23:12:16 UTC
README
相对元素测试的Behat上下文
这是什么?
此扩展允许测试页面中相对位置的视觉元素。此类测试非常简单易写,但它们可以捕捉到在现有项目开发功能时可能存在的问题。
测试www.google.com上元素的示例功能
Feature: Google example test Show how Behat Relativity can be used to test pages using google.com as an example. Background: Given I define components: | top navigation | #gb | | logo | #hplogo | | search | #lst-ib | | search button | .jsb input[name="btnK"] | | lucky button | .jsb input[name="btnI"] | | bottom navigation | .fbar | @javascript Scenario: Anonymous user visits google.com Given I am on "https://www.google.com" Then I see top navigation above logo, search, search button, lucky button and bottom navigation And I see logo above search, search button, lucky button and bottom navigation And I see search above search button, lucky button and bottom navigation And I see search button and lucky button above bottom navigation And I see search button to the left of lucky button
安装
composer require --dev drevops/behat-relativity
用法
示例 behat.yml
default: suites: default: contexts: - DrevOps\BehatRelativityExtension\Context\RelativityContext - FeatureContext extensions: DrevOps\BehatRelativityExtension: breakpoints: mobile: width: 320 height: 480 tablet: width: 768 height: 1024 desktop: width: 992 height: 1024 default: true desktop_large: width: 1200 height: 900 # Vertical offset - document will be scrolled to the element with this offset. # Useful when fixed elements may cover part of pages making it impossible to click on components. offset: 60 # List of site-wide components. components: 'page': "#page" 'main': "#main" 'top': "#top" 'bottom': "#bottom"
维护
本地开发设置
- 安装Docker。
- 如果使用M1:
cp default.docker-compose.override.yml docker-compose.override.yml
- 启动环境:
docker-compose up -d --build
。 - 安装依赖:
docker-compose exec phpserver composer install --ansi --no-suggest
。
代码检查
docker-compose exec phpserver vendor/bin/phpcs
运行测试
docker-compose exec phpserver vendor/bin/behat
启用Xdebug
XDEBUG_ENABLE=true docker-compose up -d phpserver
要禁用,运行
docker-compose up -d phpserver