Madhuka Pansuja
Madhuka Pansuja

Reputation: 1

ChromeDriver Compatibility Issue: Matching Chrome Version 132 with ChromeDriver 114 in Docker

I'm experiencing an issue where ChromeDriver in my Docker container is failing to work with the installed Chromium browser, which is deployed n a GCE instance which runs on Debian. The error message is:

Message: session not created: This version of ChromeDriver only supports Chrome version 114. Current browser version is 132.0.6834.83 with binary path /usr/bin/chromium.

I have the following setup in my Dockerfile:

Chromium version: 132.0.6834.83
ChromeDriver version: 132.0.6834.83

However, the error message suggests a mismatch with ChromeDriver expecting version 114, even though both the Chromium and ChromeDriver versions seem to be compatible.

Here’s what I’ve done so far:

What I need help with:

The error generates when the below code is executed

url = 'https://cse.lk/pages/trade-summary/trade-summary.component.html' 
driver = None

# Configure Chrome options for headless mode
chrome_options = Options()
chrome_options.add_argument("--headless")  # Uncomment this line for headless mode
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
# chrome_options.add_argument("--single-process")
chrome_options.add_argument("--disable-gpu")

try:
    # Debug log: Starting ChromeDriver setup
    print("Setting up ChromeDriver with configured options...")

    # Set up the driver with the configured options
    # driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) 
    driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=chrome_options)
    driver.get(url) 
    
    # Locate the select element by name
    print("Looking for the dropdown element...")
    select_element = Select(driver.find_element(By.NAME, "DataTables_Table_0_length"))
    
    # Select the option with value "All"
    print("Dropdown element found. Selecting 'All'...")
    select_element.select_by_value("-1")
    print("'All' option selected.")

    soup = BeautifulSoup(driver.page_source, 'html.parser')
    print("Page source parsed with BeautifulSoup.")

    if not soup:
        print("Failed to parse page. HTML source:")
        print(driver.page_source)

except NoSuchElementException as e:
    print(f"Element not found: {e}")
    soup = None  # Ensure soup is None if an error occurs

except Exception as e:
    print(f"An error occurred: {e}")
    soup = None  # Ensure soup is None if an error occurs

finally:
    # Ensure the driver is properly quit even if it's not initialized
    if driver is not None:
        print("Closing the browser...")
        driver.quit()
    else:
        print("Driver was not initialized. Skipping quit.")

The error response is

An error occurred: Message: session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 132.0.6834.83 with binary path /usr/bin/chromium Stacktrace:

Upvotes: 0

Views: 8610

Answers (2)

Muhammad Aslam
Muhammad Aslam

Reputation: 11

Set following environment variables in your docker file

# Set Selenium ChoremeDriver and Browser Path
ENV SE_CHROMEDRIVER=/chromedriverPath
ENV SE_AVOID_BROWSER_DOWNLOAD=true
ENV SE_BROWSER_PATH=/chromeBrowserPath
ENV SE_AVOID_STATS=true
ENV SE_OUTPUT=LOGGER
ENV SE_LANGUAGE_BINDING=java
RUN mkdir /tmp/cache-dir
ENV SE_CACHE_PATH=/tmp/driver
ENV SE_DRIVER=chromedriver

Upvotes: 1

Estiben Licona
Estiben Licona

Reputation: 1

"Starting with M115 the latest Chrome + ChromeDriver releases per release channel (Stable, Beta, Dev, Canary) are available at the Chrome for Testing availability dashboard. For automated version downloading one can use the convenient JSON endpoints." https://googlechromelabs.github.io/chrome-for-testing/

Upvotes: 0

Related Questions