Skip to content
cedric lombardot edited this page May 31, 2016 · 6 revisions

Write your tests in test/e2e/**/ folders

Eg sample.feature

Feature: As a good developer i want to test my angular app in BDD

Scenario: I want to see the contact page
    Given I am on the "Login"
    When I fill "email" field with "[email protected]"
    And I fill "password" field with "donkeycode"
    And I click on the button "Login"
    Then I should be redirected on "Home"

**Note the sentences Given I am on the and Then I should be redirected will go / check url and if success change the context to the current page. So your test SHOULD start by a Given I am on **

Declare your pages structures in support/pages/**/ folders

Eg Login.js

Note the name of the file will be the name used in sentences

'use strict';

module.exports = function Login() {
    return {
        url: "login",
        getButtonByName: function (buttonName) {
            var mapping = {
                "Login": ".btn"
            };

            return mapping[buttonName];
        },
        getFieldByName: function (name) {
            var mapping = {
                "email": 'input[ng-model="login.mail"]',
                "password": 'input[ng-model="login.password"]',
            };

            return mapping[name];
        }
    };
}();

To run your test in dev mode:

./node_modules/protractor/bin/protractor protractor.conf.js --cucumberOpts.env=dev --cucumberOpts.angularMode=html5mode

Or

./node_modules/angular-protractor-cucumber/node_modules/protractor/bin/protractor --cucumberOpts.env=dev --cucumberOpts.angularMode=html5mode
Clone this wiki locally