skip to Main Content

I am running a Docker image, I am getting the following error.

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

Current browser version is 116.0.5845.96 with binary path /usr/bin/google-chrome
The Dockerfile that has the chrome installation is as below:

# Base image
FROM python:3.9

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

COPY . /app
COPY wait-for-it.sh /
COPY docker-entrypoint.sh /
WORKDIR /app

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# Install system dependencies
RUN apt-get update && apt-get install -y supervisor
RUN apt-get update && apt-get install -y supervisor curl unzip
# Install Chromium
RUN curl -sSL https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /chrome.deb
RUN dpkg -i /chrome.deb || apt-get install -fy
# Install ChromeDriver
RUN LATEST_VERSION=$(curl -sSL https://chromedriver.storage.googleapis.com/LATEST_RELEASE) && 
    curl -sSL https://chromedriver.storage.googleapis.com/$LATEST_VERSION/chromedriver_linux64.zip -o /chromedriver.zip && 
    unzip /chromedriver.zip -d /usr/bin && 
    chmod +x /usr/bin/chromedriver && 
    rm /chromedriver.zip

# Copy the supervisor configuration files
COPY _config/supervisor/django.conf /etc/supervisor/conf.d/
COPY _config/supervisor/celery.conf /etc/supervisor/conf.d/

EXPOSE 8000
RUN chmod +x /wait-for-it.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

My selenium python test class is below:
def connect_selenium():
    """
    Description: Connect to Selenium
    """
    options = webdriver.ChromeOptions()
    options.add_argument('--no-sandbox')
    options.add_argument('--disable-dev-shm-usage')
    options.add_argument('--headless')  # Add this line to run Chrome in headless mode
    options.add_argument('--disable-gpu')
    options.add_argument('--window-size=1920,1080')
    driver = webdriver.Chrome('/usr/bin/chromedriver', options=options)
    return driver

Any help is much appreciated.

2

Answers


    1. If nothing is working for you, then delete currently present chrome driver binary at /usr/bin/google-chrome.
    2. After that the location where chrome driver is present should be empty. Remove any other binary for chrome driver if present.
    3. Now simply try running any simple selenium test and the latest chrome driver will be downloaded automatically.
    Login or Signup to reply.
  1. Since you are using Chrome Version 116.0.5845.96 you cannot download the correct driver via https://chromedriver.storage.googleapis.com. They only support Chrome versions until 114.0.5735.90.
    To get the newest version, Google is providing this website: https://googlechromelabs.github.io/chrome-for-testing/
    there you can find the driver for version 116.0.5845.96.

    You should probably not always use the newest Chrome version since the drivers, as far as I know, are not updated as fast as Chrome itself. You could run into a situation where there is no driver for your Chrome version.

    As @Mukund wrote in his answer, you do not have to manually install drivers anymore if you are using Selenium 4.6.0 and above. Selenium provides the SeleniumManager which is handling the driver download for you.
    At least on Windows, I can confirm that SeleniumManager is working with 116.0.5845.96

    If it is not working for you, you could still download the correct driver manually.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search