selenium无法启动Chromedriver

我无法开始ChromedriverSelenium

from selenium import webdriver

browser = webdriver.Chrome()

browser.get('http://www.google.com')

browser.get('http://www.google.com')失败,但会失败:

    raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

(Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 3.13.0-76-generic x86_64)

我正在Ubuntu 14.04使用Python 2.7.6virtualenv

installation)和(64b)selenium==2.50.1

dm@Z580:~$ which chromedriver

/usr/local/bin/chromedriver

dm@Z580:~$ ll /usr/local/bin/chromedriver

lrwxrwxrwx 1 root root 24 feb 4 22:13 /usr/local/bin/chromedriver -> /opt/google/chromedriver*

dm@Z580:~$ google-chrome --version

Google Chrome 48.0.2564.97

降级为Chromedriver 2.20

wget http://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip

unzip chromedriver_linux64.zip

chmod 777 chromedriver

sudo mv -f chromedriver /opt/google/chromedriver

但是,可悲的是,结果仍然相同。

知道为什么会这样吗?

回答:

好的,所以解决方案 有点奇怪

我将Chromedriver二进制文件从/opt/google/Google

Chrome已安装的位置)移动到/opt/,更新了符号链接,它现在可以正常工作!

与问题本身相比,以下两行代码可以解决问题:

sudo mv /opt/google/chromedriver /opt/

sudo ln -fs /opt/chromedriver /usr/local/bin/chromedriver

现在,我可以运行以下Python代码:

from selenium import webdriver

browser = webdriver.Chrome()

browser.get('http://www.google.com')

Chrome启动,一切正常。

Selenium旧文档页面上的以下行启发了我进行检查并最终更改了Chromedriver位置:

对于Linux系统,ChromeDriver希望/ usr / bin / google-chrome是实际Chrome二进制文件的符号链接。

以上是 selenium无法启动Chromedriver 的全部内容, 来源链接: utcz.com/qa/427475.html

回到顶部