I wrote a quick program that simply opens and closes a website using Firefox at set intervals. It runs perfectly on my Intel Mac OS Ventura. I intended to keep it running on a Raspberry Pi, but I cannot find a combination of versions of Selenium, geckodriver or chromedriver, and Firefox or Chromium that will run on it.
The Mac has Selenium 4.11.2, geckodriver v0.33.0, and Firefox 115.0.3 working. The Raspberry Pi has Ubuntu 22.04.3 LTS. I found out here, https://github.com/SeleniumHQ/selenium/issues/11599, that Selenium Manager doesn’t work on linux-arm64, and the Raspberry Pi uses linux-arm64. I was getting errors even when I tried to code in the path to the driver, with Selenium logging that it couldn’t find a driver, even while it was also in PATH. It looks like the developers say in the conversation above that the built in Selenium Manager driver manager causes errors like these. Selenium Manager was introduced in Selenium 4.6, so I rolled back to Selenium 4.5, altered my code for that version, tried to run it, and got different errors that seemed to be about incompatibility issues between the driver and the version of Firefox. I tried different combinations of them with no success. Then I decided to try Chrome instead. Google does not provide a chromedriver build for linux-arm64, so I tried to use different versions found here, https://github.com/electron/electron/releases, as well as trying to roll back Chromium. I was able to at least launch the Chromium browser with the program, which is more success than I had with Firefox, but I could not get it fully working. All along the whole process I read many answers to Selenium problems on Stack Overflow, but nothing has helped.
Here is the code that runs fine on Mac with the configuration above:
import datetime, logging, time
from selenium import webdriver
logger = logging.getLogger('selenium')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler("handler.log")
logger.addHandler(handler)
logging.getLogger('selenium.webdriver.remote').setLevel(logging.DEBUG)
logging.getLogger('selenium.webdriver.common').setLevel(logging.DEBUG)
logging.basicConfig(filename="program.log", level=logging.INFO)
timeStarted = datetime.datetime.now()
logging.info(
timeStarted.strftime("%m/%d/%Y, %H:%M:%S")
+ " started on https://google.com"
)
# Program starts here
while True:
timeOfRequest = datetime.datetime.now()
try:
browser = webdriver.Firefox()
browser.get("https://google.com")
logging.info(
timeOfRequest.strftime("%m/%d/%Y, %H:%M:%S")
+ " Success"
)
except:
logging.exception(
timeOfRequest.strftime("%m/%d/%Y, %H:%M:%S") + " Something went wrong"
)
time.sleep(810)
browser.quit()
time.sleep(30)
2
Answers
Here is what I got after spending a whole evening trying to solve this problem:
To use Selenium on linux-arm64, we’ll need to obtain three old Debian packages:
Below is a step-by-step guide.
Installation
Download the packages
To fetch the necessary Debian packages directly from the launchpad, we can use the
wget
command.Once ready, can install them using
gdebi-core
, which will handle the dependencies.Install gdebi-core
Install the Debian packages
After following these steps, should have a working configuration of Selenium with ChromeDriver on linux-arm64.
Verify Installation
the output should be like
Chromium 112.0.5615.49 Built on Ubuntu , running on Ubuntu 22.04
To further test the installation, save the following script as test.py. Note that the arguments provided for options are essential:
Executing
python test.py
should yield:assuming you download the geckodriver
https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux-aarch64.tar.gz and declare its directory you unpacked it in ~/.local/bin/ declared in you .bashrc or .profile in the PATH
a working starting python code I use is