0

My setup:

  • MacOS 10.12.3 virtual env.
  • I've installed selenium via pip install selenium (3.3.1).
  • I've installed geckodriver via brew install geckodriver 0.15.0

Trying to run the following code in intelliJ IDE:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox(executable_path='/usr/local/opt/geckodriver')
driver.get("https://google.com")
elem = driver.find_element_by_name("q")

and Exception is thrown from the 4th line (driver = webdriver...):

Traceback (most recent call last):
  File "/Users/itayb/test/main.py", line 4, in <module>
    driver = webdriver.Firefox(executable_path='/usr/local/opt/geckodriver')
  File "/Users/itayb/test/venv/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 145, in __init__
    self.service.start()
  File "/Users/itayb/test/venv/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 86, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable may have wrong permissions. 


Process finished with exit code 1

must say that the executable_path was added after trying to see some answers here in SO. The bin file (geckodriver is excute from command line without any problem). How do I fix that?

Community
  • 1
  • 1
ItayB
  • 8,442
  • 9
  • 49
  • 67

1 Answers1

3

I've changed the path of:

driver = webdriver.Firefox(executable_path='/usr/local/opt/geckodriver')

to

driver = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')

(and installed Firefox browser, but I'm not sure if related).

ItayB
  • 8,442
  • 9
  • 49
  • 67