2

I have set the path to a newly created Firefox profile in Ubuntu OS using python & Selenium. But when I run the python script I am getting an error

OSError: [Errno 13] Permission denied

I have changed the permissions on the file to 755 and I am still getting the error and also tried sudo.

sudo chmod 775 /home/student/.mozilla/firefox/gwi6uqpe.Default\ User2/

This is the start of my python script:-

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.by import By
import sys, time
import time

binary = FirefoxBinary('/home/student/.mozilla/firefox/gwi6uqpe.Default User2')
browser = webdriver.Firefox(firefox_binary=binary)

And this is the error message.

Traceback (most recent call last):

File "default2.py", line 9, in browser = webdriver.Firefox(firefox_binary=binary) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 78, in init self.binary, timeout) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in init self.binary.launch_browser(self.profile, timeout=timeout) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 67, in launch_browser self._start_from_profile_path(self.profile.path) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 90, in _start_from_profile_path env=self._firefox_env) File "/usr/lib/python2.7/subprocess.py", line 710, in init errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child raise child_exception OSError: [Errno 13] Permission denied

How do I get around this, please.

2 Answers 2

3

On my machine, ~/.mozilla/firefox and it's subdirectories have user:usergroup 700 permissions. Is your script being executed by the student user? Otherwise, it will get permission denied. As an experiment, you could try giving .mozilla/firefox and .mozilla/firefox/profiles 766 permissions. I wouldn't run a production environment like that, but you could make a group with permissions and add your other user to that group.

EDIT: FirefoxBinary is not what to use for specifying a profile. Use FirefoxProfile instead:

profile = FirefoxProfile('/home/student/.mozilla/firefox/gwi6uqpe.Default')
browser = webdriver.Firefox(firefox_profile=profile)
Sign up to request clarification or add additional context in comments.

3 Comments

Yes script is being used by student user. I have tried giving 766 permissions as suggested but I am still getting the same error. Thanks.
I have checked user permissions on files and folder and all have rwx (read write execute)
Thanks for your help. Works Perfectly.
0
   baseurl = "https://www.google.co.in/"
   driver = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')
   driver.maximize_window()
   driver.get(baseurl)

1 Comment

Can you please provide an explanation as to why this will work to help the author understand your solution better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.