0

I am trying to execute e2e in webstorm 8. I have configured node.js as per the instructions given at

How to debug angular protractor tests in WebStorm

Following are the configuration details -

Node interpreter: C:\Program Files\nodejs\node.exe
Working directory: E:\_work\Angular
Javascript file: node_modules\grunt-protractor-runner\node_modules\protractor\lib\cli.js
Application parameters: E:\_work\Angular\test\protractor.e2e.conf.js

Following are the contents of protractor.e2e.conf.js

 // A reference configuration file.
exports.config = {

seleniumServerJar: '../node_modules/grunt-protractor-coverage/node_modules/protractor/selenium/selenium-server-standalone-2.40.0.jar',

seleniumPort: 4443,

chromeDriver: '../node_modules/grunt-protractor-coverage/node_modules/protractor/selenium/chromedriver',

chromeOnly: false,

seleniumArgs: [],

// The address of a running selenium server. If specified, Protractor will
// connect to an already running instance of selenium. This usually looks like
//seleniumAddress: 'http://localhost:4444/wd/hub',
seleniumAddress: null,


specs: [
    './e2e/**/*.spec.js'
],

exclude: [],

// ----- Capabilities to be passed to the webdriver instance ----
//
// For a list of available capabilities, see
// https://code.google.com/p/selenium/wiki/DesiredCapabilities
// and
// https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js
// Additionally, you may specify count, shardTestFiles, and maxInstances.
capabilities: {
    browserName: 'chrome',

    // Number of times to run this set of capabilities (in parallel, unless
    // limited by maxSessions). Default is 1.
    count: 1,

    // If this is set to be true, specs will be sharded by file (i.e. all
    // files to be run by this set of capabilities will run in parallel).
    // Default is false.
    shardTestFiles: false,

    // Maximum number of browser instances that can run in parallel for this
    // set of capabilities. This is only needed if shardTestFiles is true.
    // Default is 1.
    maxInstances: 1
},

// If you would like to run more than one instance of webdriver on the same
// tests, use multiCapabilities, which takes an array of capabilities.
// If this is specified, capabilities will be ignored.
multiCapabilities: [],

// ----- More information for your tests ----
//
// A base URL for your application under test. Calls to protractor.get()
// with relative paths will be prepended with this.
baseUrl: 'http://localhost:3000',

// Selector for the element housing the angular app - this defaults to
// body, but is necessary if ng-app is on a descendant of <body>
rootElement: 'html',
// ----- The cleanup step -----
//
// A callback function called once the tests have finished running and
// the webdriver instance has been shut down. It is passed the exit code
// (0 if the tests passed or 1 if not). This is called once per capability.
onCleanUp: function (exitCode) {
}

};

And following is the spec file -

var util = require("../utils/util.js")(browser);

describe("Test: ", function() {
it("should redirect non authenticated users to the login page", function() {
    util.setCookies([ { name:"zauth", value:"UNAUTHENTICATED_USER"}, { name:"ntID", value:"1"} ]);
    util.browseTo(browser.baseUrl + "/en/", false);

    browser.driver.getCurrentUrl().
        then(function(url) {
            expect(url).toBe(browser.baseUrl + "/servlet/LoginServlet?action=logout&msg=logout.");
        });
});
});

When I run the e2e testcase I see the browser window open. It tries to run the testcase but it fails because localhost 3000 is not available. In the console I get the following error message -

  UnknownError: <unknown>: Failed to set the 'cookie' property on 'Document': Cookies are disabled inside 'data:' URLs.

Am I going wrong anywhere in the configuration. Can anyone help?

Community
  • 1
  • 1
user1305398
  • 3,550
  • 5
  • 26
  • 42
  • not sure but for me was very usefull this tut : http://programmerbuddy.blogspot.ro/2014/03/full-automation-of-protractor-e2e-tests.html and http://programmerbuddy.blogspot.ro/2014/03/full-automation-of-protractor-e2e-tests_22.html – Teodor Oct 21 '14 at 14:10

1 Answers1

2

I had the same error. I try to add the cookie on the about:blank page. But it's no possible.

The things is that you have to be on the website to put the cookie. You should try this kind of workaround :

util.browseTo(browser.baseUrl + "/en/", false);
util.setCookies([ { name:"zauth", value:"UNAUTHENTICATED_USER"}, { name:"ntID", value:"1"} ]);
util.browseTo(browser.baseUrl + "/en/", false);
Eskignax
  • 584
  • 3
  • 8