Search code examples
seleniumfirefoxweb-scrapingraspberry-pigeckodriver

Are Geckodriver and Firefox compatible on Raspberry Pi 3?


I am trying to install a small program that does webscraping on my Raspberry Pi 3.

The program works fine in my laptop with Ubuntu 16.04. I understand that the reason why it doesn’t work on my Raspberry Pi 3 is related to a compatibility issue between Geckodriver and Firefox-ESR. I am using the latest version for both.

Is there a repository version combination of Geckodriver and Firefox that would work?

Is there an alternative combination of browser and webdriver that would work to do webscraping with selenium on a Raspberry Pi 3?

Thanks A LOT for your feedback!.

Environment

  • Operating System: Raspbian GNU/Linux 9 (stretch) Kernel: Linux 4.9.59-v7+
  • ARMv7 Processor rev 4 (v7l)
  • Python 2.7.13
  • Selenium 3.10.0
  • Firefox ESR 52.6.0 (32-bit)
  • Geckodriver 0.19.1

Input

import os
import sys
import time
import selenium

# The BeautifulSoup module
from bs4 import BeautifulSoup

# The selenium module
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

# Using Firefox normally (browser pops up)
driver = webdriver.Firefox() 

at that point Firefox window opens and remains blank. After a while python gives the output below in console

Output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 162, in __init__
    keep_alive=True)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: connection refused

Solution

  • Following my question above, I started to install previous geckodriver versions, with the hope to find one that would be compatible with Firefox ESR 52.6.0 (32-bit).

    To my surprise, geckodriver 0.16.1 works well with Firefox ESR 52.6.0 (32-bit)!!!

    I have spent many hours trying to solve this issue... I hope it helps someone in the same situation!!

    :)

    My only issue now is that Firefox is not working headless. I wonder if this is related to the fact that I am using an old version of geckodriver... but well, that's another issue!