JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 22
  • Score
    100M100P100Q56608F
  • License MIT

Cucumber steps (step definitions) written with Protractor for e2e tests

Package Exports

  • protractor-cucumber-steps

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (protractor-cucumber-steps) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

protractor-cucumber-steps

Build Status npm version NPM License

Cucumber steps (step definitions) written with Protractor for end-to-end tests

Supported versions

Node.js:

  • 6.x
  • 7.x

Protractor:

  • 4.x
  • 5.x

Installation

To install this package and add it to your package.json just run:

npm install protractor-cucumber-steps --save-dev

Importing and enabling

This package is used as plugin with protractor and protractor-cucumber-framework. It is quite simple to use - to get access to all Cucumber steps defined in this plugin just:

  • add the path to protractor-cucumber-steps (in cucumberOpts -> require);
  • add the path to your page object file (in params -> pageObjects) inside protractor.config.js.

Here is a short config example:

exports.config = {
    // set to "custom" instead of cucumber
    framework: 'custom',

    // path relative to the current config file
    frameworkPath: require.resolve('protractor-cucumber-framework'),

    // require feature files
    specs: [
        'path/to/feature/files/**/*.feature' // accepts a glob
    ],

    cucumberOpts: {
        // require step definitions
        require: [
            './node_modules/.bin/protractor-cucumber-steps/index.js', // path to protractor-cucumber-steps
            'path/to/your/step/definitions/**/*.steps.js' // accepts a glob
        ]
    },

    // Custom parameters can be specified here
    params: {
        pageObjects: require('./page_objects/index.js') // path to your page object file
    }
};

You can also see the example of protractor.config.js

List of predefined steps

You can see the example of how to use predefined steps in test.feature

When steps

  • I go to URL "([^"]*)" - Open a site (by its URL provided in "") in the current browser window/tab
  • I go to "([^"]*)"."([^"]*)" - Open a site (by its URL provided in "page"."object") in the current browser window/tab
  • I reload the page - Reload current page
  • I click "([^"]*)"."([^"]*) - Click on any element (provided in "page"."object")
  • I wait and click "([^"]*)"."([^"]*)" - Wait for 300 ms and click on any element (provided in "page"."object")
  • I click "([^"]*)"."([^"]*)" if present - Click on any element (provided in "page"."object") only if it is present on the page
  • I wait for (\d+) ms - Wait for provided amount of time (in milliseconds). Maximum value is 300000 (equals to 5 minutes)
  • I wait for "([^"]*)"."([^"]*)" to be present - Wait for element (provided in "page"."object") to be present on the page (by default waits for 5000 ms, this time can be changed by specifying params.customTimeout inside protractor.config.js - see the [example|https://github.com/Marketionist/protractor-cucumber-steps/blob/master/tests/protractor.conf.js])
  • I type "([^"]*)" in the "([^"]*)"."([^"]*)" - Type any text (provided in "" as a string) in the input field (provided in "page"."object")
  • I type "([^"]*)"."([^"]*)" in the "([^"]*)"."([^"]*)" - Type any text (provided in "page1"."object1") in the input field (provided in "page2"."object2")

Then steps

  • the title should be "([^"]*)" - Validate that title of the current browser window/tab equals to the text (provided in "" as a string)
  • "([^"]*)"."([^"]*)" should be present - Validate that element (provided in "page"."object") is present on the page
  • "([^"]*)"."([^"]*)" should not be present - Validate that element (provided in "page"."object") is not present on the page
  • "([^"]*)"."([^"]*)" text should be "([^"]*)" - Validate that text of the element (provided in "page"."object") equals to the text (provided in "" as a string)
  • "([^"]*)"."([^"]*)" text should be "([^"]*)"."([^"]*)" - Validate that text of the element (provided in "page1"."object1") equals to the text (provided in "page2"."object2")
  • "([^"]*)"."([^"]*)" text should contain "([^"]*)" - Validate that text of the element (provided in "page"."object") contains the text (provided in "" as a string)
  • "([^"]*)"."([^"]*)" text should contain "([^"]*)"."([^"]*)" - Validate that text of the element (provided in "page1"."object1") contains the text (provided in "page2"."object2")
  • URL should be "([^"]*)" - Validate that URL of the current page equals to the text (provided in "" as a string)
  • URL should match \/([^"]*)\/ - Validate that URL of the current page matches the regular expression pattern (provided inside // like: /pattern/)
  • URL should contain "([^"]*)" - Validate that URL of the current page contains the text (provided in "" as a string)
  • the file "([^"]*)" is empty - Validate that the file (with name provided in "" as a string) is empty

Contributing

You are welcome to contribute - please see CONTRIBUTING.md to help you get started

Thanks

If this plugin was helpful for you, please give it a ★ Star on Github and npm