Selenium:ChromeDriver和Chromium浏览器与树莓派的不同版本

oxiaedzo  于 2023-06-19  发布在  Go
关注(0)|答案(2)|浏览(288)

我在raspberry pi上使用的是当前版本(86.0.4240.197)的chromium-browser和当前版本(87.0.4280.66)的chrome驱动程序。在Python中调用驱动程序时

driver = webdriver.Chrome(options = options, executable_path ='/usr/lib/chromium-browser/chromedriver')

我收到错误“selenium.common.exceptions.SessionNotCreatedException:消息:会话未创建:此版本的ChromeDriver仅支持Chrome版本87当前浏览器版本为86.0.4240.197,二进制路径为/usr/bin/chromium-browser”。我试图降级到https://www.ubuntuupdates.org/package/core/bionic/universe/updates/chromium-chromedriver上列出的版本,但无法找到这些版本。
你有什么想法来修复它或降级chrome驱动程序吗?
先谢谢你了。马蒂亚斯

jtoj6r0c

jtoj6r0c1#

我也遇到了同样的问题,删除了chromedriver扩展,然后通过电子版本,你可能需要做一些试验和错误来找到正确的资产,但它对我有效。
https://github.com/electron/electron/releases/
IIRC(我很可能错了),对我有效的版本是chromedriver-v11.2.0-linux-armv7 l
https://github.com/electron/electron/releases/download/v11.2.0/chromedriver-v11.2.0-linux-armv7l.zip
这是直接链接-同样,它可能不适合你,但它适合我(我运行Chromium 86.0.4240.197构建在Raspbian上,运行在Raspbian 10上

4dc9hkyq

4dc9hkyq2#

浏览器版本109.9.5414.112和Chrome驱动程序113.something遇到了同样的问题。根据art_architect对原始帖子的评论,我想分享更多的细节(为了子孙后代和像我这样的raspi初学者的新手友好性)如何在launchpad librarian上找到并安装正确的版本。
访问launchpad.net并搜索“chromium-chromedriver 109 armhf”(或者不是109,而是你需要的chromedriver版本来匹配浏览器,armhf是32位linux的,在我的情况下与armv7 l兼容)
会有一吨的结果,但似乎任何结果将工作,只要主要版本匹配,并与您的机器兼容。第109章最后是:https://launchpad.net/ubuntu/bionic/armhf/chromium-chromedriver/109.0.5414.74-0ubuntu0.18.04.14
页面上应该有一个“.deb”文件;复制链接地址到这个,下面是如何在你的raspi上安装它:

mkdir chromium_install
cd chromium_install
wget {YOUR LINK HERE} #(for example: http://launchpadlibrarian.net/645948278/chromium-chromedriver_109.0.5414.74-0ubuntu0.18.04.14_armhf.deb)
sudo apt install ./{THE DOWNLOADED FILE} #(for example: sudo apt install ./chromium-chromedriver_109.0.5414.74-0ubuntu0.18.04.14_armhf.deb)

最后,运行这个应该可以工作:

python3
>>> from selenium import webdriver
>>> from selenium.webdriver.chrome.options import Options
>>> chrome_options = Options()
>>> chrome_options.add_argument('--headless')
>>> chrome_options.add_argument('--no-sandbox')
>>> chrome_options.add_argument('--disable-dev-shm-usage')
>>> driver = webdriver.Chrome(chrome_options=chrome_options)

这个工具对于管理软件包非常有用。非常感谢art_architect提供的资源和Matthias提出的问题,因为在最终看到他们的解决方案之前有很多令人头痛的问题。

相关问题