0

webstorm 8 で e2e を実行しようとしています。

WebStorm で角度分度器テストをデバッグする方法

以下は設定の詳細です -

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

以下は、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) {
}

};

そして、以下は仕様ファイルです -

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.");
        });
});
});

e2e テストケースを実行すると、ブラウザ ウィンドウが開きます。テストケースを実行しようとしますが、localhost 3000 が利用できないため失敗します。コンソールに次のエラー メッセージが表示されます -

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

構成のどこかで間違っているのでしょうか。誰でも助けることができますか?

4

1 に答える 1

2

同じエラーが発生しました。about:blankページに Cookie を追加しようとしました。しかし、それは不可能です。

問題は、Cookie を配置するために Web サイトにアクセスする必要があるということです。この種の回避策を試す必要があります。

util.browseTo(browser.baseUrl + "/en/", false);
util.setCookies([ { name:"zauth", value:"UNAUTHENTICATED_USER"}, { name:"ntID", value:"1"} ]);
util.browseTo(browser.baseUrl + "/en/", false);
于 2015-04-14T08:25:58.347 に答える