Search code examples
pythonseleniumselenium-webdriverselenium-chromedrivergeckodriver

TimeoutError: [WinError 10060] :


I am trying to connect to my firefox browser with selenium.

#Initialise Firefox
print("here")
locationofDriver = "C:/Users/barry/OneDrive/Documents/Webdriver/"
print("here2")
driver = webdriver.Firefox(locationofDriver)
print("here3")

Yet I get two errors:

TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

And:

urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))

The Output from the print statements:

here
here2

I launched Firefox manually to see if their was an issue, however it is perfectly functional The web-driver is in the correct place. enter image description here

Any help appreciated.


Solution

  • Instead providing only the location of the WebDriver executable you need to provide the absolute path of the ChromeDriver / GeckoDriver along with the extension i.e. .exe. So your effective code block will be:

    • For ChromeDriver:

      locationofDriver = r'C:/Users/barry/OneDrive/Documents/Webdriver/chromedriver.exe'
      
    • For GeckoDriver:

      locationofDriver = r'C:/Users/barry/OneDrive/Documents/Webdriver/geckodriver.exe'
      

    Finally, you can pass the key executable_pathalong the value as follows:

    driver = webdriver.Firefox(executable_path=locationofDriver)