Closed evan1108 closed 2 months ago
I'm attempting to create my own Docker image with SeleniumBase but I'm getting the following error:
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py", line 115, in assert_process_still_running
raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
selenium.common.exceptions.WebDriverException: Message: Service /root/.cache/selenium/chromedriver/linux64/123.0.6312.122/chromedriver unexpectedly exited. Status code was: 127
This is after copying most parts of the standard Dockerfile (minus the chrome and webdriver installs as I understand Seleniumbase / Selenium Manager handles that)
Dockerfile:
FROM ubuntu:20.04
ADD . /src
RUN apt update
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
#=======================================
# Install Python and Basic Python Tools
#=======================================
RUN apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update
RUN apt-get install -y python3 python3-pip python3-setuptools python3-dev python-distribute
RUN alias python=python3
RUN echo "alias python=python3" >> ~/.bashrc
#=================================
# Install Bash Command Line Tools
#=================================
RUN apt-get -qy --no-install-recommends install \
sudo \
unzip \
wget \
curl \
libxi6 \
libgconf-2-4 \
vim \
xvfb \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
#===========================
# Configure Virtual Display
#===========================
RUN set -e
RUN echo "Starting X virtual framebuffer (Xvfb) in background..."
RUN Xvfb -ac :99 -screen 0 1280x1024x16 > /dev/null 2>&1 &
RUN export DISPLAY=:99
RUN exec "$@"
#
#=======================
# Update Python Version
#=======================
RUN apt-get update -y
RUN apt-get -qy --no-install-recommends install python3.8
RUN rm /usr/bin/python3
RUN ln -s python3.8 /usr/bin/python3
RUN pip install -r ./src/requirements.txt
CMD python3 ./src/manage.py migrate && python3 ./src/manage.py selenium_worker
The entrypoint command is executing this:
class Command(BaseCommand):
def handle(self, *args, **options):
with SB("dummy") as sb:
print("Initializing global web driver")
settings.GLOBAL_WEB_DRIVER = sb
Which is what I see failing in the stack trace:
Operations to perform:
Apply all migrations: admin, auth, contenttypes, django_rq, sessions, socials
Running migrations:
No migrations to apply.
=========================== {manage.py:22:SB} starts ===========================
Warning: chromedriver not found. Getting it now:
*** chromedriver to download = 123.0.6312.122 (Latest Stable)
Downloading chromedriver-linux64.zip from:
https://storage.googleapis.com/chrome-for-testing-public/123.0.6312.122/linux64/chromedriver-linux64.zip ...
Download Complete!
Extracting ['chromedriver'] from chromedriver-linux64.zip ...
Unzip Complete!
The file [chromedriver] was saved to:
/usr/local/lib/python3.8/dist-packages/seleniumbase/drivers/chromedriver
Making [chromedriver 123.0.6312.122] executable ...
[chromedriver 123.0.6312.122] is now ready for use!
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/seleniumbase/core/browser_launcher.py", line 3797, in get_local_driver
driver = webdriver.Chrome(options=chrome_options)
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
super().__init__(
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chromium/webdriver.py", line 50, in __init__
self.service.start()
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py", line 102, in start
self.assert_process_still_running()
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py", line 115, in assert_process_still_running
raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
selenium.common.exceptions.WebDriverException: Message: Service /root/.cache/selenium/chromedriver/linux64/123.0.6312.122/chromedriver unexpectedly exited. Status code was: 127
Appreciate any direction you can provide!
I'm still working on updating the included Dockerfile
. Maybe you'll get it working before I do.
This was resolved in 4.25.4
- https://github.com/seleniumbase/SeleniumBase/releases/tag/v4.25.4
You are incredible @mdmintz! Confirmed it's working on my end. Thanks for the quick attention and fix.
I cloned the SeleniumBase repo, built the docker image
docker build --platform linux/amd64 -t seleniumbase .
, and ran the testdocker run --platform linux/amd64 seleniumbase ./run_docker_test_in_chrome.sh
I get an error saying Chrome has failed to start/crashed. I haven't made any changes to the Dockerfile. I've tried running the test without the --platform tag in thedocker run
command and that fails as well. Running on an M2 mac.