消息:' chromedriver'可执行文件需要在PATH中

时间:2017-07-05 05:43:04

标签: python eclipse selenium selenium-chromedriver

所以,我正在OS X El Capitan使用Eclipse (Neo) and Python。我用Selenium脚本编写了一些Python。

这些脚本运行正常。

然后我从OSX Sierra升级到El Capitan

  

注意:这是唯一的重大变化   我做了我的设置。

当我尝试运行相同的脚本时,现在,我得到了

  

消息: chromedriver可执行文件需要在PATH中

到目前为止,我可以在我的路径上告诉chromedriver IS。

现在,我只能让我的脚本工作,如果我hard copy我的Chrome驱动程序的路径,这不是最优雅的做事方式,我们都知道。

还有其他人/有这个问题吗?关于使用Eclipse + Python进行任何配置的想法。

My Eclipse and Python project screen shot

my PYTHONPATH screen shot

2 个答案:

答案 0 :(得分:0)

我不知道python。但是无论语言如何,webdriver的实现都应该是相同的。在这里你已经调用了chrome webdriver,但你在代码中定义了chromedriver.exe的路径吗?例如,在java中它看起来像这个

System.setProperty("webdriver.chrome.driver", "C:\\selenium-java-3.4.0/chromedriver.exe");
driver = new ChromeDriver();

你得到的错误是指chromedriver.exe而不是python环境。

Google文档中的Python解决方案:

import time
from selenium import webdriver

driver = webdriver.Chrome('/path/to/chromedriver')  # Optional argument, if not specified will search path.
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()

答案 1 :(得分:0)

首先验证您的驱动程序路径,如果您打开命令提示符并输入chromedriver并按Enter键。如果您收到消息"启动ChromeDriver 2.15.322448 .."你的路径设置正确。
在python中,替代解决方案是你可以使用
driver = webdriver.Chrome("path_to_driver/chromedriver.exe")
 希望这应该工作!

相关问题