session not created: This version of ChromeDriver only supports Chrome version 114 – Python

by
Maya Patel
amazon-web-services boot2docker google-chrome llama-cpp-python selenium-webdriver

Quick Fix: Inspect the version of Chrome and install a compatible version of ChromeDriver by finding the download links for various versions of ChromeDriver using the provided API endpoint.

The Problem:

In a Docker container, a selenium test is failing with the error "session not created: This version of ChromeDriver only supports Chrome version 114", while the current Chrome version is 116.0.5845.96. The issue arises after a successful run.

The Solutions:

Solution 1: Use compatible versions of Chrome and ChromeDriver

The error “session not created: This version of ChromeDriver only supports Chrome version 114” indicates a version mismatch between the ChromeDriver and Chrome versions. To resolve this, you should ensure the ChromeDriver version is compatible with the installed Chrome version.

Follow these steps to troubleshoot and resolve the issue:

  1. Check Current Chrome Version:

    • Run the command "google-chrome –version" on the terminal.
    • Note the reported Chrome version (e.g., 116.0.5845.96).
  2. Find Compatible ChromeDriver Version:

    • Navigate to the ChromeDriver downloads page.
    • Locate the section titled "ChromeDriver 116 (Latest)".
    • Download the ChromeDriver version compatible with your Chrome version and operating system.
  3. Update ChromeDriver in Docker Image:

    • In your Dockerfile, locate the section where ChromeDriver is installed.
    • Replace the existing ChromeDriver download URL with the URL you obtained in step 2.
    • Rebuild the Docker image to install the compatible ChromeDriver version.
  4. Test Chrome and ChromeDriver Compatibility:

    • Create a simple Selenium script that launches a Chrome browser and performs a basic navigation.
    • Run the script to verify if Chrome and ChromeDriver are working correctly together without any version mismatch errors.

By following these steps, you can ensure that the versions of Chrome and ChromeDriver are compatible, resolving the "session not created" error and allowing you to run your Selenium tests successfully.

Solution 2: Use chromedriver from googlechromelabs.github.io

Use the `chromedriver_linux64` package from the `googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json` JSON file to download and install the latest compatible version of ChromeDriver. This package contains the `chromedriver` executable in a folder named `chromedriver-linux64`. Once downloaded and extracted, link it to `/usr/local/bin/chromedriver` for easy usage.

Solution 3: JSON API Endpoints

The release process for Chrome and Chromedriver has changed as of version 115, as per https://chromedriver.chromium.org/downloads/version-selection. To install the latest Chrome and Chromedriver in Docker, use the following commands:

# Install latest Chrome
RUN CHROME_URL=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.downloads.chrome[] | select(.platform == "linux64") | .url') \
    && curl -sSLf --retry 3 --output /tmp/chrome-linux64.zip "$CHROME_URL" \
    && unzip /tmp/chrome-linux64.zip -d /opt \
    && ln -s /opt/chrome-linux64/chrome /usr/local/bin/chrome \
    && rm /tmp/chrome-linux64.zip

# Install latest chromedriver
RUN CHROMEDRIVER_URL=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.downloads.chromedriver[] | select(.platform == "linux64") | .url') \
    && curl -sSLf --retry 3 --output /tmp/chromedriver-linux64.zip "$CHROMEDRIVER_URL" \
    && unzip -o /tmp/chromedriver-linux64.zip -d /tmp \
    && rm -rf /tmp/chromedriver-linux64.zip \
    && mv -f /tmp/chromedriver-linux64/chromedriver "/usr/local/bin/chromedriver" \
    && chmod +x "/usr/local/bin/chromedriver"

This approach utilizes JSON endpoints to ascertain the latest stable versions of Chrome and Chromedriver. The inspiration for this solution is derived from the response provided by Dr Nic, with the distinction that it employs the endpoint for retrieving the most recent (stable) versions.

Solution 4: Downgrading Chrome and Modifying Host File

To resolve the “session not created: This version of ChromeDriver only supports Chrome version 114” error, you can try the following steps:

  1. Downgrade Google Chrome:
  2. – Manually download an older version of Google Chrome that is compatible with your ChromeDriver version. For example, if your ChromeDriver is version 106, you can download Chrome version 106.

  3. Update Your Hosts File:
  4. – Open a terminal or command prompt and navigate to the directory where your hosts file is located. On Linux and macOS, it is usually located at /etc/hosts. On Windows, it is at C:\Windows\System32\drivers\etc\hosts.
    – Add the following line to the end of the hosts file: 127.0.0.1 tools.google.com. This prevents Chrome from accessing Google’s update URL, effectively disabling automatic updates.
    – Save and close the hosts file.

  5. Restart Chrome:
  6. – Quit the currently running instance of Chrome.
    – Launch the downgraded version of Chrome.

  7. Verify the Chrome Version:
  8. – Open Chrome and go to the “About Google Chrome” page (Settings > Help > About Google Chrome).
    – Ensure that the version displayed matches the version of Chrome you downgraded to.

After following these steps, try running your Selenium scripts again. If everything is set up correctly, the error should be resolved. Remember that this solution involves modifying system files and downgrading software, so it’s essential to proceed with caution and consider alternative solutions if possible.

Solution 5: Upgrade selenium version

The error “session not created: This version of ChromeDriver only supports Chrome version 114” indicates that the currently installed version of Selenium is incompatible with the version of Chrome that is being used. To resolve this issue, upgrade the Selenium version to `v4.11.2` or later. This should resolve the issue and allow you to successfully create a session with Chrome.

Q&A

What is the error I am getting?

The error says that the version of ChromeDriver (114) does not match the version of Chrome (116).

How can I fix the error?

You can fix the error by installing the correct version of ChromeDriver (116) that matches the version of Chrome (116).

What are the steps to install the correct version of ChromeDriver?

You can find the steps to install the correct version of ChromeDriver on the ChromeDriver downloads page.

Video Explanation:

The following video, titled "How To Fix SessionNotCreatedException: This version of ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

How To Fix SessionNotCreatedException: This version of ChromeDriver only supports Chrome version. 3.5K views · 1 year ago ...more ...