在Ubuntu上安装Chromedriver以使用Splinter

时间:2013-10-18 05:09:31

标签: python google-chrome ubuntu selenium splinter

我正在尝试使用Python的Splinter库来运行网页测试。问题是我无法获得chromedriver可执行文件的位置是正确的。每当我尝试运行文件时,我都会

Traceback (most recent call last):
File "autoCookie.py", line 7, in <module>
browser = Browser('chrome')
File "/usr/local/lib/python2.7/dist-packages/splinter/browser.py", line 44, in Browser
return driver(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/chrome.py", line 23, in __init__
self.driver = Chrome(chrome_options=options, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/selenium-2.36.0-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 59, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium-2.36.0-py2.7.egg/selenium/webdriver/chrome/service.py", line 68, in start
and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.                 Please download from http://code.google.com/p/chromedriver/downloads/list                and read up at http://code.google.com/p/selenium/wiki/ChromeDriver'

我已将目录更改为Web上建议的每个位置,我在splinter网站上运行了安装过程,我尝试使用os.environ进行设置,我已经在selenium内的webdrive.py文件中编辑了代码文件夹,我已经尝试了我可以在互联网上找到的所有内容,但我仍然收到此错误。此外,当我使用browser = Browser(“firefox”)运行程序时,程序运行正常,但是当我到达click()函数时,它会退出并显示错误。但这是一个不同的问题,我宁愿让它在Chrome中运行。我愿意接受任何建议,我只是希望有人在这里帮助我。提前谢谢!

其他信息:

操作系统:Ubuntu 13.04,Python 2.7,Selenium 2.36.0,chromedriver_linux64

1 个答案:

答案 0 :(得分:0)

您的PYTHONPATH和PATH设置为什么?

>>> import os
>>> import sys
>>> os.environ['PYTHONPATH'].split(os.pathsep)
>>> sys.path

您的ChromeDriver可执行文件在哪里?它需要位于上面返回的目录之一。