0

Я пытаюсь выполнить E2E в WebStorm 8. Я настроил Node.js в соответствии с инструкциями, приведенными вТранспортир: Невозможно выполнить E2e testcases [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."); 
     }); 
}); 
}); 

Когда я бегу e2e TestCase я вижу окно браузера с открытым. Он пытается запустить тестовый файл, но он не работает, потому что 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

ответ

2

У меня была такая же ошибка. Я пытаюсь добавить файл cookie на о: blank странице. Но это невозможно.

Дело в том, что вы должны быть на веб-сайте, чтобы положить куки. Вы должны попробовать этот вид обходного:

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