当试图在Docker上没有发射沙箱和无头时,Nightwatchjs忽略了镀铬选项
我在使用 chrome 在 docker 容器上运行 nightwatch 时遇到问题,nightwatch 似乎完全忽略了我告诉它使用 --no-sandbox 和 --headless 的事实
我的 nightwatch.conf.js 配置:
let localConfig = require('./nightwatch.local.conf');
module.exports = {
src_folders: ["tests"],
screenshots: {
enabled: true,
path: "screenshots"
},
webdriver: {
start_process: true,
server_path: 'node_modules/.bin/chromedriver',
port: 9195
},
test_settings: {
twlocal: localConfig,
twint:{
launch_url: "https://int.ecample.co.uk",
desiredCapabilities: {
browserName: "chrome",
acceptSslCerts: true,
acceptInsecureCerts: true
}
},
twstaging:{
launch_url: "https://staging.example.co.uk",
desiredCapabilities: {
browserName: "chrome",
acceptSslCerts: true,
acceptInsecureCerts: true,
chromeOptions:{
args:['no-sandbox','headless','disable-gpu']
}
}
},
twlive:{
launch_url: "https://example.co.uk",
desiredCapabilities: {
browserName: "chrome",
acceptSslCerts: true
}
}
}
};
TWSTAGING 配置我已经设置了 chromeOptions 参数,但它在容器上运行的命令是:
/usr/bin/google-chrome --allow-pre-commit-input --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging=stderr --ignore-certificate-errors --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.Zkxwkv
哪个产生了此错误:
不支持在没有 --no-sandbox 的情况下以 root 身份运行。
我不确定为什么它忽略这些论点?这只是正在运行:nightwatch --env twstaging
I am having an issue running nightwatch on a docker container using chrome, nightwatch seems to be completely ignoring the fact that i have told it to use --no-sandbox and --headless
My config for nightwatch.conf.js:
let localConfig = require('./nightwatch.local.conf');
module.exports = {
src_folders: ["tests"],
screenshots: {
enabled: true,
path: "screenshots"
},
webdriver: {
start_process: true,
server_path: 'node_modules/.bin/chromedriver',
port: 9195
},
test_settings: {
twlocal: localConfig,
twint:{
launch_url: "https://int.ecample.co.uk",
desiredCapabilities: {
browserName: "chrome",
acceptSslCerts: true,
acceptInsecureCerts: true
}
},
twstaging:{
launch_url: "https://staging.example.co.uk",
desiredCapabilities: {
browserName: "chrome",
acceptSslCerts: true,
acceptInsecureCerts: true,
chromeOptions:{
args:['no-sandbox','headless','disable-gpu']
}
}
},
twlive:{
launch_url: "https://example.co.uk",
desiredCapabilities: {
browserName: "chrome",
acceptSslCerts: true
}
}
}
};
The TWSTAGING config i have set the chromeOptions arguments but the command it's running on the container is:
/usr/bin/google-chrome --allow-pre-commit-input --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging=stderr --ignore-certificate-errors --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.Zkxwkv
Which is producing this error:
Running as root without --no-sandbox is not supported.
I'm not sure why it's ignoring the arguments? This is just running: nightwatch --env twstaging
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过将 goog 前缀添加到 chromeOptions 中,我已经复制了您的整个配置,但唯一的更改是在 twstaging 中。请注意冒号引起的引号的乐趣:
Have you tried adding the goog prefix to chromeOptions, I've copied your whole config but the only changes are in twstaging. Please note the fun with quotations due to the colon: