无法启动新会话。响应代码 500。消息:session not created: This version of ChromeDriver only supports Chrome version 114
操作系统:Windows服务器
语言:Java
Chrome版本:116.0.5845.97
Chrome 驱动程序版本:116.0.5845.96
输出 :
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Starting ChromeDriver 114.0.5735.90 (386bc09e8f4f2e025eddae123f36f6263096ae49-refs/branch-heads/5735@{#1052}) on port 10267
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
FAILED CONFIGURATION: @BeforeMethod StartDriver
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 116.0.5845.97 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
Host info: host: 'WSAMZN-5U0L0QME', ip: '10.40.2.21'
Build info: version: '4.8.2', revision: '826dbfc730'
System info: os.name: 'Windows Server 2019', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.2'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [--disable-notifications, ----disable-gpu, --disable-blink-features, --disable-blink-features=Au..., enable-automation, --no-sandbox, --disable-setuid-sandbox, --disable-infobars, --disable-dev-shm-usage, --disable-browser-side-navi..., --force-device-scale-factor=1, --remote-allow-origins=*, start-maximized, --safebrowsing-disable-down..., safebrowsing-disable-extens...], extensions: [], prefs: {download.default_directory: D:\SeleniumWebdriver\backlo..., download.extensions_to_open: application/exe, download.prompt_for_download: false, safebrowsing.enabled: true}}, pageLoadStrategy: none, unhandledPromptBehavior: accept}], desiredCapabilities=Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [--disable-notifications, ----disable-gpu, --disable-blink-features, --disable-blink-features=Au..., enable-automation, --no-sandbox, --disable-setuid-sandbox, --disable-infobars, --disable-dev-shm-usage, --disable-browser-side-navi..., --force-device-scale-factor=1, --remote-allow-origins=*, start-maximized, --safebrowsing-disable-down..., safebrowsing-disable-extens...], extensions: [], prefs: {download.default_directory: D:\SeleniumWebdriver\backlo..., download.extensions_to_open: application/exe, download.prompt_for_download: false, safebrowsing.enabled: true}}, pageLoadStrategy: none, unhandledPromptBehavior: accept}}]
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:148)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:106)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:165)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:183)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:229)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:101)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:84)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:73)
at com.cgw.resources.Base.StartDriver(Base.java:151)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)
at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:700)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:527)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:794)
at org.testng.TestRunner.run(TestRunner.java:596)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Starting ChromeDriver 114.0.5735.90
。也许驱动程序文件的属性指向错误的位置?
- Chaosfire 2023-08-16
问题:您使用的selenium(4.8.2
)版本不支持最新的浏览器。
解决方案:升级到支持此浏览器版本的selenium最新版本(JAVA版为4.11.0
,PYTHON版为4.11.2
)。
使用最新版本为我工作
使用最新版本的selenium
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.11.0</version>
</dependency>
使用最新版本的 webdriver 管理器
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.4.1</version>
<scope>test</scope>
</dependency>
https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java https://github.com/bonigarcia/webdrivermanager
这些都是所有软件qa公司在chrome浏览器更新时面临的常见问题。 我们需要更新 chromedriver.exe w.r.t 的 chrome 浏览器版本(版本:115 或最新)。
从日志中我们可以观察到chrome驱动版本没有更新:
启动 ChromeDriver:114.0.5735.90
当前浏览器版本:116.0.5845.97
注意:如果您已经更新了 chrome 驱动程序并遇到相同的问题,请在任务管理器中检查 chromedriver.exe 线程并将其终止。 或在命令提示符中执行以下命令以关闭所有 chromedriver.exe 线程并构建应用程序。 “taskkill /F /IM ChromeDriver.exe /T”
将 Selenium 版本升级到最新版本并升级 Selenium Manager
对我来说,当我尝试更新 selenium 和 webdriver 的版本(selenium 的最新版本)时,它就能正常工作了。
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.11.0</version>
</dependency>
最新版本的 webdriver 管理器
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.4.1</version>
<scope>test</scope>
</dependency>
如果 src\test\java 中不存在该文件,则也将其创建。
如果您使用的是 selenide 库,请将其更新到最新版本 6.17.1
有一个新的下载端点,这就是 bonigarcia lib 无法下载最新驱动程序版本的原因。你可以在官方页面查看:
新页面:https://googlechromelabs.github.io/chrome-for-testing/
官方页面: https://chromedriver.chromium.org/downloads
当前版本,如果您使用的是 Chrome 版本 115 或更高版本,请参阅 Chrome 测试可用性仪表板。此页面为特定 ChromeDriver 版本下载提供方便的 JSON 端点。