0

in my local test the code is perfectly worked but when i build the docker, after run a docker image,

"selenium.common.exceptions.WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/114.0.5735.90/chromedriver unexpectedly exited. Status code was: 255"

is occured

this is my Dockerfile

FROM python:3.11.4-slim

WORKDIR /app

COPY elasticModule.py /app/elasticModule.py
COPY slackMessage.py /app/slackMessage.py
COPY elasticMain.py /app/elasticMain.py
COPY requirements.txt /app/requirements.txt

RUN pip install -r requirements.txt

CMD ["python", "elasticMain.py"]

and also this is my make webdriver code

options = Options()   
options.add_experimental_option("detach", True)
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)    
    
driver.get(url)

somebody help..

i already try lot's of things.. but it's not work on docker container

1 Answers1

0

This error message...

selenium.common.exceptions.WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/114.0.5735.90/chromedriver unexpectedly exited. Status code was: 255

...implies that WebDriverException was raised as chromedriver unexpectedly exited.

As per the discussion Message: Service /root/.local/share/undetected_chromedriver/ae9b10e548ec168c_chromedriver unexpectedly exited. Status code was: 255 this error can surface if the platform is and machine is aarch64 to indicate additional configuration and installs outside this package is required.


Solution

The easiest solution would be to download the ChromeDriver yourself from ChromeDriver-Downloads and pass the location through an instance of the Service object as follows:

options = Options()   
options.add_experimental_option("detach", True)
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")

driver = webdriver.Chrome(service=Service('/path/to/chromedriver'), options=options)    
driver.get(url)

Further, if you are using Selenium v4.6 or above you don't have to explicitly use ChromeDriverManager().install() anymore as Selenium Manager can silently download the matching ChromeDriver and your minimal code block can be:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
options.add_argument("--headless")
options.add_argument("--no-sandbox")
driver = webdriver.Chrome(options=options)
driver.get("https://google.com/")
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • thanks for help. but when i changed the code what you suggest from selenium import webdriver options = webdriver.ChromeOptions() options.add_experimental_option("detach", True) options.add_argument("--headless") options.add_argument("--no-sandbox") driver = webdriver.Chrome(options=options) driver.get("https://google.com/") like this [Errno 86] Bad CPU type in executable: '/Users/hanhyeonbin/Desktop/Automation/myenv/lib/python3.11/site-packages/selenium/webdriver/common/macos/selenium-manager' this error is occured – HanHyeonBIn Jul 22 '23 at 01:07