Search code examples
pythonseleniumselenium-webdriverpermissionspermission-denied

Selenium using Python: Permission Denied to Launch Webdriver


I'm a Python beginner and trying to use selenium to automate a web browsing process. Unfortunately, my attempts are not as smooth as I'd like them to be; for whatever reason, the command line is returning an error saying "permission denied" when I run the following code:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\Program Files (x86)\Mozilla Firefox')
browser = webdriver.Firefox(firefox_binary=binary)

print(type(browser))

I've tried to read previous posts on this topic- specifically this one and that one- but each to no avail. Either the compiler returns "permission denied," or in the case of adding firefox.exe to the end of the path, "entity not found."

I appreciate any help you could give me. If you could explain any help like you would to an 8-year old, it'd be particularly helpful- I'm still a novice to this stuff.

Edited to add: if it helps provide any context, I'm using Windows 10 and running Python on Visual Studio Community. I've also thought about using the sudo command for permission, but I'm not exactly sure how I'd do that from Visual Studio.


Solution

  • Try adding Firefox.exe instead of firefox.exe to your path.

    I've also had this issue before and it has worked for me, though I'm not exactly sure why.