![](/img/trans.png)
[英]Not able to run intern functional tests. Error: [POST http://localhost:4444/wd/hub/session] connect ECONNREFUSED
[英]vsts hosted agent docker container (ubuntu) - unable to run nightwatch tests (Error connecting to 127.0.0.1 on port 4444
I am trying to run selenium tests in azure pipeline and running into errors The CICD pipeline is using VSTS hosted agent and building a Ubuntu docker container.
我的测试任务在 Docker 容器镜像构建并抛出以下错误之后运行。 不知道我错过了什么。
在我的 windows 机器上进行测试。
如果需要任何进一步的信息,请告诉我
任何好的夜表 docker 项目在那里请把它扔在这里。
2020-04-22T10:53:24.0632804Z - Connecting to 127.0.0.1 on port 4444...
2020-04-22T10:53:24.0633097Z
2020-04-22T10:53:24.0633309Z Response 500 POST /wd/hub/session (20137ms)
2020-04-22T10:53:24.0633973Z ⚠ Error connecting to 127.0.0.1 on port 4444.
2020-04-22T10:53:24.0634476Z Error: An error occurred while retrieving a new session: "Timed out waiting for driver server to start."
2020-04-22T10:53:24.0635002Z at endReadableNT (_stream_readable.js:1187:12)
2020-04-22T10:53:24.0635520Z at processTicksAndRejections (internal/process/task_queues.js:84:21)
2020-04-22T10:53:24.0636178Z Cannot write log file to /vsts/agent/_work/r2/a/_QA_IDLookUp/output/logs/selenium-server.log.
2020-04-22T10:53:24.0636541Z npm ERR! Test failed. See above for more details.
2020-04-22T10:53:24.0637274Z
2020-04-22T10:53:24.0638871Z > qa-idlookup@1.0.0 test /vsts/agent/_work/r2/a/_QA_IDLookUp
2020-04-22T10:53:24.0639529Z > nightwatch -e headlessChrome
2020-04-22T10:53:24.0639818Z
2020-04-22T10:53:24.0639982Z
2020-04-22T10:53:24.0640105Z
2020-04-22T10:53:24.0640412Z [Specs/Inquire Driver] Test Suite
2020-04-22T10:53:24.0640807Z =================================
2020-04-22T10:53:24.0641034Z {
2020-04-22T10:53:24.0641217Z value: {
2020-04-22T10:53:24.0641411Z error: [
2020-04-22T10:53:24.0642113Z "Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'",
2020-04-22T10:53:24.0643143Z "System info: host: '15e4d52e2df2', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.0.0-1031-azure', java.version: '1.8.0_241'",
2020-04-22T10:53:24.0644010Z 'Driver info: driver.version: unknown'
2020-04-22T10:53:24.0644276Z ],
2020-04-22T10:53:24.0645537Z message: 'Timed out waiting for driver server to start.'
2020-04-22T10:53:24.0645906Z },
2020-04-22T10:53:24.0646113Z status: 13
2020-04-22T10:53:24.0646394Z }
package.json:
{
"name": "qa-idlookup",
"version": "1.0.0",
"description": "NightwatchJS with Selenium Server",
"main": "index.js",
"scripts": {
"test": "nightwatch -e headlessChrome",
"headless": "nightwatch -e headlessChrome",
"chrome": "nightwatch -e chrome",
"firefox": "nightwatch -e firefox",
"edge": "nightwatch -e edge",
"ie": "nightwatch -e ie",
"all": "nightwatch -e headlessChrome,chrome,firefox,edge,ie",
"update": "npx npm-check-updates -u && npm install"
},
"keywords": [
"Nightwatch",
"NightwatchJS",
"Selenium"
],
"author": "Raju",
"license": "ISC",
"devDependencies": {
"chromedriver": "80.0.2",
"easy-soap-request": "^3.2.2",
"edgedriver": "^4.17134.1",
"geckodriver": "^1.19.1",
"iedriver": "^3.14.2",
"nightwatch": "^1.3.4",
"selenium-server": "^3.141.59",
"xmldom": "^0.3.0"
}
}
nightwatch.conf.js
const seleniumServer = require('selenium-server');
const chromeDriver = require('chromedriver');
const geckoDriver = require('geckodriver');
const ieDriver = require('iedriver');
const edgeDriver = require('edgedriver');
module.exports = {
src_folders: ['src'],
output_folder: 'output/reports',
custom_commands_path: '',
custom_assertions_path: '',
page_objects_path: '',
globals_path: '',
live_output: false,
disable_colors: false,
parallel_process_delay: 10,
"test_workers": {
"enabled": false,
"workers": "auto"
},
selenium: {
start_process: true,
start_session: false,
server_path: seleniumServer.path,
check_process_delay: 5000,
log_path: 'output/logs',
host: '127.0.0.1',
port: 4444,
cli_args: {
"webdriver.chrome.driver": chromeDriver.path,
"webdriver.gecko.driver": geckoDriver.path,
"webdriver.ie.driver": ieDriver.path,
"webdriver.edge.driver": edgeDriver.path
}
},
test_settings: {
skip_testcases_on_fail: false,
end_session_on_fail: false,
default: {
"request_timeout_options": {
"timeout": 10000
},
"screenshots": {
"enabled": true,
"on_failure": true,
"on_error": false,
"path": "output/screenshots"
},
desiredCapabilities: {
browserName: 'chrome',
}
},
headlessChrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
w3c: false,
args: ['headless', 'disable-gpu']
}
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
w3c: false,
args: ['disable-gpu']
}
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true,
marionette: true
}
},
edge: {
desiredCapabilities: {
browserName: 'MicrosoftEdge',
javascriptEnabled: true,
}
},
ie: {
desiredCapabilities: {
browserName: 'internet explorer',
javascriptEnabled: true,
}
}
}
};
自己为这个问题找到了解决方案。 对于曾经尝试相同的人,
请确保在 Docker Ubuntu 中安装了正确的二进制文件
The package.json chrome devdependancy is pulling.exe binary into the Docker ubuntu (looks like its an issue with chrome driver npm package)
确保 Docker Ubuntu 上也安装了稳定的 linux 镀铬
Try to setup the project on a local Docker container first and get inside the docker container to debug it (Basically bash into the Docker container and try to run the tests there). 如果测试在那里正常运行,它们很可能应该在管道中正确运行
我计划很快写一个端到端的设置博客。 完成后我会在这里更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.