SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.77k stars 8.2k forks source link

[🐛 Bug]: #14642

Closed jwillmer closed 3 weeks ago

jwillmer commented 3 weeks ago

What happened?

I use selenium in my .NET docker container together with chrome. My Dockerfile downloads the latest stable chrome and tries to find a matching chromedriver. This is usually not possible because chrome is to far ahead so there is a mismatch. However it seams to just work.

Now I switched Selenium Manager to offline mode and the communication fails. I know that Selenium Manager queries something online on my first execution but it is very quick, it definitely does not download a new driver. So I can't use the current chrome/driver combination offline. Since the communication is so quick I wonder why it does not work offline.

I have tried to install the correct chrome version that matches the chrome driver however it is very complicated since chrome does not provide older versions for OS installations. So I need to manually download the installation package. And in the end it fails since it does not include the dependencies for Chrome.

How can we reproduce the issue?

Install latest chrome and driver:

apt-get install -y google-chrome-stable
// ... failed to map driver version so we get the latest
DRIVERVER=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE");
wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$DRIVERVER/chromedriver_linux64.zip";
unzip /chromedriver/chromedriver* -d /app;
export PATH="/app:${PATH}"

Set SE_OFFLINE=true


### Relevant log output

```shell
root@1955dcb6a325:/app# google-chrome --version
Google Chrome 130.0.6723.69
root@1955dcb6a325:/app# chromedriver --version
ChromeDriver 114.0.5735.90 (386bc09e8f4f2e025eddae123f36f6263096ae49-refs/branch-heads/5735@{#1052})
{
  "Type": "System.InvalidOperationException",
  "Message": "session not created: This version of ChromeDriver only supports Chrome version 114\nCurrent browser version is 130.0.6723.69 with binary path /usr/bin/google-chrome (SessionNotCreated)"
}
root@bb24bd6a7982:/app# ./selenium-manager/linux/selenium-manager --browser chrome --debug
[2024-10-24T13:10:36.627Z DEBUG] Found chromedriver 114.0.5735.90 in PATH: /app/chromedriver
[2024-10-24T13:10:36.627Z DEBUG] chrome detected at /usr/bin/google-chrome
[2024-10-24T13:10:36.628Z DEBUG] Running command: /usr/bin/google-chrome --version
[2024-10-24T13:10:36.647Z DEBUG] Output: "Google Chrome 130.0.6723.69 "
[2024-10-24T13:10:36.648Z DEBUG] Detected browser: chrome 130.0.6723.69
[2024-10-24T13:10:36.649Z WARN ] Exception managing chrome: Unable to discover proper chromedriver version in offline mode
[2024-10-24T13:10:36.649Z WARN ] The chromedriver version (114.0.5735.90) detected in PATH at /app/chromedriver might not be compatible with the detected chrome version (130.0.6723.69); currently, chromedriver  is recommended for chrome 130.*, so it is advised to delete the driver in PATH and retry
[2024-10-24T13:10:36.649Z INFO ] Driver path: /app/chromedriver
[2024-10-24T13:10:36.649Z INFO ] Browser path: /usr/bin/google-chrome
root@bb24bd6a7982:/app# SE_OFFLINE=false ./selenium-manager/linux/selenium-manager --browser chrome --debug
[2024-10-24T13:11:56.159Z DEBUG] Found chromedriver 114.0.5735.90 in PATH: /app/chromedriver
[2024-10-24T13:11:56.159Z DEBUG] chrome detected at /usr/bin/google-chrome
[2024-10-24T13:11:56.160Z DEBUG] Running command: /usr/bin/google-chrome --version
[2024-10-24T13:11:56.180Z DEBUG] Output: "Google Chrome 130.0.6723.69 "
[2024-10-24T13:11:56.181Z DEBUG] Detected browser: chrome 130.0.6723.69
[2024-10-24T13:11:56.181Z DEBUG] Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
[2024-10-24T13:11:58.959Z DEBUG] Required driver: chromedriver 130.0.6723.69
[2024-10-24T13:11:58.959Z WARN ] The chromedriver version (114.0.5735.90) detected in PATH at /app/chromedriver might not be compatible with the detected chrome version (130.0.6723.69); currently, chromedriver 130.0.6723.69 is recommended for chrome 130.*, so it is advised to delete the driver in PATH and retry
[2024-10-24T13:11:58.959Z INFO ] Driver path: /app/chromedriver
[2024-10-24T13:11:58.959Z INFO ] Browser path: /usr/bin/google-chrome


### Operating System

Ubuntu

### Selenium version

Selenium.WebDriver 4.19.0

### What are the browser(s) and version(s) where you see this issue?

Google Chrome 130.0.6723.69

### What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 114.0.5735.90

### Are you using Selenium Grid?

-
github-actions[bot] commented 3 weeks ago

@jwillmer, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

jwillmer commented 3 weeks ago

I use the following now to get exact version matches so the issue is resolved for me:

RUN npx @puppeteer/browsers install chrome@stable && \
    npx @puppeteer/browsers install chromedriver@stable