Open nicoweb opened 5 years ago
Same here! My Docker Image is based on php:7.2-cli and has a slightly more complex environment. Nevertheless I managed to get my first functional tests working some days ago. Now I returned to that topic and now my first functional test with the PantherClient stopped working with the same exception as above.
As I used xDebug I had to change the environment to PANTHER_WEB_SERVER_PORT=9010
and created the PantherClient with static::createPanterClient('127.0.0.1', 9010, ['environment' => 'test'])
. With this settings, my first simple functional test worked as intended.
Apparently I catched an update as this call isn't valid any more.
So I changed to static::createPanterClient(['external_base_uri' => '127.0.0.1', 'port' => 9010], ['environment' => 'test'])
which should be the same, but with no success. Same if I remove the environment-variable and start with an empty options-array.
Also trying to connect to my webserver that is accessible at http://nginx:8102
in the container (verified with a direkt call to curl) with static::createPanterClient(['external_base_uri' => 'http://nginx', 'port' => 8102], ['environment' => 'test'])
does not work.
Edit: My error-message is a little bit longer, but basically the same:
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--headless","--window-size=1200,1100","--disable-gpu","--no-sandbox"]}}}
Operation timed out after 30000 milliseconds with 0 bytes received
It should be fixed in the last release (we now use a default port different than the XDebug one).
@dounglas: Sorry, but no. As you can see from my post I had it working with xDebug, deviating to port 9010. Migrating this to the new syntax did not work. I saw that the default port is now changed to 9080. So I also removed the port (also removed the environment-variable) and it still does not work.
Currently using panther 0.3.0 (as from composer.lock)
When following the $client->request() call with the debugger I stumbled over a default configuration in ChromeManager::getDefaultOptions() that uses port 9515. Not shure what this exactly means, but maybe this is a hint?
Ok it's not related to the webserver port, but to the one used by ChromeDriver to expose its own control API.
I assumed something like this, but wanted to make shure I don't miss a possible hint. But this leaves the problem still open. The call to $client->request() currently times out after 30s.
It probably means that ChromeDriver is down.
OK, so I followed the call a little bit further down the road:
Checked that chromedriver_linux64 is present
ChromeDriver::start() seems to wok
In RemoteWebDriver::create()' the call at line126
$response = $executor->execute($command);`
times out.
I found that the chromedriver version (2.37.544315) is not the currentmost. So I was curious what happens when I update that to 2.46.62388 (using Chrome 72 for which this is the current version suggested by Google). Now I get not timeout but an exception:
"unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.13.0-46-generic x86_64)"
... also checked the chromium version my docker container uses: 72.0.3626.96
But other than the changes from symfony/pather there were no changes to the docker-container since the tests ran in the past.
I have the same issue an not in docker Debian 9
Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--headless","--window-size=1200,1100","--disable-gpu"]}}}
Operation timed out after 30001 milliseconds with 0 bytes received
when I changed execution time https://github.com/symfony/panther/issues/155#issuecomment-474011523 now I have error
\PHP Fatal error: Uncaught Facebook\WebDriver\Exception\UnknownServerException: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Linux 4.9.0-8-amd64 x86_64) in /media/sf_prnt/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:114
Stack trace:
#0 /media/sf_prnt/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php(326): Facebook\WebDriver\Exception\WebDriverException::throwException(13, 'unknown error: ...', Array)
#1 /media/sf_prnt/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php(126): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand))
#2 /media/sf_prnt/vendor/symfony/panther/src/ProcessManager/ChromeManager.php(62): Facebook\WebDriver\Remote\RemoteWebDriver::create('http://127.0.0....', Object(Facebook\WebDriver\Remote\DesiredCapabilities), 600000, 600000)
#3 /media/sf_prnt/vendor/symfony/panther/src/Client.php(82): Symfony\Component\Panther\Pro in /media/sf_prnt/vendor/facebook/webdriver/lib/Exception/WebDriverException.php on line 114
Do I need any Desktop installed to use Panther?
I also upgraded the chromedriver to the one supporting Chrome 73 and sadly, I stumbled with this exception.
╳ invalid argument: invalid 'domain'
╳ (Session info: headless chrome=73.0.3683.103)
╳ (Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.15.0-47-generic x86_64) (Facebook\WebDriver\Exception\UnrecognizedExceptionException)
At this point looking that the Facebook Webdriver is old (using 1.6.0 released in March 2018), I don't think it has kept up with the times. I see development in their master branch but sadly we cannot upgrade (interface changes?).
Too many moving parts, hard to tell where the problem is...
Has anyone found a workaround?
@respinoza I've hit this problem as well. A workaround I've found is to manually set all the properties (domain, path, secure, httponly, expiry)
On my side I get an error on destruct:
PHP Fatal error: Uncaught Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http DELETE to /session/9dc6a482f043c2bc5bd06d67a38f85eb
Failed to connect to 127.0.0.1 port 9515: Connection refused in /srv/app/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:292
Stack trace:
#0 /srv/app/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php(547): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand))
#1 /srv/app/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php(289): Facebook\WebDriver\Remote\RemoteWebDriver->execute('quit')
#2 /srv/app/vendor/symfony/panther/src/Client.php(340): Facebook\WebDriver\Remote\RemoteWebDriver->quit()
#3 /srv/app/vendor/symfony/panther/src/Client.php(76): Symfony\Component\Panther\Client->quit()
#4 [internal function]: Symfony\Component\Panther\Client->__destruct()
#5 {main}
thrown in /srv/app/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php on line 292
If anyone got this error let me know please :D
Ok I misused panther. Usage of PantherTestCaseTrait solved my problem. Sorry for the interruption
@nicoweb I played a bit and i came with a quick workaround. You have to add the "--no-sandbox" option to your client. It prevent the timeout to happen.
You can do it like this :
$options = [
'--headless',
'--window-size=1200,1100',
'--no-sandbox',
'--disable-gpu'
];
$client = Client::createChromeClient(null, $options, [], 'http://your_uri');
$crawler = $client->request('GET', '/your_test_url');
//do your tests
Tell me if it works
it worked something like this:
(when using selenium from hub / standalone)
$chromeOptions = new ChromeOptions();
$chromeOptions->addArguments(['--no-sandbox', '--headless', '--window-size=1200,1100', '--disable-gpu']);
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions);
$client = PantherClient::createSeleniumClient(
'http://selenium:4444/wd/hub', // adjust this
$capabilities,
'http://test.my-domain.com' // adjust this
);
On my side I get an error on destruct:
PHP Fatal error: Uncaught Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http DELETE to /session/9dc6a482f043c2bc5bd06d67a38f85eb Failed to connect to 127.0.0.1 port 9515: Connection refused in /srv/app/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:292 Stack trace: #0 /srv/app/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php(547): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand)) #1 /srv/app/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php(289): Facebook\WebDriver\Remote\RemoteWebDriver->execute('quit') #2 /srv/app/vendor/symfony/panther/src/Client.php(340): Facebook\WebDriver\Remote\RemoteWebDriver->quit() #3 /srv/app/vendor/symfony/panther/src/Client.php(76): Symfony\Component\Panther\Client->quit() #4 [internal function]: Symfony\Component\Panther\Client->__destruct() #5 {main} thrown in /srv/app/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php on line 292
If anyone got this error let me know please :D
@tyx I have the same error, how did you solve it? just using PantherTestCaseTrait?
@qdequippe Exactly ! I was trying to make my own usage of panther. Using directly stuff in this Trait solve all my problem.
Hello,
I am encountering the same kind of errors reported above:
There was 1 error:
1) App\Tests\panther\MatchesTest::testIndex
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session/e29f5ab6b9a27f72718748867b9b999e/url with params: {"url":"https:\/\/_some_hostname_\/\/"}
Operation timed out after 30001 milliseconds with 0 bytes received
/var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331
/var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:590
/var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:252
/var/www/vendor/symfony/panther/src/Client.php:357
/var/www/vendor/symfony/panther/src/Client.php:251
/var/www/tests/panther/MatchesTest.php:14
There was 1 failure:
1) App\Tests\panther\MatchesTest::tearDownAfterClass
Exception in App\Tests\panther\MatchesTest::tearDownAfterClass
Curl error thrown for http DELETE to /session/e29f5ab6b9a27f72718748867b9b999e
Operation timed out after 30001 milliseconds with 0 bytes received
/var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331
/var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:590
/var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:315
/var/www/vendor/symfony/panther/src/Client.php:410
/var/www/vendor/symfony/panther/src/PantherTestCaseTrait.php:105
/var/www/vendor/symfony/panther/src/PantherTestCaseTrait.php:91
ERRORS!
Tests: 2, Assertions: 0, Errors: 1, Failures: 1.
PHP Fatal error: Uncaught Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http DELETE to /session/e29f5ab6b9a27f72718748867b9b999e
Operation timed out after 30001 milliseconds with 0 bytes received in /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331
Stack trace:
#0 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(590): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand))
#1 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(315): Facebook\WebDriver\Remote\RemoteWebDriver->execute('quit')
#2 /var/www/vendor/symfony/panther/src/Client.php(410): Facebook\WebDriver\Remote\RemoteWebDriver->quit()
#3 /var/www/vendor/symfony/panther/src/Client.php(88): Symfony\Component\Panther\Client->quit()
#4 [internal function]: Symfony\Component\Panther\Client->__destruct()
#5 {main}
thrown in /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php on line 331
Fatal error: Uncaught Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http DELETE to /session/e29f5ab6b9a27f72718748867b9b999e
Operation timed out after 30001 milliseconds with 0 bytes received in /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331
Stack trace:
#0 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(590): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand))
#1 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(315): Facebook\WebDriver\Remote\RemoteWebDriver->execute('quit')
#2 /var/www/vendor/symfony/panther/src/Client.php(410): Facebook\WebDriver\Remote\RemoteWebDriver->quit()
#3 /var/www/vendor/symfony/panther/src/Client.php(88): Symfony\Component\Panther\Client->quit()
#4 [internal function]: Symfony\Component\Panther\Client->__destruct()
#5 {main}
thrown in /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php on line 331
The stack is PHP 7.3, Symfony 5.1, Docker, PHPUnit 9.2.6 and Panther 0.7.1.
Here is part of the dockerfile:
FROM debian:stretch-slim
# Support for Ondrej Sury's repo
RUN apt-get update &&\
apt-get install -y --no-install-recommends ca-certificates apt-transport-https
COPY conf/sury.list /etc/apt/sources.list.d/sury.list
COPY conf/sury-archive.gpg /etc/apt/trusted.gpg.d/sury-archive.gpg
# PHP install
RUN apt-get update -qq && apt-get install -qqy software-properties-common
```docker
ENV PHP_VERSION=7.3
RUN mkdir /run/php && apt-get update -qq && apt-get install -qqy \
php$PHP_VERSION \
php$PHP_VERSION-cli \
php$PHP_VERSION-intl \
php$PHP_VERSION-mysql \
php$PHP_VERSION-curl \
php$PHP_VERSION-gd \
php$PHP_VERSION-xml \
php$PHP_VERSION-fpm \
php$PHP_VERSION-opcache \
php$PHP_VERSION-dev \
php$PHP_VERSION-mbstring \
php$PHP_VERSION-bcmath \
php$PHP_VERSION-amqp \
php$PHP_VERSION-sockets \
php$PHP_VERSION-redis \
php$PHP_VERSION-apcu
# Install Requirements
RUN apt-get update -qq && apt-get install -qqy \
sudo \
wget \
curl \
git \
apt-utils \
acl \
openssl \
nano \
htop \
netcat \
unzip \
re2c \
supervisor \
autoconf \
tzdata \
cron \
chromium \
chromedriver
# PANTHER DOCKER integration
# to disable Chrome's sandboxing (unsafe, but allows to use Panther in containers)
ENV PANTHER_NO_SANDBOX=1
# Not mandatory, but recommended
ENV PANTHER_CHROME_ARGUMENTS='--ignore-certificate-errors --disable-dev-shm-usage'
# Ensure we are using the installed driver, which should be of the same version as chromium
ENV PANTHER_CHROME_DRIVER_BINARY='/usr/bin/chromedriver'
Additionnaly, PANTHER_NO_HEADLESS=0
is set in the .env.test file.
The test is as follows:
<?php
namespace App\Tests\panther;
use Symfony\Component\Panther\PantherTestCase;
class MatchesTest extends PantherTestCase
{
public function testIndex(): void
{
$client = static::createPantherClient([
'external_base_uri' => 'https://__some_hostname__/',
'--headless',
'--no-sandbox',
'--disable-dev-shm-usage',
]);
$client->request('GET', '/');
$this->assertPageTitleSame('Some text');
}
}
@albaninho in Dockerfile try to also install following apt packages : libzip-dev
, zlib1g-dev
and phpzip
extension
Also try without --disable-dev-shm-usage
option
@domis86 I am getting the same errors after rebuilding the container with the suggestions you made :(
confirm, I have the same error. I try updated chrome version to 84 and chromedriver to latest - we have the same error. It is occur on some sites. try to load https://dengisrazy.ru/onlajn-zayavka
confirm, I have the same error. I try updated chrome version to 84 and chromedriver to latest - we have the same error. It is occur on some sites. try to load https://dengisrazy.ru/onlajn-zayavka
I have a solution, I set in options connection_timeout_in_ms=120000 and request_timeout_in_ms=120000 and now it's works fine
Hello,
I am encountering the same kind of errors reported above:
There was 1 error: 1) App\Tests\panther\MatchesTest::testIndex Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session/e29f5ab6b9a27f72718748867b9b999e/url with params: {"url":"https:\/\/_some_hostname_\/\/"} Operation timed out after 30001 milliseconds with 0 bytes received /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:590 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:252 /var/www/vendor/symfony/panther/src/Client.php:357 /var/www/vendor/symfony/panther/src/Client.php:251 /var/www/tests/panther/MatchesTest.php:14 There was 1 failure: 1) App\Tests\panther\MatchesTest::tearDownAfterClass Exception in App\Tests\panther\MatchesTest::tearDownAfterClass Curl error thrown for http DELETE to /session/e29f5ab6b9a27f72718748867b9b999e Operation timed out after 30001 milliseconds with 0 bytes received /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:590 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:315 /var/www/vendor/symfony/panther/src/Client.php:410 /var/www/vendor/symfony/panther/src/PantherTestCaseTrait.php:105 /var/www/vendor/symfony/panther/src/PantherTestCaseTrait.php:91 ERRORS! Tests: 2, Assertions: 0, Errors: 1, Failures: 1. PHP Fatal error: Uncaught Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http DELETE to /session/e29f5ab6b9a27f72718748867b9b999e Operation timed out after 30001 milliseconds with 0 bytes received in /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331 Stack trace: #0 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(590): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand)) #1 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(315): Facebook\WebDriver\Remote\RemoteWebDriver->execute('quit') #2 /var/www/vendor/symfony/panther/src/Client.php(410): Facebook\WebDriver\Remote\RemoteWebDriver->quit() #3 /var/www/vendor/symfony/panther/src/Client.php(88): Symfony\Component\Panther\Client->quit() #4 [internal function]: Symfony\Component\Panther\Client->__destruct() #5 {main} thrown in /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php on line 331 Fatal error: Uncaught Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http DELETE to /session/e29f5ab6b9a27f72718748867b9b999e Operation timed out after 30001 milliseconds with 0 bytes received in /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331 Stack trace: #0 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(590): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand)) #1 /var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(315): Facebook\WebDriver\Remote\RemoteWebDriver->execute('quit') #2 /var/www/vendor/symfony/panther/src/Client.php(410): Facebook\WebDriver\Remote\RemoteWebDriver->quit() #3 /var/www/vendor/symfony/panther/src/Client.php(88): Symfony\Component\Panther\Client->quit() #4 [internal function]: Symfony\Component\Panther\Client->__destruct() #5 {main} thrown in /var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php on line 331
The stack is PHP 7.3, Symfony 5.1, Docker, PHPUnit 9.2.6 and Panther 0.7.1.
Here is part of the dockerfile:
FROM debian:stretch-slim # Support for Ondrej Sury's repo RUN apt-get update &&\ apt-get install -y --no-install-recommends ca-certificates apt-transport-https COPY conf/sury.list /etc/apt/sources.list.d/sury.list COPY conf/sury-archive.gpg /etc/apt/trusted.gpg.d/sury-archive.gpg # PHP install RUN apt-get update -qq && apt-get install -qqy software-properties-common ```docker ENV PHP_VERSION=7.3 RUN mkdir /run/php && apt-get update -qq && apt-get install -qqy \ php$PHP_VERSION \ php$PHP_VERSION-cli \ php$PHP_VERSION-intl \ php$PHP_VERSION-mysql \ php$PHP_VERSION-curl \ php$PHP_VERSION-gd \ php$PHP_VERSION-xml \ php$PHP_VERSION-fpm \ php$PHP_VERSION-opcache \ php$PHP_VERSION-dev \ php$PHP_VERSION-mbstring \ php$PHP_VERSION-bcmath \ php$PHP_VERSION-amqp \ php$PHP_VERSION-sockets \ php$PHP_VERSION-redis \ php$PHP_VERSION-apcu # Install Requirements RUN apt-get update -qq && apt-get install -qqy \ sudo \ wget \ curl \ git \ apt-utils \ acl \ openssl \ nano \ htop \ netcat \ unzip \ re2c \ supervisor \ autoconf \ tzdata \ cron \ chromium \ chromedriver # PANTHER DOCKER integration # to disable Chrome's sandboxing (unsafe, but allows to use Panther in containers) ENV PANTHER_NO_SANDBOX=1 # Not mandatory, but recommended ENV PANTHER_CHROME_ARGUMENTS='--ignore-certificate-errors --disable-dev-shm-usage' # Ensure we are using the installed driver, which should be of the same version as chromium ENV PANTHER_CHROME_DRIVER_BINARY='/usr/bin/chromedriver'
Additionnaly,
PANTHER_NO_HEADLESS=0
is set in the .env.test file.The test is as follows:
<?php namespace App\Tests\panther; use Symfony\Component\Panther\PantherTestCase; class MatchesTest extends PantherTestCase { public function testIndex(): void { $client = static::createPantherClient([ 'external_base_uri' => 'https://__some_hostname__/', '--headless', '--no-sandbox', '--disable-dev-shm-usage', ]); $client->request('GET', '/'); $this->assertPageTitleSame('Some text'); } }
I have updated Panther to 0.8.0. I am still getting the same error. @xenolOnline I have tried this too, with no success. Furthermore in my opinion tests should not have to wait that long to begin their completion.
Hi everyone,
I try to run Panther on a new installation of Symfony (4.2). I have this error message when I start my tests :
My Dockerfile:
My test:
PS: I followed the recommended installation
Thanks for the help :)