我有一个工作的硒笔记本,我三个星期都没用过,现在崩溃了: - (
看来我并不孤单: https://bugs.chromium.org/p/chromedriver/issues/detail?id=1548
我了解Chrome版本的更改,最近转到版本54,并使旧的selenium版本崩溃。
在几个博客之后,我终于再次下载了webdriver: https://sites.google.com/a/chromium.org/chromedriver/
跟随歌剧司机(是的,我也试过歌剧: - /) https://github.com/operasoftware/operachromiumdriver/blob/master/examples/desktop.py
我仍然有这个问题。
所以这是日志:
from selenium import webdriver
from selenium.webdriver.chrome import service
webdriver_service = service.Service('/Users/romain/anaconda/bin/chromedriver_bug')
webdriver_service.start()
driver = webdriver.Remote(webdriver_service.service_url, webdriver.DesiredCapabilities.OPERA)
给予:
driver.get('https://www.google.com/')
WebDriverException: Message: session not created exception
from unknown error: bad inspector message: {"method":"Page.loadEventFired","params":{"timestamp":88165,388799}}
(Session info: chrome=54.0.2840.87)
(Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.0 x86_64)
我该如何更改webdriver?我只是将解压缩的文件复制粘贴到〜/ Anaconda / bin / webdriver中。 这是正确的方法吗?
编辑==================
我做了:
$ pip install -U selenium
Requirement already up-to-date: selenium in /Users/romain/anaconda/lib/python2.7/site-packages
我从以下网址下载了Chrome驱动程序:https://chromedriver.storage.googleapis.com/index.html?path=2.25/
我解压缩[chromedriver_mac64 (1).zip
]并获取[chromedriver
]下面的[~/anaconda/bin
]文件。
我有:
$ which jupyter
~/anaconda/bin/jupyter
我做了:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://www.google.com/')
如果我这样做:
from selenium import webdriver
from selenium.webdriver.chrome import service
webdriver_service = service.Service('/Users/romain/anaconda/bin/chromedriver')
webdriver_service.start()
driver = webdriver.Remote(webdriver_service.service_url, webdriver.DesiredCapabilities.OPERA)
driver.get('https://www.google.com/')
答案 0 :(得分:0)
将您的selenium升级到最新版本
pip install --upgrade selenium
确保使用最新版本更换旧版chromedriver,即解压缩并粘贴到早期镀铬机的位置。
答案 1 :(得分:0)
我看了看:
https://bugs.chromium.org/p/chromedriver/issues/detail?id=1552
并设置:
LC_NUMERIC=”en_US.UTF-8″
LANG=”en_US.UTF-8″
在我的〜/ .bash_profile
中然后它起作用了: - )