Search code examples
selenium-webdriverselenium-java

Response code 500. Message: session not created: This version of ChromeDriver only supports Chrome version 114


I got hit by this issue with setting up the webdrivers. I had to update my Chrome to 116.0.5845.97. This is how my maven looks like :

<dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.10.0</version>
</dependency>
<dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>5.4.1</version>
</dependency>

Code for setting up the chrome Options and finally creating the webdriver:

if (browserName.equals("chrome")) {
                WebDriverManager.chromedriver().setup();
                ChromeOptions chromeOptions = new ChromeOptions();
                chromeOptions.addArguments(new String[]{"--incognito"});
                chromeOptions.addArguments(new String[]{"window-size=1980,1080"});
                chromeOptions.addArguments(new String[]{"--remote-allow-origins=*"});
                this.driver = new ChromeDriver(chromeOptions);
}

I am getting the following error:

Starting ChromeDriver 114.0.5735.90 (386bc09e8f4f2e025eddae123f36f6263096ae49-refs/branch-heads/5735@{#1052}) on port 9006
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

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 (x86)\Google\Chrome\Application\chrome.exe 

I have not been able to resolve this issue and hence reaching out to experts here.


Solution

  • Two issues:

    1. Selenium v4.10.0 supports only up to CDP 114, which means if your browser version is 116, then you need to upgrade selenium to 4.11.0 Update POM as below.
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>4.11.0</version>
    </dependency>
    
    1. If you are using selenium v4.6.0 and above, then you don't need WebDriverManager any more. Selenium has an inbuilt tool now to handle drivers. Remove the below line from your code, you don't need it.
    WebDriverManager.chromedriver().setup();