问题描述
将感谢您的帮助!
- 我正在Windows上运行
- 我在全球范围内安装了量角器版本5.3.0
- 在更新Webdriver之前,我运行过:
webdriver-manager clean
- 和更新的版本如下:
- 节点版本9.2.1
- npm版本5.7.1
- 在启动e2e之前先启动开发服务器.
我的protractor.conf文件如下:
my protractor.conf file is as follows:
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
'proxyType': 'manual',
'httpProxy': 'http://my-proxy:8080'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
尝试通过以下方式首先运行测试: ng e2e
第二个:
Tried to ran tests first by: ng e2e
second by:
ng e2e --config ./protractor.conf.js --specs ./e2e\app.e2e-spec.ts
仍然出现此代理错误:
events.js:136
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND chromedriver.storage.googleapis.com chromedriver.storage.googleapis.com:443
at errnoException (dns.js:55:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:26)
推荐答案
ng e2e
将在后台执行 webdriver-manager启动/更新
,而 webdriver-管理员启动
将访问"chromedriver.storage.googleapis.com"以查询最新的webdriver二进制文件,您的错误来自此处.
ng e2e
will execute webdriver-manager start/update
in background, and webdriver-manager start
will access "chromedriver.storage.googleapis.com" to query latest webdriver binary, your error comes from here.
因为 ng e2e
无法接受来自cli或预配置文件的代理,这是为 webdriver-manager启动/更新
设置代理的唯一方法,code> ng e2e 是通过环境变量
来实现的.
Because ng e2e
can't accept proxy from cli or pre-configured file, the only way you can set proxy for webdriver-manager start/update
triggered by ng e2e
is by Environment Variable
.
添加以下3个环境变量:
Add below 3 Environment Variables:
HTTP_PROXY = http://my-proxy:port
HTTPS_PROXY = http://my-proxy:port
NO_PROXY = localhost,127.0.0.1, .yourcompany.com
在新的cmd窗口中尝试 ng e2e
(不要在旧的cmd窗口中尝试)
Try ng e2e
in new cmd window (don't try in old cmd window)
仅供参考,一旦添加了3个环境变量,就无需在执行 webdriver-manager start/update
时在cli中传递-proxy
.
FYI, once you add the 3 Environment Variables, you no need to pass --proxy
in cli when execute webdriver-manager start/update
.
这篇关于无法运行Angular>2 e2e在代理后面使用量角器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!