skip to Main Content

The process started from chrome location /opt/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed) error message appeared while running UI test cases using selenium , python and chrome driver)

I am attempting to run the test cases using Selenium Python via Docker and am encountering several difficulties.

Here is tech stalk information,

Selenium: 4.12.0

Python version: 3.10

Chrome Driver:

117.0.5938.88

Chrome Binary:

117.0.5938.88

Docker File:

FROM public.ecr.aws/lambda/python:3.9.2023.04.17.20 as build
RUN yum install -y unzip && 
    curl -Lo "/tmp/chromedriver-linux64.zip" "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/117.0.5938.88/linux64/chromedriver-linux64.zip" && 
    curl -Lo "/tmp/chrome-linux64.zip" "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/117.0.5938.88/linux64/chrome-linux64.zip" && 
    unzip /tmp/chromedriver-linux64.zip -d /opt/ && 
    unzip /tmp/chrome-linux64.zip -d /opt/

FROM public.ecr.aws/lambda/python:3.9.2023.04.17.20
RUN yum install -q atk cups-libs gtk3 libXcomposite alsa-lib 
    libXcursor libXdamage libXext libXi libXrandr libXScrnSaver 
    libXtst pango at-spi2-atk libXt xorg-x11-server-Xvfb 
    xorg-x11-xauth dbus-glib dbus-glib-devel -y

COPY --from=build /opt/chrome-linux64 /opt/chrome
COPY --from=build /opt/chromedriver-linux64 /opt/

COPY pyproject.toml ./
COPY src ./src

COPY ./modernca.cer ./artifactory_ng.crt
COPY ./requirementss.txt ./
COPY ./.netrc /root/.netrc
RUN chmod 600 /root/.netrc

RUN  CERT_PATH="./artifactory_ng.crt" NODE_EXTRA_CA_CERTS=${CERT_PATH} REQUESTS_CA_BUNDLE=${CERT_PATH} NO_VERIFY_SSL=true pip install -q -r requirementss.txt
RUN pip install datadog-lambda ddtrace
RUN rm -rf artifactory_ng.crt
RUN rm -rf /root/.netrc

RUN yum update -y libcurl curl python-libs python libxml2 openssl-libs openssl nss-sysinit nss nss-tools libdb-utils libdb cpio ca-certificates
COPY --from=public.ecr.aws/datadog/lambda-extension:latest /opt/extensions/ /opt/extensions

#CMD [ "datadog_lambda.handler.handler" ]
CMD [ "src.lambdas.ui_automation.handler" ]

When I run the test case in local it is working fine without any issues,

But same test case is failing when running in the docker.

I open the docker locally and I see the folder opt/chrome/chrome..

my selenium driver

from seleniumwire.webdriver import ChromeOptions
from selenium.webdriver.chrome.service import Service

options = ChromeOptions()
options.binary_location = '/opt/chrome/chrome'
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')        
chrome_driver_service = Service(executable_path='/opt/chromedriver')
driver = webdriver.Chrome(service=chrome_driver_service,
                                      options=options
                                      )

2

Answers


  1. You can also use SeleniumBase in wire mode + headless mode, which works on any environment.

    pip install seleniumbase – and run with python:

    from seleniumbase import Driver
    
    driver = Driver(wire=True, headless=True)
    try:
        driver.get("https://wikipedia.org")
        for request in driver.requests:
            print(request.url)
    finally:
        driver.quit()
    

    The output I got for that:

    https://wikipedia.org/
    https://www.wikipedia.org/
    https://www.wikipedia.org/portal/wikipedia.org/assets/js/index-6852360a56.js
    https://www.wikipedia.org/portal/wikipedia.org/assets/img/[email protected]
    https://www.wikipedia.org/portal/wikipedia.org/assets/js/gt-ie9-ce3fe8e88d.js
    https://www.wikipedia.org/portal/wikipedia.org/assets/img/sprite-8bb90067.svg
    https://www.wikipedia.org/portal/wikipedia.org/assets/img/[email protected]
    
    Login or Signup to reply.
  2. Try to run the ChromeDriver with the --whitelisted-ips flag (see https://stackoverflow.com/a/57328161/1288109 ).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search