12

I have a brand-new out of the box Raspberry Pi 4 that I'd like to run python selenium on. However, I don't have the path to use for this command: any tips?

driver = webdriver.Chrome("path-to-chromiumdriver")

I am also happy to run it with Firefox if someone has the path for that!

Thanks, /yga

YGA
  • 9,546
  • 15
  • 47
  • 50

1 Answers1

33

Aha - looks like https://ivanderevianko.com/2020/01/selenium-chromedriver-for-raspberrypi has the answer!

sudo apt-get install chromium-chromedriver

And then in the python code:

from pyvirtualdisplay import Display

display = Display(visible=0, size=(1600, 1200))
display.start()
driver = webdriver.Chrome('/usr/lib/chromium-browser/chromedriver')

(I wanted to run a headless version; hence the pyvirtualdisplay)

YGA
  • 9,546
  • 15
  • 47
  • 50
  • 6
    For headless you don't need any display, just pass `--headless` option to `Chrome()` function in the `options` parameter. – Ruslan Oct 05 '21 at 12:40
  • 2
    it's interesting though because some sites block headless browsers, so it can a be way to get through the protection – Adriendod Jun 25 '22 at 16:12