1

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.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Lyra Orwell
  • 1,048
  • 4
  • 17
  • 46

2 Answers2

1

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)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

try it:

locationofDriver = "<path to file>/geckodriver.exe"

Or add geckodriver.exe to directory with working python file and then you can try:

driver = webdriver.Firefox()
dimay
  • 2,768
  • 1
  • 13
  • 22
  • I get the error NotADirectoryError: [WinError 267] The directory name is invalid: 'C:/Users/barry/OneDrive/Documents/Webdriver/geckodriver.exe' – Lyra Orwell Aug 08 '20 at 08:05
  • Check your path to `geckodriver.exe`. You must write correct path to this file. Try add `geckodriver.exe` to directory with working python file. – dimay Aug 08 '20 at 08:10