我的 nightwatch.js 测试无法在 CentOS 的 Chrome headless 中运行
My nightwatch.js tests not runs in Chrome headless of CentOS
我 运行 nightwatch.js 使用 Nightwatch 版本 1.0.18 进行测试并且它在 windows 环境中工作但是当我在安装 Xvfb 后 运行 它在 centOS 中我发现低于错误。
Error while running .navigateTo() protocol action: invalid session id
Error while running .locateMultipleElements() protocol action: invalid session id
Error while running .locateMultipleElements() protocol action: invalid session id
这是我的nightwatch.js文件代码:
{
"src_folders": [
"./tests"
],
"output_folder": "./reports",
"custom_commands_path": "./custom_commands",
"custom_assertions_path": "",
"test_workers": false,
"webdriver": {
"start_process": true
},
"test_settings": {
"default": {
"webdriver": {
"port": 9515,
"server_path": "./node_modules/chromedriver/lib/chromedriver/chromedriver",
"cli_args": [
"--log",
"debug"
]
},
"skip_testcases_on_fail": true,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": [
"headless",
"no-sandbox",
"disable-gpu"
]
}
}
}
}
}
我在 centOS 环境中 运行 我的测试是否遗漏了什么,因为它在 windows 环境中 运行ning?
我在 Nightwatchjs 和 npm chomedriver 设置方面遇到了同样的问题。
背景:
一切正常,直到我最近更新了系统上的 Chromium。除了原来的错误post,verbose logging还显示:
{
message: 'unknown error: Chrome failed to start: exited abnormally',
error: [
"(unknown error: DevToolsActivePort file doesn't exist)",
'(The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)',
'(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.9.0-8-amd64 x86_64)'
],
}
在 downloading the standalone chromedriver (2.46.628388) 匹配我的 Chromium 版本 (72.0.3626.69) 之后,它仍然显示相同的错误。
解法:
我最终 downloading an older version of Chromium (71.0.3578.127) 并将 chromeOptions.binary 设置为 chromium 71 二进制文件的新路径。我还必须包括 'no-sandbox' 和 chromeOptions.args。
以下是上述网站的摘录:
Downloading old builds of Chrome / Chromium
Let's say you want a build of Chrome 44 for debugging purposes. Google does not offer old builds as they do not have up-to-date security fixes.
However, you can get a build of Chromium 44.x which should mostly match the stable release. Here's how you find it:
- Look in https://googlechromereleases.blogspot.com/search/label/Stable%20updates for the last time "44." was mentioned.
- Loop up that version history ("44.0.2403.157") in the Position Lookup
- In this case it returns a base position of "330231". This is the commit of where the 44 release was branched, back in May 2015.*
- Open the continuous builds archive
- Click through on your platform (Linux/Mac/Win)
- Paste "330231" into the filter field at the top and wait for all the results to XHR in.
- Eventually I get a perfect hit: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/330231/
- Sometimes you may have to decrement the commit number until you find one.
- Download and run!
升级到最新版本的 chromedriver 为我解决了这个问题。你可以在这里找到最新版本; https://www.npmjs.com/package/chromedriver
在我的情况下,发生该错误时:
Error while running .navigateTo() protocol action: invalid session id
我在 .travis.yml
中添加了以下代码:
addons:
chrome: stable
我 运行 nightwatch.js 使用 Nightwatch 版本 1.0.18 进行测试并且它在 windows 环境中工作但是当我在安装 Xvfb 后 运行 它在 centOS 中我发现低于错误。
Error while running .navigateTo() protocol action: invalid session id
Error while running .locateMultipleElements() protocol action: invalid session id
Error while running .locateMultipleElements() protocol action: invalid session id
这是我的nightwatch.js文件代码:
{
"src_folders": [
"./tests"
],
"output_folder": "./reports",
"custom_commands_path": "./custom_commands",
"custom_assertions_path": "",
"test_workers": false,
"webdriver": {
"start_process": true
},
"test_settings": {
"default": {
"webdriver": {
"port": 9515,
"server_path": "./node_modules/chromedriver/lib/chromedriver/chromedriver",
"cli_args": [
"--log",
"debug"
]
},
"skip_testcases_on_fail": true,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": [
"headless",
"no-sandbox",
"disable-gpu"
]
}
}
}
}
}
我在 centOS 环境中 运行 我的测试是否遗漏了什么,因为它在 windows 环境中 运行ning?
我在 Nightwatchjs 和 npm chomedriver 设置方面遇到了同样的问题。
背景: 一切正常,直到我最近更新了系统上的 Chromium。除了原来的错误post,verbose logging还显示:
{
message: 'unknown error: Chrome failed to start: exited abnormally',
error: [
"(unknown error: DevToolsActivePort file doesn't exist)",
'(The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)',
'(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.9.0-8-amd64 x86_64)'
],
}
在 downloading the standalone chromedriver (2.46.628388) 匹配我的 Chromium 版本 (72.0.3626.69) 之后,它仍然显示相同的错误。
解法: 我最终 downloading an older version of Chromium (71.0.3578.127) 并将 chromeOptions.binary 设置为 chromium 71 二进制文件的新路径。我还必须包括 'no-sandbox' 和 chromeOptions.args。
以下是上述网站的摘录:
Downloading old builds of Chrome / Chromium
Let's say you want a build of Chrome 44 for debugging purposes. Google does not offer old builds as they do not have up-to-date security fixes.
However, you can get a build of Chromium 44.x which should mostly match the stable release. Here's how you find it:
- Look in https://googlechromereleases.blogspot.com/search/label/Stable%20updates for the last time "44." was mentioned.
- Loop up that version history ("44.0.2403.157") in the Position Lookup
- In this case it returns a base position of "330231". This is the commit of where the 44 release was branched, back in May 2015.*
- Open the continuous builds archive
- Click through on your platform (Linux/Mac/Win)
- Paste "330231" into the filter field at the top and wait for all the results to XHR in.
- Eventually I get a perfect hit: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/330231/
- Sometimes you may have to decrement the commit number until you find one.
- Download and run!
升级到最新版本的 chromedriver 为我解决了这个问题。你可以在这里找到最新版本; https://www.npmjs.com/package/chromedriver
在我的情况下,发生该错误时:
Error while running .navigateTo() protocol action: invalid session id
我在 .travis.yml
中添加了以下代码:
addons:
chrome: stable