Reputation: 11357
My setup:
pip install selenium
(3.3.1).brew install geckodriver
0.15.0Trying 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?
Upvotes: 0
Views: 9032
Reputation: 377
Use permissions according to your need
sudo chmod 777 /usr/local/opt/geckodriver
refer this link to understand permissions
https://www.freecodecamp.org/news/how-to-change-file-permissions-with-the-chmod-command-on-linux/
Upvotes: 0
Reputation: 11357
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).
Upvotes: 3