selenium.com.mon.exceptions.SessionNotCreatedException:消息:会话



我有一个问题,每个,单个,TIME基本上这是我的代码:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:Program Files (x86)GoogleChrome BetaApplicationchrome.exe"
options.add_argument("--no-sandbox")
options.add_argument("--no-default-browser-check")
options.add_argument("--no-first-run")
options.add_argument("--disable-default-apps")
driver = webdriver.Chrome(options=options, executable_path="C:Program Files (x86)GoogleChrome BetaApplicationchromedriver.exe")
driver.get('https://www.youtube.com/')

错误为

selenium.common.exceptions.SessionNotCreatedException: Message: session not created

我使用了Pycharm,并尝试将VS代码与python 3.4、3.7和3.8.3一起使用请帮帮我,我受够了。

完整错误日志:

Traceback (most recent call last):
File "C:/Users/um/PycharmProjects/Selenium/main.py", line 10, in <module>
driver = webdriver.Chrome(options=options, executable_path="C:Program Files (x86)GoogleChrome BetaApplicationchromedriver.exe")
File "C:UsersumAppDataLocalProgramsPythonPython38-32libsite-packagesseleniumwebdriverchromewebdriver.py", line 76, in __init__
RemoteWebDriver.__init__(
File "C:UsersumAppDataLocalProgramsPythonPython38-32libsite-packagesseleniumwebdriverremotewebdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:UsersumAppDataLocalProgramsPythonPython38-32libsite-packagesseleniumwebdriverremotewebdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:UsersumAppDataLocalProgramsPythonPython38-32libsite-packagesseleniumwebdriverremotewebdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:UsersumAppDataLocalProgramsPythonPython38-32libsite-packagesseleniumwebdriverremoteerrorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to send message to renderer
(Session info: chrome=81.0.4044.83)

您的错误不是

无法将消息发送到呈现器

如您所述。根据堆栈跟踪,您在第6行中发布了问题

driver = webdriver.Chrome(options=options, executable_path="chromedriver.exe", )

,问题是:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created

您似乎指定了一个无效的chromedriver路径,而Selenium无法初始化驱动程序并创建会话。您还应该查看指南中的chromedriver版本。在这里你可以下载有效的版本(我已经从stacktrace中获取了你的Chrome版本(。

是的,它确实启动了,然后关闭了上面的错误日志,而且我有正确的版本

相关内容

最新更新