wheedwhackerjones
wheedwhackerjones

Reputation: 39

Selenium - Failed to Establish New Connection

I'm following this tutorial and pasted the exact code from the video: https://www.youtube.com/watch?v=b5jt2bhSeXs

from selenium import webdriver

PATH = "/home/matt/learnselenium/chromedriver"
driver = webdriver.Chrome(PATH)

driver.get("https://techwithtim.net")
print(driver.title)
driver.quit()

search = driver.find_element_by_name("s")
search.send_keys("test")
search.send_keys(Keys.RETURN)

time.sleep(5)

driver.quit()

And I get the following error:

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=54375): Max retries exceeded with url: /session/efc07a083600a61c9bc65e262061dd37/element (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f254da226a0>: Failed to establish a new connection: [Errno 111] Connection refused'))

I verified Chrome (94) and the Chrome driver are the same version I have ./chromedriver running

Thanks in advance

Upvotes: 0

Views: 3102

Answers (1)

Kamalesh S
Kamalesh S

Reputation: 550

Remove the driver.quit() line after print(driver.title). You are closing the driver before complete execution.

Upvotes: 2

Related Questions