ppodgorsek / docker-robot-framework

Robot Framework in Docker
https://cloud.docker.com/repository/docker/ppodgorsek/robot-framework
MIT License
343 stars 239 forks source link

WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally. #324

Open abirlal opened 3 years ago

abirlal commented 3 years ago

After Selecting BROWSER=chrome getting error. Need help on it


Visit Google | FAIL | WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/lib/chromium/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Thanks in advance..!!

ppodgorsek commented 3 years ago

Do the logs show any specific message detailing the problem? You can view the logs by following the Troubleshooting section in the README.

ppodgorsek commented 3 years ago

What is the status of this issue? Has it been resolved and can it be closed?

mikevromen commented 3 years ago

Having the same issue, log folder stays empty.

Fixed it by making sure to chmod +x the .sh files

Abdulhakimsg commented 2 years ago

Hey all

Unfortunately I'm also encountering the same issue on both browser library and selenium library. The error above occurs only if browser chosen is chrome. Firefox works fine for both libraries.

Browser Library

image

Selenium Library

image

I built the docker image and ran the container on an M1 ARM Macbook Pro. So far this this the only machine that i've tested on and most of my friends and work mates also use this machine so i'm not able to test this out on a x86/linux/amd64 machine.I would appreciate if anyone could take the time to let me know if they are also facing the same issue as well!

I've already tried changing the shm-size to a larger value as well.

I am hoping to completely rely on docker fully and not have to install any dependencies locally on my machine.

Any help, explanation and advice would be appreciated! I've been thinking about this problem for days now.

ppodgorsek commented 2 years ago

Do the Chrome logs show any specific message detailing the problem? Could you post them here please? You can view the logs by following the Troubleshooting section in the README.

Abdulhakimsg commented 2 years ago

Thank you for your reply @ppodgorsek. Hoping this would help those who encounter this issue as well.

So i've managed to make it work. The issue lies with webdriver not being able to communicate with chrome as i'm running an M1 Arm mac. You cannot use the official selenium or chrome image. you have to use the arm64 compatible image from the link below

To solve this, what i did was to run a standalone seleniarm-chrome docker container

# in shell/terminal

# Run Selenium Server with Chromium in standalone mode
docker run --name seleniarm-chromium --rm -it -p 4444:4444 -p 5900:5900 -p 7900:7900 --shm-size 3g seleniarm/standalone-chromium:latest

After wards in my test, i have a condition that if i'm running my test locally on chrome, i will connect to that arm64 chromium selenium server. Else, i'll just rely on firefox running in the docker container.

// test.robot

*** Settings ***
Library         SeleniumLibrary

*** Variables ***
${BROWSER}    %{E2E_BROWSER}
${ENV}    %{APP_ENV}

*** Test Cases ***
Determine mode
    IF  "${BROWSER}" == 'chrome' and "${ENV}" == 'testing'
        ${chrome_options} =     Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
        Call Method    ${chrome_options}   add_argument    headless
        Call Method    ${chrome_options}   add_argument    disable-gpu
        ${options}    Call Method     ${chrome_options}    to_capabilities
        ${orig timeout} =   Set Selenium Timeout    15 seconds
        Open Browser    https://www.google.com    browser=${BROWSER}    remote_url=http://172.17.0.2:4444     desired_capabilities=${options}
    ELSE
        Open Browser    https://www.yahoo.com       ${BROWSER}
    END

Capture SS
    Capture Page Screenshot
    Close Browser
# in shell/terminal
#Run e2e test
docker run --rm --platform linux/amd64 --name e2e-test --env-file .env.testing \
-v `pwd`/e2e/reports:/opt/robotframework/reports:Z \
-v `pwd`/e2e:/opt/robotframework/tests:Z \
ppodgorsek/robot-framework:latest

This whole M1 Arm mac unable to run webdriver/chromium issue is documented in the links below

This workflow is working for me. Would it be possible for users to choose to download selenium NOT using the official docker image but from the docker-seleniarm image instead?

leiforion commented 1 year ago

A few notes for those that run into this, and clarifications from what are above:

Hope this helps.