8

This is an extension from a previous post which I could not get to work, but I am now getting a new error after updating Selenium.

I am using Python 3.5, Windows 8.1, and Selenium 3.0.1.

I know the code works because it works on my Mac, but when I bring it over to my work computer which is described above, the only thing that happens is the browser will open, but it won't load anything, not even a homepage.

From everything I could find on search I downloaded the geckodriver, renamed it to wires.exe, and I added the directory to the system PATH environment variable.

Sys

I am completely lost on what to do to get this to work. Here is the code I'm using:

from selenium import webdriver

driver = webdriver.Firefox()

driver.get('https://www.google.com')

Here are the errors I am getting:

Errors

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Senor Penguin
  • 365
  • 1
  • 3
  • 16
  • 1
    Both image links are broken. – Peter Mortensen Dec 08 '20 at 15:27
  • Duplicate of [Selenium using Python - Geckodriver executable needs to be in PATH](https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path). Also extensive answer [here](/a/38676858) – cachius May 21 '22 at 22:31

5 Answers5

18

I did not add geckodriver to PATH (it is located in the same directory as Python script), and after the Selenium update to 3.0.1, use this code to start a Selenium session:

gecko = os.path.normpath(os.path.join(os.path.dirname(__file__), 'geckodriver'))
binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path=gecko+'.exe')

Additionally: you need update geckodriver to the latest version, 0.11.1.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Andrew
  • 690
  • 1
  • 6
  • 9
  • Thank you so much! I will have to try this Monday when I get back to work. This looks like a lot of things I read searching but I couldn't figure out how to put it all together. I did download the gecko driver version 0.11.1 but where do I put the .exe file? – Senor Penguin Oct 22 '16 at 02:39
  • 1
    In the directory, where your Python script is located. Or in any other, but in this case you need to modify first line of my code which calculates absolute path (from the current) to geckodriver (without extension) – Andrew Oct 22 '16 at 08:26
3

I got the same problem with my Ubuntu 20.10 (Groovy Gorilla) installation and fixed it with the terminal using this line:

sudo apt-get install firefox-geckodriver

You can do the same with a macOS machine:

brew install geckodriver
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
reee
  • 78
  • 6
0

You need to set full path to executable geckodriver as mentioned below:

self.driver = webdriver.Firefox(executable_path = 'D:\Selenium_RiponAlWasim\geckodriver-v0.18.0-win64\geckodriver.exe')

Download geckodriver for you suitable OS → extract it in a folder of your choice → set the path correctly.

I'm using Python 3.6.2 and Selenium WebDriver 3.4.3.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Ripon Al Wasim
  • 35,466
  • 40
  • 150
  • 172
  • 1
    Be careful about space in the folder. Don't use any space creating folder such as "Do not Use". This folder name should be without space as "DonotUse" or You can use underscore (_) – Ripon Al Wasim Jul 21 '17 at 13:27
0

For Windows 10, download gechodriver. And extract it on like below. Customize it for yourself. My username is yasin in Windows 10.

C:\Users\yasin\AppData\Local\Programs\Python\Python37\Scripts
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
yasin lachini
  • 3,936
  • 3
  • 23
  • 48
0

For Mac users: This problem (as well as the Notarization issues with geckodriver) can be avoided by installing the software via Homebrew.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
altabq
  • 1,232
  • 1
  • 18
  • 31