Main problem
I need to run chrome using docker. I have found docker images on github, using this I have tried to run chrome.
options = ChromeOptions()
os.system(f'docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" -e SCREEN_WIDTH={width} -e SCREEN_HEIGHT={height} --platform linux/amd64 selenium/standalone-chrome:latest')
while True:
try:
driver = webdriver.Remote('http://localhost:4444/wd/hub', options=options)
except (ProtocolError, RemoteDisconnected):
time.sleep(2)
continue
break
But it raise (docker exactly running, because past code on firefox worked)
selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
I've tried to set location to chrome but I don't seem to be able to find the correct location.
Also I've found similar error on stackoverflow, but "--headless", "--no-sandbox", "--disable-dev-shm-usage" options not works for me.
Previous problems
My target is to run selenium on docker to hide browser automation by resizing the screen. Also because of this I need to use a proxy. I have a socks5 proxy with authentication.
I have used firefox on docker, but it not works with socks5 authentication proxy. Although seleniumwire
was able to connect proxy to firefox, it didn't work on docker. Docker environment variables and firefox settings failed to connect it too.
Before that I tried to replace the values returned by window.screen.width
and window.screen.height
with JS, but I couldn't find a way to do it without docker.
So, if you know how to connect auth socks5 proxy to Firefox or simulate different screen resolution, this will help me.
Configuration
MacOS Ventura 13.2.1 on M1
Chrome 113.0.5672.63
Python 3.10