symfony / panther

A browser testing and web crawling library for PHP and Symfony
MIT License
2.91k stars 213 forks source link

Facebook\WebDriver\Exception\UnknownErrorException: DevToolsActivePort file doesn't exist #536

Closed jmichaelterenin closed 2 years ago

jmichaelterenin commented 2 years ago

Environment: Laravel Sail (Windows 10 WSL2) PHP Version: 8.1 Laravel Version: 9.3

Chrome Browser (and Driver) Version: 99.0.4844.51 X-server: VcXsrv in Windows

I've been googling and trying to get Panther to work from a Laravel console command, and all I keep getting is this:

Facebook\WebDriver\Exception\UnknownErrorException

unknown error: Chrome failed to start: crashed. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

at vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:139 135▕ throw new UnexpectedAlertOpenException($message, $results); 136▕ case 'unknown command': 137▕ throw new UnknownCommandException($message, $results); 138▕ case 'unknown error': ➜ 139▕ throw new UnknownErrorException($message, $results); 140▕ case 'unknown method': 141▕ throw new UnknownMethodException($message, $results); 142▕ case 'unsupported operation': 143▕ throw new UnsupportedOperationException($message, $results);

I've tried all combinations of options listed here: // '--headless', // '--window-size=1200,1100', '--no-sandbox', // '--disable-gpu' // '--headless',
// '--privileged', // '--disable-setuid-sandbox',
'--disable-dev-shm-usage', // '--disable-gpu', along with the 2 that work from the command line (shelling into the environment) and running: google-chrome --no-sandbox --disable-dev-shm-usage with the $DISPLAY variable set to my windows IP address through this: export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0

I'm using the directions provided here: https://www.gregbrisebois.com/posts/chromedriver-in-wsl2/, running Chrome browser from the WSL using an X server.

I'm passing the appropriate ENV vars in from the Dockerfile:

# Chromium and ChromeDriver
ENV PANTHER_NO_SANDBOX 1
ENV DISPLAY=XXX.XXX.XXX.1:0.0`
ENV BROWSER_VERSION=99.0.4844.51
...

RUN apt-get update \
    && apt-get install wget \
    && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
    && apt install -y ./google-chrome-stable_current_amd64.deb \
    && wget https://chromedriver.storage.googleapis.com/{$BROWSER_VERSION}/chromedriver_linux64.zip \
    && unzip chromedriver_linux64.zip \
    && mv chromedriver /usr/local/bin/chromedriver \    
    && chmod +x /usr/local/bin/chromedriver

Has anyone experienced this and found an "actual" solution?

jmichaelterenin commented 2 years ago

https://github.com/symfony/panther/issues/447#issuecomment-860887193