0

I want to run selenium on a raspberry pi 4 but I'm unable to get it work. I have installed the following files:

  1. Selenium (3.141.0)
  2. PyVirtualDisplay 0.2.5)
  3. Geckodriver (geckodriver-v0.26.0-linux32.tar.gz)

Running the following code (via Pycharm - Python 3.7):

from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))

driver = webdriver.Firefox(executable_path='/home/pi/driver_folder')
driver.get('https://www.google.com')
print(driver.page_source)
driver.close()
display.stop()

Gives me the following error, which indicates that Geckodriver doesn't have the right premissions. How can I solve that?

Traceback (most recent call last):
  File "/home/pi/PycharmProjects/python_anywhere/venv/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/home/pi/driver_folder'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/.PyCharmCE2019.3/config/scratches/scratch.py", line 19, in <module>
    driver = webdriver.Firefox(executable_path='/home/pi/driver_folder')
  File "/home/pi/PycharmProjects/python_anywhere/venv/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
    self.service.start()
  File "/home/pi/PycharmProjects/python_anywhere/venv/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 88, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'driver_folder' executable may have wrong permissions. 

Process finished with exit code 1
furas
  • 134,197
  • 12
  • 106
  • 148
Oamriotn
  • 257
  • 1
  • 3
  • 8

0 Answers0