0

我試圖執行在webstorm 8. E2E我已經配置的node.js按照在量角器:無法執行E2E測試用例[HTTP://本地主機:3000不可]在Webstorm 8

給出的說明

How to debug angular protractor tests in 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."); 
     }); 
}); 
}); 

當我運行的端到端測試用例我看到瀏覽器窗口中打開。它試圖運行測試用例,但由於localhost 3000不可用而失敗。 在控制檯中我得到了以下錯誤消息 -

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

我該怎麼在配置錯誤的任何地方。誰能幫忙?

+0

不知道,但對我來說是非常有用的這個嘖嘖:http://programmerbuddy.blogspot.ro/2014/03/full-automation-of-protractor-e2e- tests.html和http://programmerbuddy.blogspot.ro/2014/03/full-automation-of-protractor-e2e-tests_22.html – Teodor 2014-10-21 14:10:12

回答

2

我有同樣的錯誤。 我嘗試在上添加關於:空白頁面的cookie。但這是不可能的。

事情是,你必須在網站上放置cookie。 你應該嘗試這種解決辦法的:

util.browseTo(browser.baseUrl + "/en/", false); 
util.setCookies([ { name:"zauth", value:"UNAUTHENTICATED_USER"}, { name:"ntID", value:"1"} ]); 
util.browseTo(browser.baseUrl + "/en/", false); 
相關問題