gpt4 book ai didi

automation - 我的 nightwatch.js 测试无法在 CentOS 的 headless Chrome 中运行

转载 作者:太空宇宙 更新时间:2023-11-03 17:14:20 34 4
gpt4 key购买 nike

我使用 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 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)'
],
}

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 二进制文件的新路径。我还必须在 chromeOptions.args 中包含“no-sandbox”。

这是上述网站的摘录:

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:

关于automation - 我的 nightwatch.js 测试无法在 CentOS 的 headless Chrome 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54511523/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com