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]: Issue with SergeyPirogov/webdriver_manager#687 #14750

Closed
jackpeikun opened this issue Nov 12, 2024 · 10 comments
Closed

[🐛 Bug]: Issue with SergeyPirogov/webdriver_manager#687 #14750

jackpeikun opened this issue Nov 12, 2024 · 10 comments
Labels
I-question Applied to questions. Issues should be closed and send the user to community resources.

Comments

@jackpeikun
Copy link

What happened?

Background

I am trying to setup a docker image so I can run my python application anywhere

DockerFile

FROM python:3.12-slim

# Set the working directory in the container
WORKDIR /app

# Copy only requirements.txt first to take advantage of Docker's cache
COPY requirements.txt /app/

# Install any necessary dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application files into the container
COPY . /app

# Create the logs directory
RUN mkdir -p /app/logs

# Set the environment variable to not buffer Python output
ENV PYTHONUNBUFFERED=1

# Run the application (adjust the command based on your app's entry point)
CMD ["python", "main.py"]

My requirements.txt

boto3~=1.35.58
requests~=2.32.3
cachetools~=5.5.0
selenium~=4.25.0
webdriver-manager
python-dotenv~=1.0.1

How I start my Driver

    options = Options()
    options.add_argument('--headless=new')
    options.add_argument(f'user-agent={TEST_HEADER.get("User-Agent")}')  # necessary when the website has javascript
    options.add_argument('--disable-gpu')
    options.add_argument('--no-sandbox')  # Important for running in Docker
    options.add_argument('--verbose')

    driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options)

Error log from docker

2024-11-12 11:18:27 ====== WebDriver manager ======
2024-11-12 11:18:27 Get LATEST chromedriver version for google-chrome
2024-11-12 11:18:27 About to download new driver from https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip
2024-11-12 11:18:28 Driver downloading response is 200
2024-11-12 11:18:28 Get LATEST chromedriver version for google-chrome
2024-11-12 11:18:28 Get LATEST chromedriver version for google-chrome
2024-11-12 11:18:28 Driver has been saved in cache [/root/.wdm/drivers/chromedriver/linux64/114.0.5735.90]
2024-11-12 11:18:28 Error during loading or interaction: Message: Service /root/.wdm/drivers/chromedriver/linux64/114.0.5735.90/chromedriver unexpectedly exited. Status code was: -5
2024-11-12 11:18:28  Traceback (most recent call last):
2024-11-12 11:18:28   File "/app/main.py", line 296, in <module>
2024-11-12 11:18:28     driver, session = create_new_driver_and_session(cache)
2024-11-12 11:18:28                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-11-12 11:18:28   File "/app/main.py", line 131, in create_new_driver_and_session
2024-11-12 11:18:28     new_webdriver = login_and_return_driver()
2024-11-12 11:18:28                     ^^^^^^^^^^^^^^^^^^^^^^^^^
2024-11-12 11:18:28   File "/app/main.py", line 168, in login_and_return_driver
2024-11-12 11:18:28     driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options)
2024-11-12 11:18:28              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-11-12 11:18:28   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
2024-11-12 11:18:28     super().__init__(
2024-11-12 11:18:28   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 55, in __init__
2024-11-12 11:18:28     self.service.start()
2024-11-12 11:18:28   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/common/service.py", line 105, in start
2024-11-12 11:18:28     self.assert_process_still_running()
2024-11-12 11:18:28   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/common/service.py", line 118, in assert_process_still_running
2024-11-12 11:18:28     raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
2024-11-12 11:18:28 selenium.common.exceptions.WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/114.0.5735.90/chromedriver unexpectedly exited. Status code was: -5

How can we reproduce the issue?

basically setup the same docker and file and you should be able to re-produce it

Relevant log output

2024-11-12 11:18:27 ====== WebDriver manager ======
2024-11-12 11:18:27 Get LATEST chromedriver version for google-chrome
2024-11-12 11:18:27 About to download new driver from https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip
2024-11-12 11:18:28 Driver downloading response is 200
2024-11-12 11:18:28 Get LATEST chromedriver version for google-chrome
2024-11-12 11:18:28 Get LATEST chromedriver version for google-chrome
2024-11-12 11:18:28 Driver has been saved in cache [/root/.wdm/drivers/chromedriver/linux64/114.0.5735.90]
2024-11-12 11:18:28 Error during loading or interaction: Message: Service /root/.wdm/drivers/chromedriver/linux64/114.0.5735.90/chromedriver unexpectedly exited. Status code was: -5
2024-11-12 11:18:28  Traceback (most recent call last):
2024-11-12 11:18:28   File "/app/main.py", line 296, in <module>
2024-11-12 11:18:28     driver, session = create_new_driver_and_session(cache)
2024-11-12 11:18:28                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-11-12 11:18:28   File "/app/main.py", line 131, in create_new_driver_and_session
2024-11-12 11:18:28     new_webdriver = login_and_return_driver()
2024-11-12 11:18:28                     ^^^^^^^^^^^^^^^^^^^^^^^^^
2024-11-12 11:18:28   File "/app/main.py", line 168, in login_and_return_driver
2024-11-12 11:18:28     driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options)
2024-11-12 11:18:28              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-11-12 11:18:28   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
2024-11-12 11:18:28     super().__init__(
2024-11-12 11:18:28   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 55, in __init__
2024-11-12 11:18:28     self.service.start()
2024-11-12 11:18:28   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/common/service.py", line 105, in start
2024-11-12 11:18:28     self.assert_process_still_running()
2024-11-12 11:18:28   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/common/service.py", line 118, in assert_process_still_running
2024-11-12 11:18:28     raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
2024-11-12 11:18:28 selenium.common.exceptions.WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/114.0.5735.90/chromedriver unexpectedly exited. Status code was: -5

Operating System

Running docker on MacOS 15.1

Selenium version

4.25.0

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

Chrome

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

chromedriver/linux64/114.0.5735.90/chromedrive

Are you using Selenium Grid?

No

Copy link

@jackpeikun, 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 diemol added I-question Applied to questions. Issues should be closed and send the user to community resources. and removed I-defect needs-triaging labels Nov 12, 2024
Copy link

💬 Please ask questions at:

@aleenprd
Copy link

wtf this issue keeps appearing and you guys are closing it with no explanations???

@diemol
Copy link
Member

diemol commented Nov 21, 2024

We shared links to our Slack channel, where you can join and ask for help. We also provide docker images that you can use. Hence, we do not triage any issues with custom-made docker images.

Join the Slack channel and we will happy to help.

@VietND96
Copy link
Member

Again, the issue with this line of code

driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options)

Similar to #14758
And you should report to lib that you are using SergeyPirogov/webdriver_manager#687
The same question is: Can you also try to adapt your test using selenium manager itself instead of relying on another external lib and it can repetitively occur?

@VietND96 VietND96 changed the title [🐛 Bug]: [🐛 Bug]: Issue with SergeyPirogov/webdriver_manager#687 Nov 21, 2024
@aleenprd
Copy link

aleenprd commented Nov 21, 2024

I just want to make a Docker image that has Python3.10 or later and can run Selenium with whatever browser and driver. I have hopelessly been trying this all day and I don't understand how the https://github.com/SeleniumHQ/docker-selenium project helps because I can't even use Pip properly with it.

Like seriously, I can't get these images to work at all. How is one supposed to use them? How does the image not come with Selenium installed in the first place??? :/

Traceback (most recent call last):
  File "/home/nace/main.py", line 1, in <module>
    from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'

It's all good. We can install it in a whacky way because pip doesn't work.

FROM selenium/standalone-chromium:latest
USER root
# Set working directory in user directory and copy app files
WORKDIR /home/nace
COPY app/ .
COPY requirements.txt .

# Upgrade pip
RUN apt-get update && apt install python-is-python3
# Just Selenium, nothing else
RUN pip install --break-system-packages -r requirements.txt 

And run -it i.e: docker build -t selenium:local . && docker run -it selenium:local /bin/bash && python main.py

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

# Configure Chrome options for Chromium
chrome_options = Options()
chrome_options.add_argument('--headless')  # Optional: Run without UI
chrome_options.add_argument('--no-sandbox')  # Required for some Linux environments
chrome_options.add_argument('--disable-dev-shm-usage')  # Helps with resource limitations

# Initialize WebDriver with Chromium
driver = webdriver.Chrome(options=chrome_options)

try:
    # Open a webpage
    url = "https://example.com"
    driver.get(url)

    # Print page title
    print(f"Page title: {driver.title}")

finally:
    # Always quit the driver
    driver.quit()

Well then, even this doesn't work...Unsupported architecture combination. Then why is there a Docker image for Chromium if it's not supported?


root@bc0bd95cfc31:/home/nace# python main.py 
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/selenium/webdriver/common/driver_finder.py", line 67, in _binary_paths
    output = SeleniumManager().binary_paths(self._to_args())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/selenium/webdriver/common/selenium_manager.py", line 47, in binary_paths
    args = [str(self._get_binary())] + args
                ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/selenium/webdriver/common/selenium_manager.py", line 94, in _get_binary
    raise WebDriverException(f"Unsupported platform/architecture combination: {sys.platform}/{arch}")
selenium.common.exceptions.WebDriverException: Message: Unsupported platform/architecture combination: linux/aarch64


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/nace/main.py", line 11, in <module>
    driver = webdriver.Chrome(options=chrome_options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/usr/local/lib/python3.12/dist-packages/selenium/webdriver/chromium/webdriver.py", line 50, in __init__
    if finder.get_browser_path():
       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/selenium/webdriver/common/driver_finder.py", line 47, in get_browser_path
    return self._binary_paths()["browser_path"]
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/selenium/webdriver/common/driver_finder.py", line 78, in _binary_paths
    raise NoSuchDriverException(msg) from err
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

@VietND96
Copy link
Member

Project https://github.com/SeleniumHQ/docker-selenium provide Selenium Server (Grid), and from your test will create a RemoteWebDriver - https://www.selenium.dev/documentation/webdriver/drivers/remote_webdriver/
In docker-selenium doesn't install Selenium python there.

@aleenprd
Copy link

Then why recommend that? The OP came with a Python issue.

Mattere not, managed to get Firefox running in Docker. Chrome or Chromium are a nightmare to set up.

@VietND96
Copy link
Member

Yes, it looks like your host is using ARM chip, that is the reason SM is looking for Chome in linux/arm64 (which is still not supported by Chrome, even docker image node-chromium is used), and could be seen via error selenium.common.exceptions.WebDriverException: Message: Unsupported platform/architecture combination: linux/aarch64

Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I-question Applied to questions. Issues should be closed and send the user to community resources.
Projects
None yet
Development

No branches or pull requests

4 participants