Automation My nightwatch.js测试无法在Chrome headless of CentOS中运行
我使用nightwatch 1.0.18版运行nightwatch.js测试,它在windows环境下工作,但在安装Xvfb后在centOS中运行它时,我发现以下错误Automation My nightwatch.js测试无法在Chrome headless of CentOS中运行,automation,centos,nightwatch.js,google-chrome-headless,Automation,Centos,Nightwatch.js,Google Chrome Headless,我使用nightwatch 1.0.18版运行nightwatch.js测试,它在windows环境下工作,但在安装Xvfb后在centOS中运行它时,我发现以下错误 Error while running .navigateTo() protocol action: invalid session id Error while running .locateMultipleElements() protocol action: invalid session id Error whi
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.json文件代码:
{
"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环境中运行而遗漏了一些内容 我对Nightwatchjs和npm chomedriver的设置也有同样的问题 背景: 直到我最近更新了系统上的Chromium,一切都正常。除了原始帖子中的错误,详细日志还显示:
{
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)'
],
}
在(2.46.628388)匹配我的Chromium版本(72.0.3626.69)之后,它仍然显示相同的错误
解决方案:
我最终(71.0.3578.127)将chromeOptions.binary设置为chromeo71二进制文件的新路径。我还必须在chromeOptions.args中包含“无沙盒”
以下是上述网站的片段:
下载Chrome/Chrome的旧版本
假设你想要一个Chrome44的版本来进行调试。谷歌不提供旧版本,因为它们没有最新的安全补丁
然而,您可以得到Chromium 44.x的构建,它应该与稳定版本相匹配。以下是您如何找到它的:
- 最后一次提到“44”是什么时候
- 在位置查找中循环该版本历史记录(“44.0.2403.157”)
- 在这种情况下,它返回一个基准位置“330231”。这是在2015年5月发布44版本的地方提交的*
- 打开“连续生成”存档
- 点击您的平台(Linux/Mac/Win)
- 将“330231”粘贴到顶部的过滤器字段中,等待所有结果显示出来李>
- 最终我得到了完美的一击:
- 有时,您可能必须减少提交数,直到找到一个为止
- 下载并运行李>
升级到chromedriver的最新版本为我解决了这个问题。你可以在这里找到最新版本 在我的情况下,当错误发生时:
Error while running .navigateTo() protocol action: invalid session id
我在.travis.yml
中添加了以下代码:
addons:
chrome: stable
这里相同,配置不同,但错误相同,特别是“运行时出错。navigateTo()协议操作:无效会话id”`我更幸运地得到了
chromedriver
作为独立模块而不是节点模块运行,请让我知道您是否希望我一步一步地发布。我也这样做了,尽管我刚刚下载了google chrome(v.73)和chromedriver 2.46。尽管它们应该是兼容的,但我仍然有这个问题。解决方案是在chromeOptions参数中添加无沙箱
!