Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: #14417

Closed
AlexWhitham opened this issue Aug 21, 2024 · 14 comments
Closed

[🐛 Bug]: #14417

AlexWhitham opened this issue Aug 21, 2024 · 14 comments

Comments

@AlexWhitham
Copy link

AlexWhitham commented Aug 21, 2024

What happened?

Running in a docker container on python:3-slim.
After the Chrome version changed from major 126 to 127 webdriver wouldn't instantiate. If I change the version back to 126, all goes well.

Chrome and Chrome driver versions are 127.0.6533.119

Docker container: Linux, python

How can we reproduce the issue?

FROM python:3-slim

ENV CHROME_DRIVER_DIR=/usr/bin

RUN apt-get -yq update && apt-get install -yq unzip curl gnupg jq git build-essential

# Install latest Chrome
# Using direct ubuntu deb package because googlechromelabs package
# requires too many extra libraries to be preinstalled and as a result
# chrome still crashes and not working for selenium
# LATEST_CHROME_VERSION=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json | jq -r '.channels.Stable.version')
# https://github.com/GoogleChromeLabs/chrome-for-testing/issues/55
RUN LATEST_CHROME_VERSION_DEB="https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" \
  && curl -o /tmp/chrome.deb $LATEST_CHROME_VERSION_DEB \
  && apt-get install -yq /tmp/chrome.deb \
  && rm /tmp/chrome.deb \
  && google-chrome --version

# 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 -sSL -o /tmp/chromedriver.zip "$CHROMEDRIVER_URL" \
  && unzip /tmp/chromedriver.zip chromedriver-linux64/chromedriver -d "${CHROME_DRIVER_DIR}" \
  && ln -s "${CHROME_DRIVER_DIR}"/chromedriver-linux64/chromedriver "${CHROME_DRIVER_DIR}"/chromedriver \
  && rm /tmp/chromedriver.zip \
  && chromedriver --version

# set display port to avoid crash and dbus env to avoid hanging
ENV DISPLAY=:99
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null

ARG SELENIUM_VERSION
COPY requirements-${SELENIUM_VERSION}.txt /tmp/requirements.txt
COPY selenium-smoke-test.py /tmp/

RUN cd /tmp \
  && pip install --upgrade pip \
  && pip install -r requirements.txt \
  && timeout --foreground --verbose 10 python3 selenium-smoke-test.py --chrome_driver_path "${CHROME_DRIVER_DIR}/chromedriver" --google_chrome_path "$(which google-chrome-stable)"

RUN mkdir /code
WORKDIR /code


--------------


import argparse
import subprocess

import selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service

TEST_URL = "https://www.google.com/"
CHROME_OPTIONS_LIST = [
    "--headless",
    "--no-sandbox",
    "--disable-dev-shm-usage",
    "--window-size=1920,1080",
]


def main(_args):
    chrome_driver_path = _args.chrome_driver_path
    chrome_binary_path = _args.google_chrome_path
    list_versions(chrome_driver_path, chrome_binary_path)

    chrome_options = Options()
    [chrome_options.add_argument(option) for option in CHROME_OPTIONS_LIST]
    chrome_options.binary_location = chrome_binary_path

    selenium_version = int(str(selenium.__version__)[0])

    if selenium_version <= 3:
        driver = webdriver.Chrome(
            executable_path=chrome_driver_path, options=chrome_options
        )
    else:
        service = Service(chrome_driver_path)
        # service = webdriver.ChromeService(
        #     service_args=['--log-level=INFO'], log_output=subprocess.STDOUT
        # )
        driver = webdriver.Chrome(service=service, options=chrome_options)

    driver.maximize_window()
    driver.get(TEST_URL)
    driver.quit()

Relevant log output

7.355 ChromeDriver 127.0.6533.119 (bdef6783a05f0b3f885591e7d2c7b2aec1a89dea-refs/branch-heads/6533@{#1999})
7.383 Google Chrome 127.0.6533.119 
7.386 Creating driver instance
7.387 Selenium version 4
7.605 Starting ChromeDriver 127.0.6533.119 (bdef6783a05f0b3f885591e7d2c7b2aec1a89dea-refs/branch-heads/6533@{#1999}) on port 58889
7.605 Only local connections are allowed.
7.605 Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
7.618 ChromeDriver was started successfully.
7.680 [1724161347.412][INFO]: [44c4b3b1eb309c0ded7c60af221eeb9c] COMMAND InitSession {
7.680    "capabilities": {
7.680       "alwaysMatch": {
7.680          "browserName": "chrome",
7.680          "browserVersion": null,
7.680          "goog:chromeOptions": {
7.680             "args": [ "--headless", "--no-sandbox", "--disable-dev-shm-usage", "--window-size=1920,1080" ],
7.680             "binary": "/usr/bin/google-chrome-stable",
7.680             "extensions": [  ]
7.680          },
7.680          "pageLoadStrategy": "normal"
7.680       },
7.680       "firstMatch": [ {
7.680       } ]
7.680    }
7.680 }
7.681 [1724161347.413][INFO]: Populating Preferences file: {
7.681    "alternate_error_pages": {
7.681       "enabled": false
7.681    },
7.681    "autofill": {
7.681       "enabled": false
7.681    },
7.681    "browser": {
7.681       "check_default_browser": false
7.681    },
7.681    "distribution": {
7.681       "import_bookmarks": false,
7.681       "import_history": false,
7.681       "import_search_engine": false,
7.681       "make_chrome_default_for_user": false,
7.681       "skip_first_run_ui": true
7.681    },
7.681    "dns_prefetching": {
7.681       "enabled": false
7.681    },
7.681    "profile": {
7.681       "content_settings": {
7.681          "pattern_pairs": {
7.681             "https://*,*": {
7.681                "media-stream": {
7.681                   "audio": "Default",
7.681                   "video": "Default"
7.681                }
7.681             }
7.681          }
7.681       },
7.681       "default_content_setting_values": {
7.681          "geolocation": 1
7.681       },
7.681       "default_content_settings": {
7.681          "geolocation": 1,
7.681          "mouselock": 1,
7.681          "notifications": 1,
7.681          "popups": 1,
7.681          "ppapi-broker": 1
7.681       },
7.681       "password_manager_enabled": false
7.681    },
7.681    "safebrowsing": {
7.681       "enabled": false
7.681    },
7.681    "search": {
7.681       "suggest_enabled": false
7.681    },
7.681    "translate": {
7.681       "enabled": false
7.681    }
7.681 }
7.681 [1724161347.413][INFO]: Populating Local State file: {
7.681    "background_mode": {
7.681       "enabled": false
7.681    },
7.681    "ssl": {
7.681       "rev_checking": {
7.681          "enabled": false
7.681       }
7.681    }
7.681 }
7.682 [1724161347.414][INFO]: ChromeDriver supports communication with Chrome via pipes. This is more reliable and more secure.
7.682 [1724161347.414][INFO]: Use the --remote-debugging-pipe Chrome switch instead of the default --remote-debugging-port to enable this communication mode.
7.682 [1724161347.414][INFO]: Launching chrome: /usr/bin/google-chrome-stable --allow-pre-commit-input --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-dev-shm-usage --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-logging --headless --log-level=0 --no-first-run --no-sandbox --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.vdJffZ --window-size=1920,1080 data:,
7.918 [1724161347.650][INFO]: resolved localhost to ["::1","127.0.0.1"]
17.20 timeout: sending signal TERM to command ‘python3’

Operating System

Linux

Selenium version

3 and 4

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

Major version 127 and up

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

Major version 127 and up

Are you using Selenium Grid?

No response

Copy link

@AlexWhitham, 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!

@diemol
Copy link
Member

diemol commented Aug 21, 2024

I don't see how this is a Selenium issue. Can you please elaborate?

@AlexWhitham
Copy link
Author

AlexWhitham commented Aug 21, 2024

The Selenium webdriver won't instantiate. It works with Chrome major version 126 but not 127. As I understand it, because it is a Selenium webdriver - it is a Selenium issue, no? Also Chrome and Chrome driver instantiate correctly with no issues

@diemol
Copy link
Member

diemol commented Aug 21, 2024

Aside from the link I shared in the other issue, what else have you tried to understand the root cause? Have you tried the options I shared in the link?

@AlexWhitham
Copy link
Author

I tried to set versions of Chrome and Chrome driver to ensure the problem is occurring only starting from 127. I tried 128 as well and I got the same result. I did use the options but it didn't help.

@AlexWhitham
Copy link
Author

Because there is no error, if I remove the timeout it just keeps running forever, I have no way to understand what is going on.

@diemol
Copy link
Member

diemol commented Aug 21, 2024

What happens when you run that code outside of a Docker container?

@AlexWhitham
Copy link
Author

Well it needs to be run in a container, but I will give it a go locally

@VietND96
Copy link
Member

7.682 [1724161347.414][INFO]: Launching chrome: /usr/bin/google-chrome-stable --allow-pre-commit-input --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-dev-shm-usage --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-logging --headless --log-level=0 --no-first-run --no-sandbox --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.vdJffZ --window-size=1920,1080 data:,

Can you update argument --headless to --headless=new ?

@AlexWhitham
Copy link
Author

Thank you @VietND96 just tried that, didn't help

@AlexWhitham
Copy link
Author

It did work locally @diemol ... I am going to explode. I guess I need a different container setup. Thanks!

@diemol
Copy link
Member

diemol commented Aug 21, 2024

What was the issue?

@AlexWhitham
Copy link
Author

Not sure yet, but I guess the container itself is the issue, since it is working locally

@AlexWhitham
Copy link
Author

The issue was ENV DISPLAY=:99 🤦🏼‍♀️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants