protractor-cucumber-pages

0.0.2 • Public • Published

#protractor-cucumber-pages This package bundles generic steps and functions for use in e2e test. The functions use page objects which are project specific. The goal is to create building blocks that can be used inside cucumber steps. Thereby decreasing the complexity in steps and improving maintainability.

Run:

npm install --save-dev protractor-cucumber-pages

Add these lines to the top of your step definitions

var actor = require('protractor-cucumber-pages').core
actor.setSearchDir(__dirname + '/..')

If you want to make use of the generic steps add the path to your protractor.conf

cucumberOpts: {
    require: [paths.e2e + '/steps/**/*.js', require('protractor-cucumber-pages').steps]
}

###dependencies This requires protractor and the protractor-cucumber-framework. We would advise using gulp-protractor for easier webdriver management.

  1. gulp-protractor
  2. protractor-cucumber-framework

###Making a test The package expects a 'data' and 'pages' folder to be on the same level. Their parent should be set using core.setSearchDir() A good way to do this is to put all e2e related files in the same folder. This documentation assumes a structure that looks as follows.

project
+-- e2e
|    +- data
|    |   +- users.js
|    |   +- ...js
|    +- features
|    |   +- login.feature
|    |   +- ...feature
|    +- pages
|    |   +- login.js
|    |   +- home.js
|    |   +- ...js
|    +- steps
|        +- steps.js
|        +- ...js
+-- node_modules
+-- ...

Most functions in this package are called with a page name. This name must correspond to a filename in the folder pages. Pages bundle identifiers and functions specific to that page. An example page can be found here. any function that takes a page sets that page as the active page. This allows for code in steps to be independent of the pages themselves. for example:

this.When(/^authorize glowingbear\-js$/, function (callback) {
        actor.waitForPage('oauth').then( //wait for a page mathing the oauth.js page object.
        actor.page.authorizeButton.click().then( //because waitForPage has set the active page to 'oauth' the authorizeButton can be called on it.
        callback, callback), callback)
    });

Package Sidebar

Install

npm i protractor-cucumber-pages

Weekly Downloads

0

Version

0.0.2

License

ISC

Last publish

Collaborators

  • barteld.hyve