Open superromeo opened 3 years ago
I replace container definition to this https://www.drupal.org/docs/automated-testing/phpunit-in-drupal/running-phpunit-javascript-tests#docker-compose And all works again!
New fix: See https://groups.google.com/g/chromedriver-users/c/3B1zixDQNSQ/m/_l0A3Ee4BgAJ
Add this:
chrome:
entrypoint:
...
- "--allowed-origins=*"
And alter to this:
SELENIUM_CHROME_TAG=99.0
Neither of previous solutions worked.
chrome:
image: selenium/standalone-chrome:$SELENIUM_CHROME_TAG
container_name: "${PROJECT_NAME}_chrome"
volumes:
- /dev/shm:/dev/shm
entrypoint:
- chromedriver
- "--no-sandbox"
- "--disable-dev-shm-usage"
- "--log-path=/tmp/chromedriver.log"
- "--verbose"
- "--whitelisted-ips="
- "--allowed-origins=*"
with SELENIUM_CHROME_TAG=103.0
works for me. It's important that --allowed-origins=*
without ''
. Wrong: --allowed-origins='*'
.
Hi !
Working on a new drupal4docker project,
with :
DRUPAL_TAG=10-4.71.2
PHP_TAG=8.3-dev-4.59.2
NGINX_TAG=1.26-5.35.0
NGINX_VHOST_PRESET=drupal10
SELENIUM_CHROME_TAG=3.141
I'm trying to run phpunit functionnal test using chrome.
On my compose.yml :
php:
image: wodby/drupal-php:$PHP_TAG
container_name: "${PROJECT_NAME}_php"
environment:
# By default xdebug extension also disabled.
PHP_EXTENSIONS_DISABLE: xhprof,spx
PHP_MAIL_MIXED_LF_AND_CRLF: On
# Mailhog:
MSMTP_HOST: mailhog
MSMTP_PORT: 1025
DB_HOST: $DB_HOST
DB_PORT: $DB_PORT
DB_USER: $DB_USER
DB_PASSWORD: $DB_PASSWORD
DB_NAME: $DB_NAME
DB_DRIVER: $DB_DRIVER
PHP_FPM_USER: wodby
PHP_FPM_GROUP: wodby
PHP_XDEBUG_MODE: debug
SIMPLETEST_BASE_URL: "http://nginx"
SIMPLETEST_DB: "${DB_DRIVER}://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}#tests_"
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-gpu","--headless"]}}, "http://chrome:9515"]'
volumes:
- ./:/var/www/html:cached
nginx:
image: wodby/nginx:$NGINX_TAG
container_name: "${PROJECT_NAME}_nginx"
depends_on:
- php
environment:
NGINX_STATIC_OPEN_FILE_CACHE: "off"
NGINX_ERROR_LOG_LEVEL: debug
NGINX_BACKEND_HOST: php
NGINX_SERVER_ROOT: /var/www/html/web
NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET
# NGINX_DRUPAL_FILE_PROXY_URL: http://example.com
volumes:
- ./:/var/www/html:cached
labels:
- "traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`)"
chrome:
image: selenium/standalone-chromium:latest
container_name: "${PROJECT_NAME}_chrome"
environment:
- SE_OPTS="--log-level FINE"
volumes:
- /dev/shm:/dev/shm
expose:
- 5900
- 4444
entrypoint:
- chromedriver
- "--no-sandbox"
- "--disable-dev-shm-usage"
- "--log-path=/tmp/chromedriver.log"
- "--verbose"
- "--whitelisted-ips="
- "--allowed-origins=*"
When i'm on my php container and i'm trying to run a phpunit
wodby@php.container:/var/www/html $ vendor/bin/phpunit -v tests/ExampleJavascriptTest.php
I got the following error :
PHPUnit 9.6.18 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.7
Configuration: /var/www/html/phpunit.xml
Testing Drupal\Tests\ExampleJavascriptTest
S 1 / 1 (100%)string(263) "Could not open connection: Curl error thrown for http POST to http://chrome:9515/session with params: {"desiredCapabilities":{"browserName":"chrome","name":"Behat Test","goog:chromeOptions":{"args":["--disable-gpu","--headless"]}}}
Could not resolve host: chrome"
Time: 00:13.385, Memory: 10.00 MB
There was 1 skipped test:
1) Drupal\Tests\ExampleJavascriptTest::testAjaxOnAddPage
The test wasn't able to connect to your webdriver instance. For more information read core/tests/README.md.
The original message while starting Mink: Could not open connection: Curl error thrown for http POST to http://chrome:9515/session with params: {"desiredCapabilities":{"browserName":"chrome","name":"Behat Test","goog:chromeOptions":{"args":["--disable-gpu","--headless"]}}}
Could not resolve host: chrome
/var/www/html/web/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:59
/var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php:372
/var/www/html/tests/ExampleJavascriptTest.php:50
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 1, Skipped: 1.
I don't understand why php container is not able to resolve "chrome", while all containers are under the same network...
If i ping chrome on php container, it works !
wodby@php.container:/var/www/html $ ping chrome
PING chrome (172.22.0.2): 56 data bytes
64 bytes from 172.22.0.2: seq=0 ttl=42 time=0.295 ms
64 bytes from 172.22.0.2: seq=1 ttl=42 time=0.160 ms
64 bytes from 172.22.0.2: seq=2 ttl=42 time=0.162 ms
If someone have an idea ? appreciate it
Please try to open port 9515, as it is being used. I also had some problems with Chrome connections, but that was more than a year ago. Since then, I have been using this configuration, and it still works fine.
chrome:
image: drupalci/webdriver-chromedriver:production
container_name: "${PROJECT_NAME}_chrome"
ulimits:
core:
soft: -1
hard: -1
ports:
- "4444:4444"
- "9515:9515"
entrypoint:
- chromedriver
- "--log-path=/tmp/chromedriver.log"
- "--verbose"
- "--whitelisted-ips="
Thanks @Niklan,
Port 9515 had to be opened for this to work ! I'm able to launch my functional tests, with the image selenium/standalone-chromium:latest
Another little mistery, I don't understand why I don't get any display in noVNC on port 7900.
Tests are running - but no display on NoVNC
If anyone has an idea ;)
Codebase Built-in vanilla Drupal
Describe your issue When I run functional JS test I have:
Output of
cat /tmp/chromedriver.log
on lom_chromeAnd after another single try I have new:
phpunit.xml
Output of
docker info
Contents of your
docker-compose.yml
Contents of your
.env
Logs output
docker-compose logs