Running Chromium WebDriver on aarch64/ARM Ubuntu Linux

As of now (April 22nd), there’s no official chromedriver released for Ubuntu Linux running on ARM architecture yet, but we can use unofficial binary released by the Electron team.

Let’s download it:

wget -qP /tmp/ "https://github.com/electron/electron/releases/download/v30.0.1/chromedriver-v30.0.1-linux-arm64.zip"
sudo unzip -o /tmp/chromedriver-v30.0.1-linux-arm64.zip -d /usr/bin
sudo chmod 755 /usr/bin/chromedriver

The appropriate way to use that webdriver on Selenium 4.19 is:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

service = webdriver.ChromeService()
service.path = '/usr/bin/chromedriver' # replace this if necessary
options = Options()
options.add_argument("--disable-extensions") # add any other option

driver = webdriver.Chrome(service=service, options=options)

Otherwise, if we simply:

from selenium import webdriver
options = Options()
options.add_argument("--disable-extensions") # add any other option
driver = webdriver.Chrome(options=options)

We’ll see this Unsupported platform/architecture combination: linux/aarch64 error popped up:

Traceback (most recent call last):
  File "/home/p4/.cache/pypoetry/virtualenvs/requesters-aWPIf66K-py3.11/lib/python3.11/site-packages/selenium/webdriver/common/driver_finder.py", line 38, in get_path
    path = SeleniumManager().driver_location(options) if path is None else path
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/p4/.cache/pypoetry/virtualenvs/requesters-aWPIf66K-py3.11/lib/python3.11/site-packages/selenium/webdriver/common/selenium_manager.py", line 89, in driver_location
    args = [str(self.get_binary()), "--browser", browser]
                ^^^^^^^^^^^^^^^^^
  File "/home/p4/.cache/pypoetry/virtualenvs/requesters-aWPIf66K-py3.11/lib/python3.11/site-packages/selenium/webdriver/common/selenium_manager.py", line 63, in get_binary
    raise WebDriverException(f"Unsupported platform/architecture combination: {sys.platform}/{arch}")
selenium.common.exceptions.WebDriverException: Message: Unsupported platform/architecture combination: linux/aarch64


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/p4/.cache/pypoetry/virtualenvs/requesters-aWPIf66K-py3.11/lib/python3.11/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/p4/.cache/pypoetry/virtualenvs/requesters-aWPIf66K-py3.11/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.py", line 49, in __init__
    self.service.path = DriverFinder.get_path(self.service, options)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/p4/.cache/pypoetry/virtualenvs/requesters-aWPIf66K-py3.11/lib/python3.11/site-packages/selenium/webdriver/common/driver_finder.py", line 41, in get_path
    raise NoSuchDriverException(msg) from err
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

Alas, the current selenium webdriver at the time of writing (in 2024!) does not support specifying executable path through executable_path, so this won’t work:

driver = webdriver.Chrome(executable_path='C:/path/to/chromedriver.exe')

Unfortunately, the source code is not so well documented. To know how to fix this, I had to see what’s inside driver_finder.py. Luckily, there’s still a way to manually specify the path. But, why don’t they get the path by themselves, since the chromedriver is extracted at /usr/bin anyway? Well, the main reason is because aarch64 is an unknown platform for the Ubuntu Linux, according to Selenium.

In any case that you need to exactly specify which chrome browser to use, we can still do:

options.binary_location = '/snap/bin/chromium'

Finally, you will likely still need to tweak the code to download the chromedriver most appropriate for your Chrome or chromium.