Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied: 'geckodriver.log' while running selenium webdriver in python

I've installed Firefox and Selenium on centos. I'm using Xvfb and pyvirtualdisplay to open the browser.

When I try to run selenium webdriver, I'm able to open a new display but as soon as I do

browser = webdriver.Firefox()

I get the error:

File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 134, in __init__
    self.service = Service(executable_path, log_path=log_path)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/service.py", line 45, in __init__
    log_file = open(log_path, "a+")
IOError: [Errno 13] Permission denied: 'geckodriver.log'

Any clues on what's going wrong here?

EDIT : After overcoming the permission error, I'm getting

Message: 'geckodriver' executable needs to be in PATH

like image 641
Pravesh Jain Avatar asked Nov 07 '16 13:11

Pravesh Jain


2 Answers

I had this same issue recently on a Windows 10 workstation. I fixed it by explicitly setting the service_log_path to a location I know I've got write access to:

browser = webdriver.Firefox( service_log_path="C:\\Users\\[username]\\AppData\\Local\\Temp\\geckodriver.log" )

like image 94
father_goose Avatar answered Sep 17 '22 13:09

father_goose


I had this exact same error.

[Errno 13] Permission denied: 'geckodriver.log'

The problem was not at all with this .log file.
The real problem was that my script (.py file) and the geckodriver.exe were not located in the same folder.
Once I put them in the same folder, the problem was solved and the function was executed normally.

browser = webdriver.Firefox()

Hope this helps.

like image 36
Dana Georgescu Avatar answered Sep 18 '22 13:09

Dana Georgescu