0

我使用的是linux64,我只是想使用硒webdriver控制铬,为此,我已下载并放置在"/usr/bin" Cromedriver和更改权限"a+x"硒webdriver chromedriver路径异常

现在我试图运行示例结果路径异常(ChromeDriver executable needs to be available in the path)。

File "test1.py", line 16, in <module> 
    driver = webdriver.Chrome(chromedriver) 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 59, in __init__ 
    self.service.start() 
    File "/usr/local/lib/python2.7/dist-packages/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/selenium/downloads/list and 
read up at http://code.google.com/p/selenium/wiki/ChromeDriver' 

经过一番研究,我刚刚修改了示例代码,我仍然得到相同的异常。

chromedriver = "/usr/bin/chromedriver" 
os.environ["webdriver.chrome.driver"] = chromedriver 

# Create a new instance of the Chrome driver 
driver = webdriver.Chrome(chromedriver) 

如何解决异常?

+0

如果您将chrome的可执行文件放入主目录,该怎么办?它工作吗? – alecxe

+0

没有它也没有工作 – user1834809

+0

你真的可以从命令行启动可执行吗? – alecxe

回答

0

可能是您下载的驱动程序出现问题。您很可能在64位平台上运行32位驱动程序。