1

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.

1
  • did you puplish the port 4444 , in your docker run command Commented Sep 17, 2019 at 9:43

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, for the response, I managed to make it work and indeed I was missing the selenium hub step

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.