skip to Main Content

I am running a Docker image from a Docker container in AWS Batch environment.
It was all working nicely for a while now, but since today I am getting the following error.

E   selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This 
version of ChromeDriver only supports Chrome version 114
E   Current browser version is 116.0.5845.96 with binary path /opt/google/chrome/google-chrome

The Dockerfile that has the chrome installation is as below

FROM python:3.10
WORKDIR /usr/src/app
COPY . .

RUN pip install --trusted-host pypi.org --upgrade pip
RUN pip install --no-cache-dir 
--extra-index-url https://artifactory.int.csgdev01.citcosvc.com/artifactory/api/pypi/citco- 
pypi/simple 
-r requirements.txt

RUN pip install awscli

RUN apt-get install -yqq unzip curl
RUN apt-get -y update
RUN apt-get install zip -y
RUN apt-get install unzip -y
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> 

/etc/apt/sources.list.d/google-chrome.list
RUN apt-get -y update
RUN apt-get -y install -y google-chrome-stable

# Install chrome driver
RUN wget -N https://chromedriver.storage.googleapis.com/`curl -sS 
chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip -P ~/
RUN unzip ~/chromedriver_linux64.zip -d ~/
RUN rm ~/chromedriver_linux64.zip
RUN mv -f ~/chromedriver /usr/local/bin/chromedriver
RUN chmod 0755 /usr/local/bin/chromedriver
RUN ls -lt
RUN ls -lt /usr/local/bin
RUN chmod +x ./run.sh
CMD ["bash", "./run.sh"]

My selenium python test class is below

from selenium import webdriver
import unittest
class Test_SecTransferWorkflow(unittest.TestCase):
    options = webdriver.ChromeOptions()
    options.add_argument('--no-sandbox')
    options.add_argument("--enable-javascript")
    options.add_argument("--start-maximized")
    options.add_argument("--incognito")
    options.add_argument('--headless')
    options.add_argument('--ignore-certificate-errors')
    options.add_argument('--enable-features=NetworkService')
    options.add_argument('--shm-size=1g')
    options.add_argument('--disable-gpu')
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_argument("--window-size=1920,1080")
    options.add_argument("--disable-extensions")
    options.add_argument('--disable-dev-shm-usage')
    options.add_experimental_option('useAutomationExtension', False)
    options.add_experimental_option("detach", True)
    options.add_argument('--allow-running-insecure-content')
    options.add_argument('--allow-insecure-localhost')
    options.add_argument('--ignore-ssl-errors=yes')
    options.add_argument('--user-agent=Chrome/77')
    driver = webdriver.Chrome(options=options)

    @classmethod
    def setUpClass(cls):
        try:
            cls.driver.delete_all_cookies()
            cls.driver.get(TestData_common.BASE_URL)
            time.sleep(2)
        except WebDriverException as e:
            print('Site down...> ', e)
            cls.driver.delete_all_cookies()
        time.sleep(3)

    def test_001_login(self):
        if not TestData_common.URL_FOUND:
            pytest.skip('Site seems to be down...')
        self.loginPage = LoginPage(self.driver)
        self.loginPage.do_click_agree_button()
        self.driver.maximize_window()
        print('Successfully clicked on AGREE button...')
        time.sleep(2)

I didn’t have any issues running this image so far, until I encountered this error today.
Any help is much appreciated.

2

Answers


  1. The versions of chrome (116) and chromedriver (114) do not match. This is because the latest version of chromedriver (as described by chromedriver.storage.googleapis.com/LATEST_RELEASE) is not necessarily always going to match the latest version of Chrome from the debian repo. Although these major versions will often match (which is why this has worked for you in the past), you cannot rely on this to be the case all the time, as you’re now seeing.

    Instead, you should inspect the version of chrome and then install an appropriate version of chromedriver. As described on the chromedriver downloads page, you can use their API endpoint to find download links for various versions of chromedriver or find the links on the dashboard, both of which will include links to download versions of chromedriver that are compatible with chrome 116 — for example at the time of writing: https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/linux64/chromedriver-linux64.zip (but be aware this zip structure may be different than the download links you’re already using).

    In my own dockerfile, I specify the chromedriver download URL manually and just run a script to test that the major versions match. Though, you could use the API endpoint mentioned above to automate getting the correct chromedriver URL.


    As for why chromedriver.storage.googleapis.com/LATEST_RELEASE points to major version 114 instead of 116, despite a download being available for 116 and the stable debian version being 116, I’m not really sure, to be honest.

    Login or Signup to reply.
  2. My guess is that you are on older version of selenium. Selenium version 4.10.0 or below will not support latest version of chrome browser.

    Solution: Upgrade selenium version to v4.11.2. This should resolve the issue.

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