我正在使用 linux64,我只想使用 selenium webdriver 控制 chrome,为此我已经下载并放置了 cromedriver"/usr/bin"
并更改了权限"a+x"
。
现在我正在尝试运行路径异常(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)
如何解决异常?