量角器:ng e2e:如何解决“错误:连接ETIMEDOUT"问题.错误? [英] Protractor: ng e2e: How to solve the "Error: connect ETIMEDOUT" error?

查看:79
本文介绍了量角器:ng e2e:如何解决“错误:连接ETIMEDOUT"问题.错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了英雄之旅 Angular教程应用程序.之后,我为组件编写了测试.应用程序和组件测试运行良好.现在,我想与Protractor一起开发E2E测试,但我无法让它们运行.

I developed the Tour of Heroes Angular tutorial application. After that I wrote tests for the components. The application and the component tests are doing fine. Now I wanted to develop E2E tests with Protractor and I can't get them running.

每次我在命令行上运行ng e2e时,都会得到以下输出:

Every time I run ng e2e on the command line, I get the following output:

$ ng e2e
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152/ **
Date: 2017-09-26T14:51:12.962Z
Hash: ef70100f8d31703b6b85
Time: 8035ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 3.16 MB {inline} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 209 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.6 kB {inline} [initial] [rendered]
(node:13556) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

webpack: Compiled successfully.
events.js:182
  throw er; // Unhandled 'error' event
  ^

Error: connect ETIMEDOUT 216.58.205.112:443
    at Object._errnoException (util.js:1026:11)
    at _exceptionWithHostPort (util.js:1049:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)

一些有关我的设置的有用信息:

Some hopefully useful information regarding my setup:

  • 该项目是使用Anguliar CLI创建的
  • 量角器已在全局和本地安装
  • 以下文件位于node_modules/webdriver-manager/selenium目录中:chromedriver_2.32.exe, chromedriver_2.32.zip, chrome-response.xml, gecko-response.json, selenium-server-standalone-3.5.3.jar, standalone-response.xml
  • 我使用代理属性运行webdriver-manager update
  • 如果我在运行中的Selenium Grid或directConnect: true配置中运行命令,则没有区别
  • 在浏览器中设置了Chrome(Firefox也有同样的问题)
  • 操作系统:Windows 10,浏览器:Chrome 51.0.2704.106 m(64位)
  • The project was created with the Anguliar CLI
  • Protractor was installed globally and local
  • The following files are in the node_modules/webdriver-manager/selenium directory: chromedriver_2.32.exe, chromedriver_2.32.zip, chrome-response.xml, gecko-response.json, selenium-server-standalone-3.5.3.jar, standalone-response.xml
  • I run webdriver-manager update with a proxy property
  • It makes no difference if I run the command with a running Selenium Grid or with the directConnect: true configuration
  • As browser is set Chrome (Firefox has the same problem)
  • OS: Windows 10, Browser: Chrome 51.0.2704.106 m (64-bit)

protractor.conf.js文件:

// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'chrome'
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  /*seleniumAddress: 'http://localhost:4444/wd/hub',*/
  directConnect: true,
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  onPrepare() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }
};

package.json文件:

{
  "name": "angular-tour-of-heroes",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "core-js": "^2.4.1",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.4.2",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "angular-in-memory-web-api": "^0.4.6",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-firefox-launcher": "^1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

这是我第一次尝试使用Angular和Protractor开发E2E测试.

It's the first time that I try to develop E2E tests with Angular and Protractor.

谢谢您的支持!

更新

我不知道如果运行ng e2e将会执行webdriver-manager update.所以我尝试了ng e2e --no-webdriver-update,并且使用此命令,上面的错误不再出现.我认为出现此错误是因为未设置代理,并且webdriver-manager无法运行更新.

I didn't know that webdriver-manager update will be executed if I run ng e2e. So I tried ng e2e --no-webdriver-update and with this command the error above is not coming anymore. I think the error appears because no proxy is set and the webdriver-manager is not able to run the update.

但是,现在我遇到了一个新错误.这又是完整的输出:

However, now I am getting a new error. Here is the full output again:

$ ng e2e --no-webdriver-update
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152/ **
Date: 2017-09-27T06:50:31.482Z
Hash: ef70100f8d31703b6b85
Time: 8513ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 3.16 MB {inline} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 209 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.6 kB {inline} [initial] [rendered]
(node:12764) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

webpack: Compiled successfully.
[08:50:31] I/launcher - Running 1 instances of WebDriver
[08:50:31] I/direct - Using ChromeDriver directly...
[08:50:31] E/direct - Error code: 135
[08:50:31] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[08:50:31] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
    at Direct.getNewDriver (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\built\driverProviders\direct.js:63:31)
    at Runner.createBrowser (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\built\runner.js:195:43)
    at q.then.then (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\built\runner.js:339:29)
    at _fulfilled (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:834:54)
    at self.promiseDispatch.done (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:863:30)
    at Promise.promise.promiseDispatch (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:796:13)
    at D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:556:49
    at runSingle (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:137:13)
    at flush (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
[08:50:31] E/launcher - Process exited with error code 135

推荐答案

好的,我能够解决问题.这就是我所做的.

OK, I was able to solve the problem. Here is what I did.

ng e2e运行webdriver-manager update命令.以我为例,这导致了ETIMEDOUT问题,因为在没有代理的环境中,它无法下载文件.相反,我必须使用ng e2e --no-webdriver-update.

ng e2e runs the webdriver-manager update command. In my case this caused the ETIMEDOUT problem, because in my environment without a proxy it cannot download the files. Instead I have to use ng e2e --no-webdriver-update.

现在我出现了Could not find update-config.json错误.

使用--proxy参数更新webdriver-manager似乎无法下载所有内容和/或正确.我必须设置环境变量HTTP_PROXYHTTPS_PROXY并运行命令webdriver-manager update --ignore_ssl.

Using the --proxy argument to update webdriver-manager seems to not download everything and/or correct. I had to set the environment variables HTTP_PROXY and HTTPS_PROXY and run the command webdriver-manager update --ignore_ssl.

现在量角器正在工作.

这篇关于量角器:ng e2e:如何解决“错误:连接ETIMEDOUT"问题.错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆