“ng e2e"可能由于代理而失败,但“ng serve"和“ng测试"正在工作 [英] "ng e2e" is failling probably in reason of proxy but "ng serve" and "ng test" are working

查看:40
本文介绍了“ng e2e"可能由于代理而失败,但“ng serve"和“ng测试"正在工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了 https://github.com/blizzerand/pastebin-angular 并且我可以成功运行ng test"或npm 运行测试"(我知道两者完全一样).

C:\_pocs\ws_vsc\pastebin-angular-master>npm 运行测试>test-angular@0.0.0 测试 C:\_pocs\ws_vsc\pastebin-angular-master>测试10% 构建模块 1/1 模块 0 active29 12 2017 18:13:27.927:WARN [karma]:没有捕获的浏览器,打开 http://localhost:9876/29 12 2017 18:13:27.998:INFO [karma]:Karma v1.7.0 服务器启动于 http://0.0.0.0:9876/29 12 2017 18:13:28.002:INFO [启动器]:启动浏览器 Chrome、ChromeNoSandboxHeadless,无限并发29 12 2017 18:13:28.013:INFO [启动器]:启动浏览器 Chrome29 12 2017 18:13:28.032:INFO [launcher]: 启动浏览器 Chrome 29 12 2017 18:13:39.229:WARN [karma]: 没有捕获的浏览器,打开 http://localhost:9876/29 12 2017 18:13:40.708:INFO [HeadlessChrome 0.0.0 (Windows 10 0.0.0)]:连接到 UDrOcB34PHgK-7M-AAAB 插槽,ID 为 4864709329 12 2017 18:13:40.708:INFO [Chrome 63.0.3239 (Windows 10 0.0.0)]:连接到套接字 8ZsdfQHAmDKzVaoHAAAA,ID 为 86143812Chrome 63.0.3239 (Windows 10 0.0.0): 执行了 31 of 31 SUCCESS (3.745 secs/3.714 secs)HeadlessChrome 0.0.0 (Windows 10 0.0.0): 31 of 31 SUCCESS (3.807 secs/3.779 secs) 执行总计:62 次成功总计:62 次成功

当我尝试ng e2e"时我得到 "ETIMEDOUT x.x.x.x:443"

C:\_pocs\ws_vsc\pastebin-angular-master>ng e2e您的全局 Angular CLI 版本 (1.6.3) 高于您本地的版本 (1.1.0).使用本地 Angular CLI 版本.要禁用此警告,请使用ng set --global warnings.versionMismatch=false".** NG Live Development Server 正在侦听 localhost:49152,在 http://localhost:49152 上打开浏览器 **(节点:5784)[DEP0022] 弃用警告:不推荐使用 os.tmpDir().使用 os.tmpdir() 代替.哈希:5891176eb0b28d7d1f89时间:12097ms块 {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]块 {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]块{2}styles.bundle.js,styles.bundle.js.map(样式)10.5 kB {4} [initial] [rendered]块 {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]webpack: 编译成功.事件.js:183扔er;//未处理的错误"事件^错误:连接 ETIMEDOUT x.x.x.x:443在 Object._errnoException (util.js:1024:11)在 _exceptionWithHostPort (util.js:1046:20)在 TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)

所以我改为ng e2e --no-webdriver-update";因为它根本不会依赖代理.

C:\_pocs\ws_vsc\pastebin-angular-master>ng e2e --no-webdriver-update您的全局 Angular CLI 版本 (1.6.3) 高于您本地的版本 (1.1.0).使用本地 Angular CLI 版本.要禁用此警告,请使用ng set --global warnings.versionMismatch=false".** NG Live Development Server 正在侦听 localhost:49152,在 http://localhost:49152 上打开浏览器 **(节点:14496)[DEP0022] 弃用警告:不推荐使用 os.tmpDir().使用 os.tmpdir() 代替.哈希:5891176eb0b28d7d1f89时间:13274ms块 {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]块 {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]块{2}styles.bundle.js,styles.bundle.js.map(样式)10.5 kB {4} [initial] [rendered]块 {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]webpack: 编译成功.[18:20:39] I/launcher - 运行 1 个 WebDriver 实例[18:20:39] I/direct - 直接使用 ChromeDriver...[18:20:39] E/direct - 错误代码:135[18:20:39] E/direct - 错误消息:找不到 update-config.json.运行webdriver-manager update"以下载二进制文件.[18:20:39] E/direct - 错误:找不到 update-config.json.运行webdriver-manager update"以下载二进制文件.在 Direct.getNewDriver (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\built\driverProviders\direct.js:63:31)在 Runner.createBrowser (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\built\runner.js:195:43)在 q.then.then (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\built\runner.js:339:29)在 _fulfilled (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:834:54)在 self.promiseDispatch.done (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:863:30)在 Promise.promise.promiseDispatch (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:796:13)在 C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:556:49在 runSingle (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:137:13)在刷新 (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:125:13)在 _combinedTickCallback (internal/process/next_tick.js:131:7)在 process._tickCallback (internal/process/next_tick.js:180:9)[18:20:39] E/launcher - 进程退出,错误代码 135

因为我收到了找不到 update-config.json".运行webdriver-manager update"然后我尝试下载它并明确使用我的本地代理

C:\_pocs\ws_vsc\pastebin-angular-master>webdriver-manager update --proxy http://myproxy.vm.mycompany.net:3128[18:23:19] I/更新 - geckodriver:文件存在 C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\protractor\node_modules\webdriver-manager\selenium\geckodriver-v0.19.1.压缩[18:23:19] I/更新 - geckodriver:解压 geckodriver-v0.19.1.zip[18:23:19] I/update - geckodriver: geckodriver-v0.19.1.exe 是最新的[18:23:20] E/downloader - 预期响应代码 200,收到:403[18:23:20] I/update - chromedriver: 文件存在 C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.34.zip[18:23:20] I/更新 - chromedriver:解压 chromedriver_2.34.zip(节点:14648)UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:1):无效的文件名(节点:14648)[DEP0018] 弃用警告:不推荐使用未处理的承诺拒绝.将来,未处理的承诺拒绝将使用非零退出代码终止 Node.js 进程.[18:24:29] I/更新 - selenium 独立:文件存在 C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.8.1.jar[18:24:29] I/更新 - selenium 独立:selenium-server-standalone-3.8.1.jar 是最新的

当我看到我有点困惑"E/下载器 - 预期响应代码 200,收到:403"但最后我看到I/update - selenium standalone: selenium-server-standalone-3.8.1.jar up to date".我会假设我正确下载了它.现在我重复ng e2e"我在上面遇到了同样的错误.由于我看到端口号 443,我决定尝试一些ng e2e --skip-ssl"我在上面遇到了同样的错误.我也试过 ng e2e --webdriver-update=false ,但我仍然得到找不到 update-config.json".

我尝试的最后一次尝试是

C:\_pocs\ws_vsc\pastebin-angular-master>npm run e2e>test-angular@0.0.0 e2e C:\_pocs\ws_vsc\pastebin-angular-master>ng e2e** NG Live Development Server 正在侦听 localhost:49152,在 http://localhost:49152 上打开浏览器 **(节点:9036)[DEP0022] 弃用警告:不推荐使用 os.tmpDir().使用 os.tmpdir() 代替.哈希:5891176eb0b28d7d1f89时间:11115ms块 {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]块 {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]块{2}styles.bundle.js,styles.bundle.js.map(样式)10.5 kB {4} [initial] [rendered]块 {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]webpack: 编译成功.事件.js:183扔er;//未处理的错误"事件^错误:连接 ETIMEDOUT 172.217.17.48:443在 Object._errnoException (util.js:1024:11)在 _exceptionWithHostPort (util.js:1046:20)在 TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)npm 错误!代码生命周期npm 错误!错误号 1npm 错误!测试角度@0.0.0 e2e:`ng e2e`npm 错误!退出状态 1npm 错误!npm 错误!test-angular@0.0.0 e2e 脚本失败.npm 错误!这可能不是 npm 的问题.上面可能有额外的日志输出.npm 错误!可以在以下位置找到此运行的完整日志:npm 错误!C:\Users\dca\AppData\Roaming\npm-cache\_logs\2017-12-29T17_33_44_400Z-debug.log

这是日志

0 info 如果它以 ok 结尾,它就起作用了1 详细的 cli ['C:\\Program Files\\nodejs\\node.exe',1 详细的 cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',1个详细的cli运行",1个详细的cli'e2e']2 信息使用 npm@5.5.13 信息使用 node@v8.9.34 详细的运行脚本 ['pree2e', 'e2e', 'poste2e']5 信息生命周期 test-angular@0.0.0~pree2e: test-angular@0.0.06 信息生命周期 test-angular@0.0.0~e2e: test-angular@0.0.07 冗长的生命周期测试-angular@0.0.0~e2e: unsafe-perm in lifecycle true8 详细生命周期测试-angular@0.0.0~e2e:路径:C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\npm\bin\node-gyp-bin;C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\.bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Windows\CCM;C:\Program Files (x86)\GnuWin32\bin;C:\Program Files (x86)\Skype\Phone\;C:\_t3\gradle-3.5\bin;C:\Program Files (x86)\Subversion\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Yarn\bin;C:\Program Files\TortoiseSVN\bin;C:\Users\dca\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Users\dca\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Java\jdk1.8.0_112\bin;C:\_t\maven\bin;C:\Users\dca\AppData\Local\GitHubDesktop\bin;C:\Program Files\Microsoft VS Code\bin;C:\Users\dca\AppData\Local\Yarn\bin;C:\Users\dca\AppData\Roaming\nvm;C:\Program Files\nodejs9 详细生命周期测试-angular@0.0.0~e2e: CWD: C:\_pocs\ws_vsc\pastebin-angular-master10 愚蠢的生命周期测试-angular@0.0.0~e2e: Args: [ '/d/s/c', 'ng e2e' ]11 愚蠢的生命周期测试-angular@0.0.0~e2e:返回:代码:1 信号:空12 信息生命周期 test-angular@0.0.0~e2e: 无法执行 e2e 脚本13 详细堆栈错误:test-angular@0.0.0 e2e:`ng e2e`13 详细堆栈退出状态 113 EventEmitter 上的详细堆栈.(C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16)13 冗长堆栈在emitTwo (events.js:126:13)EventEmitter.emit 上的 13 个详细堆栈 (events.js:214:7)13 ChildProcess 中的详细堆栈.(C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)13 冗长堆栈在emitTwo (events.js:126:13)ChildProcess.emit 上的 13 个详细堆栈 (events.js:214:7)13 详细堆栈在可能关闭 (internal/child_process.js:925:16)13 Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 的详细堆栈14 详细 pkid 测试角度@0.0.015 详细 cwd C:\_pocs\ws_vsc\pastebin-angular-master16 详细 Windows_NT 10.0.1439317 详细参数C:\\Program Files\\nodejs\\node.exe"C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js"跑"e2e"18 详细节点 v8.9.319 冗长的 npm v5.5.120 错误代码 ELIFECYCLE21 错误 errno 122 错误 test-angular@0.0.0 e2e: `ng e2e`22 错误退出状态 123 错误 test-angular@0.0.0 e2e 脚本失败.23 错误 这可能不是 npm 的问题.上面可能有额外的日志输出.24 详细退出 [ 1, true ]

如果相关,这里是 package.json

<代码>{名称":测试角",版本":0.0.0",许可证":MIT",脚本":{ng":ng",开始":ng服务",build":ng build",测试":ng测试",lint":ng lint",e2e":ng e2e"},私人":真的,依赖关系":{@angular/animations":^4.0.0",@angular/common":^4.0.0",@angular/compiler":^4.0.0",@angular/core":^4.0.0",@angular/forms":^4.0.0",@angular/http":^4.0.0",@angular/platform-b​​rowser":^4.0.0",@angular/platform-b​​rowser-dynamic":^4.0.0",@angular/router":^4.0.0",@types/faker":^4.1.0",angular-in-memory-web-api":^0.3.2",core-js":^2.4.1",faker":^4.1.0",rxjs":^5.1.0",zone.js":^0.8.4";},开发依赖":{@angular/cli":1.1.0",@angular/compiler-cli":^4.0.0",@angular/language-service":^4.0.0",@types/jasmine":2.5.45",@types/node":~6.0.60",codelyzer":~3.0.1",茉莉花芯":~2.6.2",jasmine-spec-reporter":~4.1.0",业力":~1.7.0",karma-chrome-launcher":~2.1.1",karma-cli":~1.0.1",业力茉莉":~1.1.0",karma-jasmine-html-reporter":^0.2.2",karma-coverage-istanbul-reporter":^1.2.1",量角器":~5.1.2",ts-node":~3.0.4",tslint":~5.3.2",打字稿":~2.3.3"}}

我所做的所有尝试都是在 2 天(16 小时)努力设置我的环境之后.据我了解ng test"运行基于 Jasmine sintaxes 和ng e2e"的测试;基于量角器语法(我知道这是非常虚拟的比较).

最后,当我看到两个 ng serve"和ng测试"工作正常.

C:\_pocs\ws_vsc\pastebin-angular-master>ng serve您的全局 Angular CLI 版本 (1.6.3) 高于您本地的版本 (1.1.0).使用本地 Angular CLI 版本.要禁用此警告,请使用ng set --global warnings.versionMismatch=false".** NG Live Development Server 正在侦听 localhost:4200,在 http://localhost:4200 上打开浏览器 **哈希:68480633f4a6979c64f6时间:12524ms块 {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]块 {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]块{2}styles.bundle.js,styles.bundle.js.map(样式)10.5 kB {4} [initial] [rendered]块 {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]webpack: 编译成功.

...

C:\_pocs\ws_vsc\pastebin-angular-master>ng 测试您的全局 Angular CLI 版本 (1.6.3) 高于您本地的版本 (1.1.0).使用本地 Angular CLI 版本.要禁用此警告,请使用ng set --global warnings.versionMismatch=false".10% 构建模块 1/1 模块 0 active29 12 2017 18:46:45.409:WARN [karma]:没有捕获的浏览器,打开 http://localhost:9876/29 12 2017 18:46:45.487:INFO [karma]:Karma v1.7.0 服务器启动于 http://0.0.0.0:9876/29 12 2017 18:46:45.487:INFO [启动器]:启动浏览器 Chrome、ChromeNoSandboxHeadless 与无限并发29 12 2017 18:46:45.502:INFO [启动器]:启动浏览器 Chrome29 12 2017 18:46:45.523:INFO [launcher]: 启动浏览器 Chrome 29 12 2017 18:46:57.058:WARN [karma]: 没有捕获的浏览器,打开 http://localhost:9876/29 12 2017 18:46:58.843:INFO [Chrome 63.0.3239 (Windows 10 0.0.0)]:连接到插座 ZyuotOYE2ISz30vzAAAA,ID 为 4172756829 12 2017 18:46:58.910:INFO [HeadlessChrome 0.0.0 (Windows 10 0.0.0)]:连接到 yBro2KHiWGptHCihAAAB 插槽,ID 为 10384190Chrome 63.0.3239 (Windows 10 0.0.0):执行了 31 个成功的 31 个(4.328 秒/4.288 秒)HeadlessChrome 0.0.0 (Windows 10 0.0.0): 执行了 31 of 31 SUCCESS (4.279 secs/4.24 secs)总计:62 次成功总计:62 次成功

Webdriver-manager 也能正确启动:

C:\_pocs\ws_vsc\pastebin-angular-master>webdriver-manager 启动代理 http://xxx.vm.xxx.net:3128[18:52:18] I/start - java -Dwebdriver.gecko.driver=C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\protractor\node_modules\webdriver-manager\selenium\geckodriver-v0.19.1.exe -jar C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.8.1.jar -port 4444[18:52:18] I/start - seleniumProcess.pid: 1154018:52:19.437 信息 - Selenium 构建信息:版本:'3.8.1',修订版:'6e95a6684b'18:52:19.438 信息 - 启动独立的 Selenium 服务器2017-12-29 18:52:19.546:INFO::main: 日志初始化@387ms 到 org.seleniumhq.jetty9.util.log.StdErrLog18:52:19.577 信息 - 使用 `new FirefoxOptions()` 优于 `DesiredCapabilities.firefox()`18:52:19.593 信息 - 使用 `new ChromeOptions()` 优于 `DesiredCapabilities.chrome()`18:52:19.608 信息 - 使用 `new EdgeOptions()` 优于 `DesiredCapabilities.edge()`18:52:19.608 信息 - 未找到驱动程序类:com.opera.core.systems.OperaDriver 18:52:19.608 信息 - 使用 `new OperaOptions()` 优于 `DesiredCapabilities.operaBlink()`18:52:19.608 信息 - 使用 `new SafariOptions()` 优于 `DesiredCapabilities.safari()`18:52:19.608 信息 - 未找到驱动程序类:org.openqa.selenium.phantomjs.PhantomJSDriver 18:52:19.655 信息 - 驱动程序提供程序类 org.openqa.selenium.safari.SafariDriver 注册被跳过:注册功能功能 {browserName:safari,平台:MAC,版本:}与当前平台WIN10不匹配18:52:19.702 信息 - 使用 `new ChromeOptions()` 优于 `DesiredCapabilities.chrome()`18:52:19.702 信息 - 使用 `new EdgeOptions()` 优于`DesiredCapabilities.edge()` 18:52:19.702 信息 - 使用`new FirefoxOptions()` 优于`DesiredCapabilities.firefox()`18:52:19.702 信息 - 使用`new OperaOptions()` 优于`DesiredCapabilities.operaBlink()` 18:52:19.702 信息-使用`new SafariOptions()` 优于`DesiredCapabilities.safari()`18:52:19.718 信息 - 使用直通模式处理程序2017-12-29 18:52:19.751:INFO:osjs.Server:main:jetty-9.4.7.v201709142017-12-29 18:52:19.778:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@757942a1{/,null,STARTING} 发现了路径的 http 方法:/2017-12-29 18:52:19.787:INFO:osjsh.ContextHandler:main: 启动 osjsServletContextHandler@757942a1{/,null,AVAILABLE}2017-12-29 18:52:19.913:INFO:osjs:main:AbstractConnector启动 ServerConnector@27d415d9{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}2017-12-29 18:52:19.916:INFO:osjs.Server:main: 开始 @756ms18:52:19.917 信息 - Selenium 服务器已启动并正在运行

对以上可能的误解进行检查或更正的任何内容都将受到高度赞赏.

  • 找到解决方案后

如果我在没有建议环境变量的情况下尝试,我得到:

C:\_pocs\ws_vsc\pastebin-angular-master>ng e2e您的全局 Angular CLI 版本 (1.6.3) 高于您本地的版本 (1.1.0).使用本地 Angular CLI 版本.要禁用此警告,请使用ng set --global warnings.versionMismatch=false".** NG Live Development Server 正在侦听 localhost:49152,在 http://localhost:49152 上打开浏览器 **(节点:8044)[DEP0022] 弃用警告:不推荐使用 os.tmpDir().使用 os.tmpdir() 代替.哈希:5891176eb0b28d7d1f89时间:12039ms块 {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]块 {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]块{2}styles.bundle.js,styles.bundle.js.map(样式)10.5 kB {4} [initial] [rendered]块 {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]webpack: 编译成功.[16:12:48] E/downloader - 下载连接超时:https://chromedriver.storage.googleapis.com/2.34/chromedriver_win32.zip.默认超时为 4 分钟.[16:12:48] I/update - chromedriver: 文件存在 C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.34.zip[16:12:48] I/更新 - chromedriver:解压 chromedriver_2.34.zip[16:12:49] I/update - chromedriver: chromedriver_2.34.exe 是最新的[16:12:49] I/launcher - 运行 1 个 WebDriver 实例[16:12:49] I/direct - 直接使用 ChromeDriver...[16:12:49] E/downloader - 下载连接超时:https://chromedriver.storage.googleapis.com/2.34/chromedriver_win32.zip.默认超时为 4 分钟.DevTools 监听 ws://127.0.0.1:12268/devtools/browser/71d97023-dae5-4b24-8ecc-98922db60bf5茉莉花开始在 0.002 秒内执行了 0 个规范中的 0 个成功.[16:12:53] I/launcher - 0 个 WebDriver 实例仍在运行[16:12:53] I/launcher - chrome #01 通过

另一方面,在设置环境变量后,我得到:

C:\_pocs\ws_vsc\pastebin-angular-master>ng e2e您的全局 Angular CLI 版本 (1.6.3) 高于您本地的版本 (1.1.0).使用本地 Angular CLI 版本.要禁用此警告,请使用ng set --global warnings.versionMismatch=false".** NG Live Development Server 正在侦听 localhost:49152,在 http://localhost:49152 上打开浏览器 **(节点:2288)[DEP0022] 弃用警告:不推荐使用 os.tmpDir().使用 os.tmpdir() 代替.哈希:5891176eb0b28d7d1f89时间:12368ms块 {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]块 {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]块{2}styles.bundle.js,styles.bundle.js.map(样式)10.5 kB {4} [initial] [rendered]块 {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]webpack: 编译成功.[16:19:30] I/update - chromedriver: 文件存在 C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.34.zip[16:19:30] I/更新 - chromedriver:解压 chromedriver_2.34.zip[16:19:30] I/update - chromedriver: chromedriver_2.34.exe 是最新的[16:19:30] I/launcher - 运行 1 个 WebDriver 实例[16:19:30] I/direct - 直接使用 ChromeDriver...DevTools 监听 ws://127.0.0.1:12462/devtools/browser/86f2d2f5-3312-48e6-8d05-25241eeba843茉莉花开始在 0.003 秒内执行了 0 个规范中的 0 个成功.[16:19:34] I/launcher - 0 个 WebDriver 实例仍在运行[16:19:34] I/launcher - chrome #01 通过

解决方案

1) 运行 ng e2e 时报错:Error: connect ETIMEDOUT xxxx:443

因为ng e2e的选项--webdriver-update的默认值为true,而且你的网络在代理后面,所以不用告诉你的网络代理给webdriver-manager, webdriver-manger 更新将无法连接网络,这就是您看到错误的原因.

我在 https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/tasks/e2e.ts,并注意到我们不能通过跟随 npm run e2e 后面的来传递代理,但是我们可以在环境变量中设置代理,webdriver-manager 在运行之前会读取,你可以按照下面的帖子在环境变量中设置代理:how检查导致 webdriver-manager 失败的原因

2) 当您运行 ng e2e --no-webdriver-update 跳过 webdriver 更新时,它报告错误:Error message: could not find update-config.json

这意味着 project_folder\node_modules\protractor\node_modules\webdriver-manager\selenium

中不存在 update-config.json

因为您使用全局webdriver-manger 来执行webdriver 更新,而不是项目本地webdriver-manager(位于project_folder\.bin\webdriver-manager).

正确的方法是先在cmd窗口切换到your_project文件夹,然后执行node_modules\.bin\webdriver-manager update --proxy http://myproxy.vm.mycompany.net:3128然后 update-config.json 将在那里,ng e2e --no-webdriver-manager 现在应该可以工作了.

ng e2e 不能使用全局的webdriver-manager,而只能使用本地的node_modules\.bin\webdriver-manger

>

npm 代理 VS 环境变量代理

1) npm 代理

npm proxy 只对命令有效:npm 并且这个命令工具不会从 evniroment 变量中读取代理,因此你必须通过命令 npm config set或者直接修改用户home或者项目文件夹下的.npmrc文件.

2) 环境变量代理

只有执行的工具/软件/程序/命令会从环境变量中读取代理设置,然后环境变量代理才能对其产生影响.

用户不容易知道环境变量代理会对工具/软件/程序/命令产生影响,尤其是我们第一次接触的新事物.

但一般情况下,我们可以认为从命令窗口执行的所有内容都会从环境变量中读取代理设置,但并不总是这样,像npm一样,它只从自己的代理设置中读取代理.

现在回到webdriver-manager,在大多数情况下它首先从命令窗口执行,实际上决定环境变量代理对其是否影响的最终决定因素是实现本身.>

webdriver-manager实现中,首先会读取在命令行中作为选项传递的代理如下: webdriver-manager update --proxy http://proxy.company.com:1234

如果你没有在命令行中传递代理,那么它会从环境变量中读取代理.

I download https://github.com/blizzerand/pastebin-angular and I can successfully run "ng test" or "npm run test" (I understand both do exactly the same).

C:\_pocs\ws_vsc\pastebin-angular-master>npm run test

    > test-angular@0.0.0 test C:\_pocs\ws_vsc\pastebin-angular-master
    > ng test
    
     10% building modules 1/1 modules 0 active29 12 2017 18:13:27.927:WARN [karma]: No captured browser, open http://localhost:9876/
    29 12 2017 18:13:27.998:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
    29 12 2017 18:13:28.002:INFO [launcher]: Launching browsers Chrome, ChromeNoSandboxHeadless with unlimited concurrency
    29 12 2017 18:13:28.013:INFO [launcher]: Starting browser Chrome
    29 12 2017 18:13:28.032:INFO [launcher]: Starting browser Chrome              29 12 2017 18:13:39.229:WARN [karma]: No captured browser, open http://localhost:9876/
    29 12 2017 18:13:40.708:INFO [HeadlessChrome 0.0.0 (Windows 10 0.0.0)]: Connected on socket UDrOcB34PHgK-7M-AAAB with id 48647093
    29 12 2017 18:13:40.708:INFO [Chrome 63.0.3239 (Windows 10 0.0.0)]: Connected on socket 8ZsdfQHAmDKzVaoHAAAA with id 86143812
    Chrome 63.0.3239 (Windows 10 0.0.0): Executed 31 of 31 SUCCESS (3.745 secs / 3.714 secs)
    HeadlessChrome 0.0.0 (Windows 10 0.0.0): Executed 31 of 31 SUCCESS (3.807 secs / 3.779 secs)
    TOTAL: 62 SUCCESS
    TOTAL: 62 SUCCESS

When I try "ng e2e" I get " ETIMEDOUT x.x.x.x:443"

C:\_pocs\ws_vsc\pastebin-angular-master>ng e2e
Your global Angular CLI version (1.6.3) is greater than your local
version (1.1.0). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152 **
(node:5784) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
Hash: 5891176eb0b28d7d1f89
Time: 12097ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: connect ETIMEDOUT x.x.x.x:443
    at Object._errnoException (util.js:1024:11)
    at _exceptionWithHostPort (util.js:1046:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)

So I change to "ng e2e --no-webdriver-update" since it will no rely on proxy at all.

C:\_pocs\ws_vsc\pastebin-angular-master>ng e2e --no-webdriver-update
Your global Angular CLI version (1.6.3) is greater than your local
version (1.1.0). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152 **
(node:14496) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
Hash: 5891176eb0b28d7d1f89
Time: 13274ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
[18:20:39] I/launcher - Running 1 instances of WebDriver
[18:20:39] I/direct - Using ChromeDriver directly...
[18:20:39] E/direct - Error code: 135
[18:20:39] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[18:20:39] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
    at Direct.getNewDriver (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\built\driverProviders\direct.js:63:31)
    at Runner.createBrowser (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\built\runner.js:195:43)
    at q.then.then (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\built\runner.js:339:29)
    at _fulfilled (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:834:54)
    at self.promiseDispatch.done (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:863:30)
    at Promise.promise.promiseDispatch (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:796:13)
    at C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:556:49
    at runSingle (C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\q\q.js:137:13)
    at flush (C:\_pocs\ws_vsc\pastebin-angular-master\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)
[18:20:39] E/launcher - Process exited with error code 135

Since I got "Could not find update-config.json. Run 'webdriver-manager update' " then I tried downlod it and explicitly use my local proxy

C:\_pocs\ws_vsc\pastebin-angular-master>webdriver-manager update --proxy http://myproxy.vm.mycompany.net:3128
[18:23:19] I/update - geckodriver: file exists C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\protractor\node_modules\webdriver-manager\selenium\geckodriver-v0.19.1.zip
[18:23:19] I/update - geckodriver: unzipping geckodriver-v0.19.1.zip
[18:23:19] I/update - geckodriver: geckodriver-v0.19.1.exe up to date
[18:23:20] E/downloader - Expected response code 200, received: 403
[18:23:20] I/update - chromedriver: file exists C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.34.zip
[18:23:20] I/update - chromedriver: unzipping chromedriver_2.34.zip
(node:14648) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Invalid filename
(node:14648) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[18:24:29] I/update - selenium standalone: file exists C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.8.1.jar
[18:24:29] I/update - selenium standalone: selenium-server-standalone-3.8.1.jar up to date

A bit confusing for me when I see " E/downloader - Expected response code 200, received: 403" but at the end I see "I/update - selenium standalone: selenium-server-standalone-3.8.1.jar up to date". I will assume that I download it correctly. Now I repeat "ng e2e" and I got same error above. Since I see port number 443, I decided try something "ng e2e --skip-ssl" and I got same error above. I tried ng e2e --webdriver-update=false as well and I still get "Could not find update-config.json".

The last tentative I tried was

C:\_pocs\ws_vsc\pastebin-angular-master>npm run e2e

> test-angular@0.0.0 e2e C:\_pocs\ws_vsc\pastebin-angular-master
> ng e2e

** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152 **
(node:9036) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
Hash: 5891176eb0b28d7d1f89
Time: 11115ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: connect ETIMEDOUT 172.217.17.48:443
    at Object._errnoException (util.js:1024:11)
    at _exceptionWithHostPort (util.js:1046:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-angular@0.0.0 e2e: `ng e2e`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-angular@0.0.0 e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\dca\AppData\Roaming\npm-cache\_logs\2017-12-29T17_33_44_400Z-debug.log

and here is the log

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'e2e' ]
2 info using npm@5.5.1
3 info using node@v8.9.3
4 verbose run-script [ 'pree2e', 'e2e', 'poste2e' ]
5 info lifecycle test-angular@0.0.0~pree2e: test-angular@0.0.0
6 info lifecycle test-angular@0.0.0~e2e: test-angular@0.0.0
7 verbose lifecycle test-angular@0.0.0~e2e: unsafe-perm in lifecycle true
8 verbose lifecycle test-angular@0.0.0~e2e: PATH: C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\npm\bin\node-gyp-bin;C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\.bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Windows\CCM;C:\Program Files (x86)\GnuWin32\bin;C:\Program Files (x86)\Skype\Phone\;C:\_t3\gradle-3.5\bin;C:\Program Files (x86)\Subversion\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Yarn\bin;C:\Program Files\TortoiseSVN\bin;C:\Users\dca\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Users\dca\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Java\jdk1.8.0_112\bin;C:\_t\maven\bin;C:\Users\dca\AppData\Local\GitHubDesktop\bin;C:\Program Files\Microsoft VS Code\bin;C:\Users\dca\AppData\Local\Yarn\bin;C:\Users\dca\AppData\Roaming\nvm;C:\Program Files\nodejs
9 verbose lifecycle test-angular@0.0.0~e2e: CWD: C:\_pocs\ws_vsc\pastebin-angular-master
10 silly lifecycle test-angular@0.0.0~e2e: Args: [ '/d /s /c', 'ng e2e' ]
11 silly lifecycle test-angular@0.0.0~e2e: Returned: code: 1  signal: null
12 info lifecycle test-angular@0.0.0~e2e: Failed to exec e2e script
13 verbose stack Error: test-angular@0.0.0 e2e: `ng e2e`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid test-angular@0.0.0
15 verbose cwd C:\_pocs\ws_vsc\pastebin-angular-master
16 verbose Windows_NT 10.0.14393
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "e2e"
18 verbose node v8.9.3
19 verbose npm  v5.5.1
20 error code ELIFECYCLE
21 error errno 1
22 error test-angular@0.0.0 e2e: `ng e2e`
22 error Exit status 1
23 error Failed at the test-angular@0.0.0 e2e script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

In case it is relevant, here is package.json

{
  "name": "test-angular",
  "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.0.0",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@types/faker": "^4.1.0",
    "angular-in-memory-web-api": "^0.3.2",
    "core-js": "^2.4.1",
    "faker": "^4.1.0",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.1.0",
    "@angular/compiler-cli": "^4.0.0",
    "@angular/language-service": "^4.0.0",
    "@types/jasmine": "2.5.45",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.0.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-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "protractor": "~5.1.2",
    "ts-node": "~3.0.4",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

All tentatives I have done was after 2 days (16 hours) struggling to settup my environment. As far as I understand "ng test" run tests based on Jasmine sintaxes and "ng e2e" based on Protractor sintaxes (I know it is very dummy comparasion).

Finally, it make my route to find the issue even more complicated when I see that both "ng serve" and "ng test" are working perfectly.

C:\_pocs\ws_vsc\pastebin-angular-master>ng serve
Your global Angular CLI version (1.6.3) is greater than your local
version (1.1.0). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200 **
Hash: 68480633f4a6979c64f6
Time: 12524ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.

...

C:\_pocs\ws_vsc\pastebin-angular-master>ng test
Your global Angular CLI version (1.6.3) is greater than your local
version (1.1.0). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
 10% building modules 1/1 modules 0 active29 12 2017 18:46:45.409:WARN [karma]: No captured browser, open http://localhost:9876/
29 12 2017 18:46:45.487:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
29 12 2017 18:46:45.487:INFO [launcher]: Launching browsers Chrome, ChromeNoSandboxHeadless with unlimited concurrency
29 12 2017 18:46:45.502:INFO [launcher]: Starting browser Chrome
29 12 2017 18:46:45.523:INFO [launcher]: Starting browser Chrome              29 12 2017 18:46:57.058:WARN [karma]: No captured browser, open http://localhost:9876/
29 12 2017 18:46:58.843:INFO [Chrome 63.0.3239 (Windows 10 0.0.0)]: Connected on socket ZyuotOYE2ISz30vzAAAA with id 41727568
29 12 2017 18:46:58.910:INFO [HeadlessChrome 0.0.0 (Windows 10 0.0.0)]: Connected on socket yBro2KHiWGptHCihAAAB with id 10384190
Chrome 63.0.3239 (Windows 10 0.0.0): Executed 31 of 31 SUCCESS (4.328 secs / 4.288 secs)
HeadlessChrome 0.0.0 (Windows 10 0.0.0): Executed 31 of 31 SUCCESS (4.279 secs / 4.24 secs)
TOTAL: 62 SUCCESS
TOTAL: 62 SUCCESS

Webdriver-manager also starts correctly:

C:\_pocs\ws_vsc\pastebin-angular-master>webdriver-manager start proxy http://xxx.vm.xxx.net:3128
[18:52:18] I/start - java -Dwebdriver.gecko.driver=C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\protractor\node_modules\webdriver-manager\selenium\geckodriver-v0.19.1.exe -jar C:\Users\dca\AppData\Roaming\nvm\v8.9.3\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.8.1.jar -port 4444
[18:52:18] I/start - seleniumProcess.pid: 11540
18:52:19.437 INFO - Selenium build info: version: '3.8.1', revision: '6e95a6684b'
18:52:19.438 INFO - Launching a standalone Selenium Server
2017-12-29 18:52:19.546:INFO::main: Logging initialized @387ms to org.seleniumhq.jetty9.util.log.StdErrLog
18:52:19.577 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
18:52:19.593 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
18:52:19.608 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
18:52:19.608 INFO - Driver class not found: com.opera.core.systems.OperaDriver                                          18:52:19.608 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
18:52:19.608 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
18:52:19.608 INFO - Driver class not found: org.openqa.selenium.phantomjs.PhantomJSDriver                               18:52:19.655 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:               registration capabilities Capabilities {browserName: safari, platform: MAC, version: } does not match the current platform WIN10
18:52:19.702 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
18:52:19.702 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`                              18:52:19.702 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
18:52:19.702 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`                       18:52:19.702 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
18:52:19.718 INFO - Using the passthrough mode handler
2017-12-29 18:52:19.751:INFO:osjs.Server:main: jetty-9.4.7.v20170914
2017-12-29 18:52:19.778:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@757942a1{/,null,STARTING} has uncovered http methods for path: /
2017-12-29 18:52:19.787:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@757942a1{/,null,AVAILABLE}2017-12-29 18:52:19.913:INFO:osjs.AbstractConnector:main: Started ServerConnector@27d415d9{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-12-29 18:52:19.916:INFO:osjs.Server:main: Started @756ms
18:52:19.917 INFO - Selenium Server is up and running

Anything to check or correction on possible misunderstanding above will be highly appreciatted.

  • edited after solution found:

if I tried without environment variables suggested, I got:

C:\_pocs\ws_vsc\pastebin-angular-master>ng e2e
Your global Angular CLI version (1.6.3) is greater than your local
version (1.1.0). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152 **
(node:8044) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
Hash: 5891176eb0b28d7d1f89
Time: 12039ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
[16:12:48] E/downloader - Connection timeout downloading: https://chromedriver.storage.googleapis.com/2.34/chromedriver_win32.zip. Default timeout is 4 minutes.
[16:12:48] I/update - chromedriver: file exists C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.34.zip
[16:12:48] I/update - chromedriver: unzipping chromedriver_2.34.zip
[16:12:49] I/update - chromedriver: chromedriver_2.34.exe up to date
[16:12:49] I/launcher - Running 1 instances of WebDriver
[16:12:49] I/direct - Using ChromeDriver directly...
[16:12:49] E/downloader - Connection timeout downloading: https://chromedriver.storage.googleapis.com/2.34/chromedriver_win32.zip. Default timeout is 4 minutes.

DevTools listening on ws://127.0.0.1:12268/devtools/browser/71d97023-dae5-4b24-8ecc-98922db60bf5
Jasmine started

Executed 0 of 0 specs SUCCESS in 0.002 sec.
[16:12:53] I/launcher - 0 instance(s) of WebDriver still running
[16:12:53] I/launcher - chrome #01 passed

On another hand, after setting the environment variables, I got:

C:\_pocs\ws_vsc\pastebin-angular-master>ng e2e
Your global Angular CLI version (1.6.3) is greater than your local
version (1.1.0). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152 **
(node:2288) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
Hash: 5891176eb0b28d7d1f89
Time: 12368ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 29.2 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.82 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
[16:19:30] I/update - chromedriver: file exists C:\_pocs\ws_vsc\pastebin-angular-master\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.34.zip
[16:19:30] I/update - chromedriver: unzipping chromedriver_2.34.zip
[16:19:30] I/update - chromedriver: chromedriver_2.34.exe up to date
[16:19:30] I/launcher - Running 1 instances of WebDriver
[16:19:30] I/direct - Using ChromeDriver directly...

DevTools listening on ws://127.0.0.1:12462/devtools/browser/86f2d2f5-3312-48e6-8d05-25241eeba843
Jasmine started

Executed 0 of 0 specs SUCCESS in 0.003 sec.
[16:19:34] I/launcher - 0 instance(s) of WebDriver still running
[16:19:34] I/launcher - chrome #01 passed

解决方案

1) when you run ng e2e, it report error: Error: connect ETIMEDOUT x.x.x.x:443

because the default value of option --webdriver-update of ng e2e is true, and your network behind proxy, so without telling your network proxy to webdriver-manager, webdriver-manger update will fail to connect network, this's why you see the error.

I looked into the source code of ng e2e at https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/tasks/e2e.ts, and noticed we can't pass the proxy by following behind npm run e2e, but we can set proxy in Enviroment Variable which webdriver-manager will read before running, you can follow below post to set proxy in Environment Varable: how to check what is causing webdriver-manager to fail

2) when you run ng e2e --no-webdriver-update to skip webdriver update, it report error: Error message: Could not find update-config.json

It means the update-config.json not exist in project_folder\node_modules\protractor\node_modules\webdriver-manager\selenium

Because you used the global webdriver-manger to execute webdriver update, rather than the project local webdriver-manager (at project_folder\.bin\webdriver-manager).

The correct way is switch to your_project folder in cmd window firstly, then execute node_modules\.bin\webdriver-manager update --proxy http://myproxy.vm.mycompany.net:3128 Then the update-config.json will be there and ng e2e --no-webdriver-manager should work now.

ng e2e can't use global webdriver-manager, but only project local node_modules\.bin\webdriver-manger

npm proxy VS environment variable proxy

1) npm proxy

npm proxy only work for the command: npm and this command implement won't read proxy from evniroment variable, thus you have to set proxy for npm by command npm config set or directly modify .npmrc file under user home or project folder.

2) environment variable proxy

Only tool/soft/program/command which implement will read proxy setting from environment variable, then the environment variable proxy can effect on them.

It's not easy for user to know environment variable proxy will effect on a tool/soft/program/command, especially it's a new thing we touch for first time.

But in generally, we can think everything executed from command window will read proxy setting from environment variable, but it's not always this, Like npm, it only read proxy from itself proxy setting.

Now back to the webdriver-manager, first it executed from command window in most case, actually the final determiner to decide environment variable proxy will effect on it or not is the implement itself.

In webdriver-manager implement, firstly, it will read proxy passed as options in command line as following: webdriver-manager update --proxy http://proxy.company.com:1234

If you not pass proxy in command line, then it will read proxy from environment variable.

这篇关于“ng e2e"可能由于代理而失败,但“ng serve"和“ng测试"正在工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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