如何在Selenium Python中打开新的Chrome会话?

如何在Selenium Python中打开新的Chrome会话?,python,selenium,selenium-webdriver,selenium-chromedriver,Python,Selenium,Selenium Webdriver,Selenium Chromedriver,我是一名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, de

我是一名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。例如,我有最新版本的chrome85

  • 确保基于此下载了正确的chrome驱动程序。

    是否确保使用与当前chrome安装相同的驱动程序版本?打开chrome>设置>关于chrome并检查版本号。确保它与驱动程序版本非常匹配,@AdarshKumar发现我使用的是旧版本的驱动程序。
    chrome://settings/help