I am experimenting with running Selenium and headless Chrome in a Docker container for testing purposes.
Previously, I successfully ran Selenium in headless Chrome outside of my Docker container using the code snippet below in my .js file:
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
})
However, I encountered issues when attempting to replicate this setup within my Docker container. I am using "FROM selenium/standalone-chrome" in my Dockerfile without any apparent problems. The challenge arises while trying to execute my Selenium tests within the container. Despite changing the binary_path in my .js file to /opt/google/chrome/google-chrome, the tests fail and the client initialization does not occur.
To troubleshoot, I attempted to directly run /opt/google/chrome/google-chrome to verify if Chrome is functioning within the container, but I received the following error:
[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
As someone new to this topic and seeking assistance on Stack Overflow, I acknowledge that there may be fundamental aspects that I have overlooked.