python linux selenium:无法访问chrome [英] python linux selenium: chrome not reachable

查看:122
本文介绍了python linux selenium:无法访问chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Ubuntu 16.10 Server上运行selenium,但是却出现WebDriverException:消息:无法访问chrome(驱动程序信息:chromedriver 2.9.248304,platform = Linux 4.8.0-22-generic x86_64)

I'm trying to run selenium on Ubuntu 16.10 Server, but I'm getting WebDriverException : Message : chrome not reachable (Driver info: chromedriver 2.9.248304, platform=Linux 4.8.0-22-generic x86_64)

from pyvirtualdisplay import Display
from selenium import webdriver

display = Display(visible=0, size=(800, 600))
display.start()

browser = webdriver.Chrome('usr/bin/chromedriver')
browser.get('http://www.google.com')
print(browser.title)
browser.quit()

display.stop()

已安装Chrome:

google-chrome --version

Google Chrome 57.0.2987.110

Google Chrome 57.0.2987.110

推荐答案

添加一些chrome选项很有帮助!

Adding some chrome options helped!

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=chrome_options)

这篇关于python linux selenium:无法访问chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆