vsts 托管代理 docker 容器 (ubuntu) - 无法 运行 守夜人测试(在端口 4444 上连接到 127.0.0.1 时出错
vsts hosted agent docker container (ubuntu) - unable to run nightwatch tests (Error connecting to 127.0.0.1 on port 4444
我正在尝试 运行 Azure 管道中的硒测试 运行 出错
CICD 管道正在使用 VSTS 托管代理并构建一个 Ubuntu docker 容器。
我的测试任务是 运行ning 在 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
中安装了正确的二进制文件
package.json chrome devdependancy 正在将 .exe 二进制文件拉入 Docker ubuntu(看起来它是 [=32= 的问题] 驱动 npm 包)
确保 linux chrome 也安装在 Docker Ubuntu
首先尝试在本地 Docker 容器上设置项目,然后进入 docker 容器进行调试(基本上 bash 到 Docker 容器并尝试 运行 那里的测试)。如果测试 运行 正确,它们很可能应该 运行 在管道中正确
我打算很快写一篇端到端的设置博客。完成后我会在这里更新。
我正在尝试 运行 Azure 管道中的硒测试 运行 出错 CICD 管道正在使用 VSTS 托管代理并构建一个 Ubuntu docker 容器。
我的测试任务是 运行ning 在 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
中安装了正确的二进制文件package.json chrome devdependancy 正在将 .exe 二进制文件拉入 Docker ubuntu(看起来它是 [=32= 的问题] 驱动 npm 包)
确保 linux chrome 也安装在 Docker Ubuntu
首先尝试在本地 Docker 容器上设置项目,然后进入 docker 容器进行调试(基本上 bash 到 Docker 容器并尝试 运行 那里的测试)。如果测试 运行 正确,它们很可能应该 运行 在管道中正确
我打算很快写一篇端到端的设置博客。完成后我会在这里更新。