我试着找到答案而不能,现在我自己问.我写了简单的测试from selenium import webdriverdriver = webdriver.Chrome(executable_path=r/home/tranter/workspace/chromedriver)driver.get(http://www.python.org)...

我试着找到答案而不能,现在我自己问.
我写了简单的测试
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,最新的铬,最新的selenium webdriver.
这一切都是我从xubuntu开始的
Linux version 3.13.0-35-generic (buildd@roseapple) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #62-Ubuntu SMP Fri Aug 15 01:58:01 UTC 2014
请帮我 :(
解决方法:
对于Linux用户:
在启动Chrome之前启动显示.有关更多信息,请单击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()
本文标题为:python – 尝试使用selenium webdriver在linux上启动chrome驱动程序


基础教程推荐
- python-如何将空参数传递给Popen(shell = False)? 2023-11-10
- 停止使用Python 2:您需要了解的关于Python 3的内容| Hackaday 2023-09-04
- python-使狗尾示例脚本在Ubuntu 10.04上运行 2023-11-13
- Python执行Linux系统命令的4种方法-转发的 2023-11-12
- 在Windows TO Linux / OSX中使用Python进行交叉编译 2023-11-14
- python-在CentOS上构建PyGTK时出现问题 2023-11-10
- 如何在Python3.5虚拟环境中安装scipy Windows 10? 2023-11-11
- 进程与子进程(python3入门) 2023-09-04
- Python中的getattr、__getattr__、__getattribute__、__get__详解 2023-08-04
- python-Nginx,uWSGI,Flask应用程序直到服务器重启后才会显示更改 2023-11-11