Giter Site home page Giter Site logo

behat-extension's Introduction

BehatExtension

behat-extension's People

Contributors

aik099 avatar dependabot-preview[bot] avatar evangelion1204 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

evangelion1204

behat-extension's Issues

Composer.json adjustments

  1. change package name (the name key) to: qa-tools/behat-extension
  2. remove dependency to Mink ("behat/mink": "dev-master",), because MinkExtension already has it
  3. change qa-tools dependency ("aik099/qa-tools": "dev-master") to *@dev, because it's valid version format and it will automatically pickup release when it happens, while dev-master is fixed link to master branch
  4. not sure about "minimum-stability": "dev",, maybe it's not needed at all and better to specify @dev in required package version in project's own composer.json
  5. remove the repositories key, because qa-tools library is already published on packagist
  6. split autoload into autoload (for main code) and autoload-dev (for tests)
  7. fixed mixed use of tabs/spaces
  8. change dependency from aik099/qa-tools to qa-tools\qa-tools

FeatureContext steps to integrate with QA-Tools

I see following steps that might come in handy:

  1. I visit {PageClass} page - will:
    • create page object
    • assign created object to $this->page (of FeatureContext)
    • call $this->page->open()

Also we need to implement existing steps (from MinkContext) in a way, that they would access $this->page instead of using $this->session directly.

Change namespace

Currently the evangelion1204\QAToolsExtension namespace is used in PHP. This needs to be changed to QATools\BehatExtension to match with PSR-0.

Use MinkExtension

  1. put dependency to MinkExtension in composer.json
  2. move service definitions to services.xml
  3. put in the README.md in installation instructions, that MinkExtension needs to be configured upfront in behat.yml file (with a link to how to page on Behat website)

Keep base_url option within qa_tools extension options group even though we have same option in MinkExtension as well, because I see no way right now how to obtain it's value from within another extension.

Implement a basic user management

Many pages need user data e.g.login or register.

It should be possible to specify users in the behat.yml and use this saved data to fill forms or write custom steps:

default:
    QATools\BehatExtension:
      users:
        registered:
          firstname: michael
          lastname: geppert
public function fillLoginForm()
{
    $user = $this->getUser('registered');
    $this->loginForm->fill($user->getData());
}

public function enterFirstname()
{
    $user = $this->getUser('registered');
    $this->firstname->setValue($user->get('firstname'));
}

Normally only one user is active at time. Therefore extend the whole feature with an active user and specific steps to load him.

For example:

Scenario: A basic registration of an user
    Given "valid" as user

Stale Mink's Session usage in PageFactory

The PageFactory is created only once (when extension is initialized - https://github.com/qa-tools/behat-extension/blob/master/src/QATools/BehatExtension/QATools.php#L78) and therefore it uses Mink's session available at the moment.

Such setup however is can backfire when multiple sessions are configured in MinkExtension. The MinkExtension works like this:

  1. it analyzes scenarios and figures out which sessions needs to be created for them
  2. for example in most simple case there will be 2:
    • one using GoutteDriver for simple pages
    • one using Selenium for pages that require JavaScript interactions
  3. in before scenario hook the name of Mink's default session is set to one, that needs to be used by the scenario

To solve this we need to have separate page factory instance created per session and call ->getPageFactory() (instead of ->pageFactory) that will:

  1. look in ->pageFactories array (key is Mink's session name, value is page factory created for it)
  2. if no page factory found for that session name, then create and return it
  3. if page factory found then return it

Thanks to caching in ->pageFactories array we don't need to create new page factory for each scenario.

Move example to a seperate repo

To allow the user to get started we should create a behat-extension-skeleton or behat-extension-example to get started.
This could be a template to get started or to get an idea how to use the extension and QA-Tools in general.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.