8

I would like to set up the Raspberry Pi as a client that exclusively runs FireFox as a client in a Selenium grid.

Has anyone tried and got this to work?

Are there any tips or pitfalls that I will need to be aware of?

techraf
  • 4,254
  • 10
  • 29
  • 41
Bruce McLeod
  • 189
  • 1
  • 2
  • 5

3 Answers3

7

You either need to have enable X or better you can run Selenium webdriver on Raspberry Pi in headless mode with xvfb. For this you need the following:

Install required APT packages:

sudo apt-get update
sudo apt-get install iceweasel
sudo apt-get install xvfb

Install required pip packages:

sudo pip install selenium
sudo pip install PyVirtualDisplay
sudo pip install xvfbwrapper

Install geckodriver:

wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-arm7hf.tar.gz
tar -xvzf geckodriver*
chmod +x geckodriver
sudo mv geckodriver /usr/local/bin/

Then start with the following minimal Python:

from pyvirtualdisplay import Display
from selenium import webdriver

display = Display(visible=0, size=(1024, 768))
display.start()

driver = webdriver.Firefox()
driver.get('http://raspberrypi.stackexchange.com/')
driver.quit()

display.stop()
techraf
  • 4,254
  • 10
  • 29
  • 41
  • I also needed to download the appropriate geckodriver for my Firefox version (https://github.com/mozilla/geckodriver/releases/download/v0.17.0/geckodriver-v0.17.0-arm7hf.tar.gz) and add to the system path – Tahlor Dec 16 '18 at 04:43
5

I got Raspberry and Selenium working using

Python, Selenium Firefox driver, and Iceweasel

so if you sudo apt-get install iceweasel, then you have a firefox-based browser that will work with the Selenium firefox driver.

Would this help you?

user985366
  • 151
  • 1
  • 2
  • Forgive my ignorance... It is 2019, does this still hold true? –  Mar 29 '19 at 12:57
  • @jww I don't know, haven't tried it since 2014. But I can't come up with a reason why it would not still work. Can you? – user985366 Mar 29 '19 at 13:29
1

Following on from @Techraf you need to install the geckodriver.

Here is the latest version supported for Rasp Pi:

https://github.com/mozilla/geckodriver/releases/tag/v0.23.0

Download geckodriver-v0.23.0-arm7hf.tar.gz

This is the latest release supporting arm7hf, which I believe is required for Selenium on Rasp Pi.

You need to inform your script to load the geckodriver. Like so

from selenium import webdriver

driver = webdriver.Firefox(executable_path = '/home/pi/Downloads/geckodriver')
driver.get('http://raspberrypi.stackexchange.com/')
Ollie
  • 11
  • 2