运行量角器测试时随机出现的 Failed: ECONNREFUSED connect ECONNREFUSED 127.0.0.1
我的量角器测试用例随机失败并显示以下错误消息:
My protractor test cases randomly fail with this error message:
失败:ECONNREFUSED 连接 ECONNREFUSED 127.0.0.1
Failed: ECONNREFUSED connect ECONNREFUSED 127.0.0.1
我浏览了资源并尝试了所有建议的解决方案:
I have gone through the resources and tried all the suggested solutions:
- 升级量角器
- 运行 webdriver-manager 更新
- 已升级 chromedriver 版本,但问题似乎存在.
当我尝试一起运行所有 e2e 测试时尤其会发生这种情况.
This particularly happens when I try to run all the e2e tests together.
以下是我用于我的项目的特定版本:
Below is the specific versions that Im using for my project:
- 节点 - v9.2.0
- 量角器 - 版本 5.4.1
- ChromeDriver 2.42.591088
请帮忙.
谢谢,尼拉加
您是否在测试中使用 async/await?
Are you using async/await in your tests?
您能否尝试通过执行node patch.js"从包含node_modules"文件夹的同一文件夹中应用以下指定的补丁?
Can you try applying patch as specified below from the same folder which contains the 'node_modules' folder by executing 'node patch.js'?
patch.js 文件
patch.js file
var fs = require('fs');
var httpIndexFile = 'node_modules/selenium-webdriver/http/index.js';
fs.readFile(httpIndexFile, 'utf8', function (err, data) {
if (err)
throw err;
var result = data.replace(/\(e.code === 'ECONNRESET'\)/g, "(e.code === 'ECONNRESET' || e.code === 'ECONNREFUSED')");
console.log(`Patching ${httpIndexFile}`)
fs.writeFileSync(httpIndexFile, result, 'utf8');});
var chromeFile = 'node_modules/selenium-webdriver/chrome.js';
fs.readFile(chromeFile, 'utf8', function (err, data) {
if (err)
throw err;
var result = data.replace(/new http.HttpClient\(url\)/g, "new http.HttpClient(url, new (require('http').Agent)({ keepAlive: true }))");
console.log(`Patching ${chromeFile}`)
fs.writeFileSync(chromeFile, result, 'utf8');});
请在此处查看原始帖子-https://github.com/angular/protractor/issues/4706#issuecomment-393004887
Please see original post here - https://github.com/angular/protractor/issues/4706#issuecomment-393004887