我想在我的 docker 容器中运行 selenium 和 headless chrome 以进行测试。
我尝试在 .js 文件中使用以下内容在 headless chrome(在我的 docker 容器外)中运行 selenium。这有效:
const client = webdriverio.remote({
desiredCapabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--headless', '--disable-gpu']
},
binary: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
},
baseUrl: CONFIG.host,
logLevel: 'verbose',
waitForTimeout: 3000
})
但我无法让它在我的 docker 容器中工作。在我的 docker 容器中,我使用“FROM selenium/standalone-chrome”。我的 dockerfile 似乎没有任何问题。当我尝试运行 selenium 测试时出现问题。我将 .js 文件中的 binary_path 更改为/opt/google/chrome/google-chrome。但是测试失败,甚至无法启动客户端。
所以我尝试只运行/opt/google/chrome/google-chrome 以查看 chrome 是否工作,但随后出现此错误:
[0711/005304.226472:ERROR:nacl_helper_linux.cc(311)] NaCl helper
process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
我对此(和堆栈溢出)很陌生,所以我可能错过了一些基本的东西。
最佳答案
尝试包含--no-sandbox
chromeOptions: {
args: ['--headless', '--disable-gpu', '--no-sandbox']
},
正如我在 docker-selenium 所做的那样
关于javascript - docker/ Selenium / headless Chrome : Configure SUID sandbox correctly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45025628/