尝试使用Selenium WebDriver在Linux上启动Chrome驱动程序 [英] Try to start chrome driver on linux with selenium webdriver

查看:781
本文介绍了尝试使用Selenium WebDriver在Linux上启动Chrome驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到答案,但是现在我自己问.

I try to find answer and can't, now I ask by myself.

我写了简单的测试

from selenium import webdriver

driver = webdriver.Chrome(executable_path=r"/home/tranter/workspace/chromedriver")
driver.get("http://www.python.org")
driver.close()

比我有追溯力

> tranter@tranter-VirtualBox:~/workspace$ python testchrome.py Traceback
> (most recent call last): File "testchrome.py", line 6, in <module>
> driver =
> webdriver.Chrome(executable_path=r"/home/tranter/workspace/chromedriver")
> File
> "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py",
> line 65, in __init__ keep_alive=True) File
> "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
> line 73, in __init__ self.start_session(desired_capabilities,
> browser_profile) File
> "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
> line 121, in start_session 'desiredCapabilities':
> desired_capabilities, File
> "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
> line 173, in execute self.error_handler.check_response(response) File
> "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py",
> line 166, in check_response raise exception_class(message, screen,
> stacktrace) selenium.common.exceptions.WebDriverException: Message:
> u'unknown error: Chrome failed to start: exited abnormally\n (Driver
> info: chromedriver=2.10.267517,platform=Linux 3.13.0-35-generic x86)'

我有最新版本的chromedriver 10,最新的chromium和最新的selenium webdriver. 这就是我从xubuntu开始的一切

I have latest version of chromedriver 10, latest chromium, latest selenium webdriver. And it all I start in xubuntu

Linux版本3.13.0-35-通用(build @ roseapple)(gcc版本4.8.2(Ubuntu 4.8.2-19ubuntu1))#62-Ubuntu SMP 2014年8月15日星期五UTC 15

请帮助我:(

推荐答案

对于Linux用户:

在启动Chrome之前,先启动显示.有关更多信息,请点击此处

For Linux user:

Start the Display before start the Chrome. for more info click here

from selenium import webdriver
from pyvirtualdisplay import Display
# Add following 2 line before start the Chrome
display = Display(visible=0, size=(800, 800))  
display.start()
driver = webdriver.Chrome()
driver.get("http://www.google.com")
driver.quit()
display.stop()

这篇关于尝试使用Selenium WebDriver在Linux上启动Chrome驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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