Python Selenium Webdriver Browser browser failed to start: permission denied

I want to run firefox web-editor with selenium so that I can save login with requests in a search robot. I got this idea from this solution, because the login with requests does not work for several reasons. I always get an error that the browser could not be started because permission was denied. Here is my code:

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

binary=FirefoxBinary("/path/to/firefox")
fp=webdriver.FirefoxProfile("path/to/extra/profile")


url="www.python.org"
driver = webdriver.Firefox(fp,  firefox_binary=binary, executable_path="path/to/geckodriver.exe")
driver.get(url)

The error is as follows:

selenium.common.exceptions.WebDriverException: Message: Failed to start browser:
permission denied

Can anybody help? I searched for years on the Internet but can't find anything ... Thanks !!!

+6
source share
4 answers

Selenium 3 Firefox . geckodriver , , . , , firefox.exe .

script:

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

binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary)

driver.get('http://www.google.com')

, .

+10

Mac OS X Firefox, Firefox.app. , .

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('/Users/YOUR_USERNAME/Applications/Firefox.app/Contents/MacOS/firefox-bin')
driver = webdriver.Firefox(firefox_binary=binary)
+2

Just use a double slash in the path on Windows:

binary = FirefoxBinary(r'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe')
+1
source

On Windows 10 with Selenium 3.14.1, the code below worked for me.

binary = FirefoxBinary(r'C:\\Program Files\\Mozilla Firefox\\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, 
executable_path='C:\\Tools\\Selenium\\geckodriver.exe')
driver.get("https://www.python.org")

Hope this helps ..

0
source

Source: https://habr.com/ru/post/1658330/


All Articles