承接 twistersfury/codeception-gherkin 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

twistersfury/codeception-gherkin

Composer 安装命令:

composer require twistersfury/codeception-gherkin

包简介

Page Object Helpers For Use In Codeception

README 文档

README

codecov pipelines

Codeception Gherkin Page Object Helper

This project provides the default steps for the various Codeception modules. It leverages the concept of Page Object Models to allow you to easily configure specific elements without the need to put these directly in your feature files.

Steps

Add any of the included traits to your Tester Class. After adding, you can use the Codeception codecept gherkin:steps to see all options.

Available Traits

  • TwistersFury\Codeception\Gherkin\Module\Db
  • TwistersFury\Codeception\Gherkin\Module\WebDriver
Example Steps:
haveInDatabase
Scenario: Do Something
  Given I have in database "table"
    | field1 | field2 | field3 |
    | value 1| value 2| value #|
seeInDatabase
Scenario: Do Something
  Then I see in database "table"
    | field1 | field2 | field3 |
    | value 1| value 2| value #|

PageObject

Register your pages in the Codeception bootstrap file. The page name will be the identifier used in your gherkin feature files. The class name is the class to initialize. As part of your Scenario, use the I am on page step to initialize the page.

Your Page Objects must extend TwistersFury\Codeception\Gherkin\Page\AbstractPage and define the methods:

  • getUrl the relative url of the page.
  • getElementMap The map of elements (See Below)
  • getDefaultElement The default HTML element.

Element Maps

Element maps are used to define elements on the page. The selection system uses the Codeception Location class to build the selector in the command. If an element is requested that doesn't exist, then the requested is returned. Possible values for a mapping are:

  • method Location Method To Use. Options are:
    • find - Default -
    • href
    • name
  • attributes - Defines Search In find
  • element - Defines HTML element in find and name. Defaults to getDefaultElement
  • url - Used in href method.
Examples

bootstrap.php

<?php

use My\Pages\AdminPage;
use My\Pages\Signup;
use My\Pages\ProfilePage
use TwistersFury\Codeception\Gherkin\Page\Factory;

Factory::reset();
Factory::getInstance()->addPages(
   [
        'admin'  => AdminPage::class,
        'signup' => SignUp::class
   ]
);

Factory::getInstance()->addPage(
    'profile', ProfilePage::class
);

tests/_support/Pages/Signup.php

<?php

namespace My\Pages;

class Signup {
    protected function getDefaultElement(): string 
    {
        return 'input';
    }
    
    public function getUrl(): string 
    {
        return '/signup';
    }

    protected function getElementMap(): array
    {
        return [
            'signup' => [
                'element' => 'button',
                'attributes' => [
                    'class' => 'signup'
                ]
            ],
            'forgot-my-pass' => [
                'method' => 'href',
                'url'    => '/forgot-pass/'
            ],
            'username' => [
                'method' => 'name'
            ]
        ]; 
    }
}

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固