Reputation: 329
I wrote a selenium script that works works fine when I launch it using cmd.
I would like now to execute the script in a docker so that it can easily be launched from any machine in one click.
I wrote a Dockerfile using the base image FROM selenium/standalone-chrome-debug
I changed my script like this :
driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", DesiredCapabilities.CHROME)
driver.maximize_window()
driver.get("www.google.com")
But when I launch it, I have the following error :
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd11b9e3b90>: Failed to establish a new connection: [Errno 111] Connection refused',))
I'm new to docker and selenium so I may have forgot something.
Upvotes: 1
Views: 1392
Reputation: 17593
You are passing local IP and local port number
http://127.0.0.1:4444 - your IP is local and local port
You need to identify your selenium hub docker ip
and port
on which hub running on same VM and update your below line:
driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", DesiredCapabilities.CHROME)
Upvotes: 3