【发布时间】:2018-11-03 13:11:36
【问题描述】:
这里有点 Python 新手...
Windows 7 x64 和 Python 3.7
我已经安装了 Selenium 和 Chrome Webdriver。我正在使用:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'
driver = webdriver.Chrome(chrome_options=options, executable_path='C:/python/chromedriver.exe')
driver.get('http://google.com/')
我明白了:
\python\python.exe C:/py/defectURLS/app.py
C:/py/defectURLS/app.py:6: DeprecationWarning: use options instead of chrome_options
driver = webdriver.Chrome(chrome_options=options, executable_path='C:/python/chromedriver.exe')
Traceback (most recent call last):
File "C:/py/defectURLS/app.py", line 6, in <module>
driver = webdriver.Chrome(chrome_options=options, executable_path='C:/python/chromedriver.exe')
File "C:\python\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "C:\python\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\python\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\python\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\python\lib\site-packages\selenium-3.141.0-py3.7.egg\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at C:/Program Files (x86)/Google/Chrome/Application/chrome.exe
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 6.1.7601 SP1 x86_64)
现在,我很确定确凿证据是:
selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at C:/Program Files (x86)/Google/Chrome/Application/chrome.exe
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 6.1.7601 SP1 x86_64)
这表明 Selenium 可以找到 webdriver 正常,因为它能够报告 webdriver 版本。该错误似乎表明 chrome 二进制文件未位于给定位置。但我完全确定这是 Chrome.exe 所在的位置。我可以直接从该路径启动 chrome.exe,完全没有问题。
非常感谢指导可能出现的问题。
【问题讨论】:
-
尝试传递
options而不是chrome_options
标签: python selenium google-chrome selenium-webdriver selenium-chromedriver