5 javascript selenium google-chrome docker
我想在我的 docker 容器中运行 selenium 和 headless chrome 以进行测试。
我尝试在无头chrome(在我的docker容器之外)中运行selenium,并在我的.js文件中使用以下内容。这有效:
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
})
Run Code Online (Sandbox Code Playgroud)
但我无法让它在我的 docker 容器中工作。在我的 docker 容器中,我使用“FROM selenium/standalone-chrome”。我的dockerfile似乎没有任何问题。当我尝试运行硒测试时出现问题。我将 .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
Run Code Online (Sandbox Code Playgroud)
我对此(和堆栈溢出)还很陌生,所以我可能错过了一些基本的东西。
尝试包括--no-sandbox
chromeOptions: {
args: ['--headless', '--disable-gpu', '--no-sandbox']
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6122 次 |
| 最近记录: |