我是python初学者,chrome驱动程序的最新更新无法在不创建会话的情况下在windows上打开chrome,如何每次使用python创建新会话?
我得到以下错误-
**~/opt/anaconda2/envs/p36workshop/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
79 remote_server_addr=self.service.service_url,
80 keep_alive=keep_alive),
---> 81 desired_capabilities=desired_capabilities)
82 except Exception:
83 self.quit()
~/opt/anaconda2/envs/p36workshop/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
155 warnings.warn("Please use FirefoxOptions to set browser profile",
156 DeprecationWarning, stacklevel=2)
--> 157 self.start_session(capabilities, browser_profile)
158 self._switch_to = SwitchTo(self)
159 self._mobile = Mobile(self)
~/opt/anaconda2/envs/p36workshop/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, capabilities, browser_profile)
250 parameters = {"capabilities": w3c_caps,
251 "desiredCapabilities": capabilities}
--> 252 response = self.execute(Command.NEW_SESSION, parameters)
253 if 'sessionId' not in response:
254 response = response['value']
~/opt/anaconda2/envs/p36workshop/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
319 response = self.command_executor.execute(driver_command, params)
320 if response:
--> 321 self.error_handler.check_response(response)
322 response['value'] = self._unwrap_value(
323 response.get('value', None))
~/opt/anaconda2/envs/p36workshop/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
240 alert_text = value['alert'].get('text')
241 raise exception_class(message, screen, stacktrace, alert_text)
--> 242 raise exception_class(message, screen, stacktrace)
243
244 def _value_or_default(self, obj, key, default):
SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 83**
错误是解释错误所在。您拥有的chrome驱动程序版本不能用于chrome v83。
如何检查您使用的chrome版本?:
- 打开chrome并在url栏中写入以下内容:
chrome://settings/help
- 这将打开about部分,您应该能够看到当前版本的chrome。例如,我有最新版本的
85.0.4183.83
,它是chrome85
请确保在此基础上下载正确的chrome驱动程序。