I have written a python script that does some tasks in the browser (using Selenium), which works fine in Windows. Now I am trying to now get it onto my Raspberry Pi.
I did a lot of searching to find the best way to get this to work with Chromium. The best I could find was at this Reddit Link.
The problem is that I cannot find a chromedriver that jives with my version of Chromium (version 56.0.2924.84). And when I do apt-get upgrade it advises me that I have the newest version of Chromium. I’ve tried chromedriver versions 53 through 65 by downloading from this Launchpad Link.
So when I run the following
from selenium import webdriver driver_path = 'usr/lib/chromium-browser/chromedriver' driver = webdriver.Chrome(driver_path)
I get this error for chrome drivers > 58
selenium.common.exceptions.SessionNoteCreatedException: Message: session not created exception: Chrome version must be >= 59.0.3071.0 (Driver info: chromedriver=2.43,platform=Linux 4.9.35-v7+ armv7l)
or this error for chrome drivers < 58
selenium.common.exceptions.WebDriverException: Message: Service /usr/lib/chromium-browser/chromedriver unexpectedly exited. Status code was: 127
any help here would be appreciated
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
As per your question your Chromium binary is of version 56.0.2924.84. So keeping this constraint in consideration the solution would be to download either of the following ChromeDriver version from ChromeDriver Google Storage
- ChromeDriver v84: Supports Chrome v84
- ChromeDriver v83: Supports Chrome v83
- ChromeDriver v82: Was intentionally skipped
- ChromeDriver v81: Supports Chrome v81
- ChromeDriver v80: Supports Chrome v80
- ChromeDriver v79: Supports Chrome v79
- ChromeDriver v78: Supports Chrome v78
- ChromeDriver v77: Supports Chrome v77
- ChromeDriver v76: Supports Chrome v76
- ChromeDriver v75: Supports Chrome v75
- ChromeDriver v74: Supports Chrome v74
- ChromeDriver v73: Supports Chrome v73
- ChromeDriver v2.46: Supports Chrome v71-73
- ChromeDriver v2.46: Supports Chrome v71-73
- ChromeDriver v2.45: Supports Chrome v70-72
- ChromeDriver v2.44: Supports Chrome v69-71 (same as ChromeDriver 2.43, but with additional bug fixes)
- ChromeDriver v2.43: Supports Chrome v69-71
- ChromeDriver v2.42: Supports Chrome v68-70
- ChromeDriver v2.41: Supports Chrome v67-69
- ChromeDriver v2.40: Supports Chrome v66-68
- ChromeDriver v2.39: Supports Chrome v66-68
- ChromeDriver v2.38: Supports Chrome v65-67
- ChromeDriver v2.37: Supports Chrome v64-66
- ChromeDriver v2.36: Supports Chrome v63-65
- ChromeDriver v2.35: Supports Chrome v62-64
- ChromeDriver v2.34: Supports Chrome v61-63
- ChromeDriver v2.33: Supports Chrome v60-62
- ChromeDriver v2.32: Supports Chrome v59-61
- ChromeDriver v2.31: Supports Chrome v58-60
- ChromeDriver v2.30: Supports Chrome v58-60
- ChromeDriver v2.29: Supports Chrome v56-58
- ChromeDriver v2.28: Supports Chrome v55-57
- ChromeDriver v2.27: Supports Chrome v54-56
Note: A few months ago, Chromium Team made a preliminary announcement that ChromeDriver’s versioning model will be changing. Chromium Team is moving forward with the plan. Specifically, ChromeDriver 2.46 will be the last release carrying the major version of 2. Future ChromeDriver releases will carry a version number similar to Chrome release. We will start with a release of ChromeDriver 73 next week, before the Beta release of Chrome 73.
Here is how the new release model will work:
- ChromeDriver will be using the same version number scheme as Chrome. See https://www.chromium.org/developers/version-numbers for more details.
- Each version of ChromeDriver will support Chrome with matching major, minor, and build version numbers. For example, upcoming ChromeDriver 73.0.3683.* will support all Chrome versions that start with 73.0.3683.
- Before a new major version of Chrome goes to Beta, a matching version of ChromeDriver will be released. For example, a new version of ChromeDriver will be release next week to match the Beta release of Chrome m73.
- After the initial release of a new major version, we will release patches as needed. These patches may or may not coincide with updates to Chrome.
ChromeDriver for Raspberry Pi
As you are using Raspberry Pi you need to download the arm format of ChromeDriver from this link and use it within your program.
Additional Considerations
- Upgrade Selenium to current levels Version 3.11.0.
- Upgrade ChromeDriver as per the above discussion.
- Keep Chrome version at Chrome v56.x levels. (as per the discussion)
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
- If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
- Take a System Reboot.
- Execute your
@Test.
Method 2
Before: You should download binary chromedriver, unzip it somewhere in you PC and set path to this driver like this:
webdriver.Chrome('/home/user/drivers/chromedriver')
ChromeDriverManager(path=custom_path).install()
It’s boring!!! Moreover every time the new version of driver released, you should go and repeat all steps again and again.
With webdriver manager, you just need to do two simple steps:
Install manager:
pip install webdriver-manager
Use with Chrome:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
Use with Chromium:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType
driver = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install())
Use with FireFox:
from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
Use with IE:
from selenium import webdriver
from webdriver_manager.microsoft import IEDriverManager
driver = webdriver.Ie(IEDriverManager().install())
Use with Edge:
from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager
driver = webdriver.Edge(EdgeChromiumDriverManager().install())
Use with Opera:
from selenium import webdriver
from webdriver_manager.opera import OperaDriverManager
driver = webdriver.Opera(executable_path=OperaDriverManager().install())
Note
If the Opera browser is installed in a location other than C:/Program Files or C:/Program Files (x86) on windows and /usr/bin/opera for all unix variants and mac, then use the below code:
from selenium import webdriver
from webdriver_manager.opera import OperaDriverManager
options = webdriver.ChromeOptions()
options.add_argument('allow-elevated-browser')
options.binary_location = "C:\Users\USERNAME\FOLDERLOCATION\Opera\VERSION\opera.exe"
driver = webdriver.Opera(executable_path=OperaDriverManager().install(), options=options)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0