提问人:user1305398 提问时间:10/12/2014 最后编辑:Communityuser1305398 更新时间:4/14/2015 访问量:1258
量角器:无法在 Webstorm 8 中执行 e2e 测试用例 [http://localhost:3000 不可用]
Protractor: Unable to execute e2e testcases [http://localhost:3000 is not available] in Webstorm 8
问:
我正在尝试在 webstorm 2 中执行 e8e。我已经.js按照
以下是配置详细信息 -
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.
我在配置中的任何位置都出错了吗?谁能帮忙?
答:
2赞
Eskignax
4/14/2015
#1
我也有同样的错误。 我尝试在about:blank页面上添加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);
评论