From 9787b28601a52bf0832af085785ef1a9c90bc296 Mon Sep 17 00:00:00 2001 From: Amitai Burstein Date: Thu, 14 Aug 2025 11:27:45 +0300 Subject: [PATCH 1/2] Re-add Selenium files Re-run ddev add-on get ddev/ddev-selenium-standalone-chrome --- .../addon-template/manifest.yaml | 9 -------- .../manifest.yaml | 19 +++++++++++++++++ .ddev/config.selenium-standalone-chrome.yaml | 12 +++++++++-- .ddev/docker-compose.selenium-chrome.yaml | 21 +++++++++++-------- ...docker-compose.selenium-chrome_extras.yaml | 5 +++++ 5 files changed, 46 insertions(+), 20 deletions(-) delete mode 100644 .ddev/addon-metadata/addon-template/manifest.yaml create mode 100644 .ddev/addon-metadata/ddev-selenium-standalone-chrome/manifest.yaml create mode 100644 .ddev/docker-compose.selenium-chrome_extras.yaml diff --git a/.ddev/addon-metadata/addon-template/manifest.yaml b/.ddev/addon-metadata/addon-template/manifest.yaml deleted file mode 100644 index 3121ee08e..000000000 --- a/.ddev/addon-metadata/addon-template/manifest.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: addon-template -repository: ddev/ddev-selenium-standalone-chrome -version: 1.0.3 -install_date: "2023-06-27T14:41:55+01:00" -project_files: - - docker-compose.selenium-chrome.yaml - - config.selenium-standalone-chrome.yaml -global_files: [] -removal_actions: [] diff --git a/.ddev/addon-metadata/ddev-selenium-standalone-chrome/manifest.yaml b/.ddev/addon-metadata/ddev-selenium-standalone-chrome/manifest.yaml new file mode 100644 index 000000000..557419856 --- /dev/null +++ b/.ddev/addon-metadata/ddev-selenium-standalone-chrome/manifest.yaml @@ -0,0 +1,19 @@ +name: ddev-selenium-standalone-chrome +repository: ddev/ddev-selenium-standalone-chrome +version: 2.0.0-rc2 +install_date: "2025-08-14T11:26:49+03:00" +project_files: + - docker-compose.selenium-chrome.yaml + - config.selenium-standalone-chrome.yaml +global_files: [] +removal_actions: + - | + #ddev-nodisplay + #ddev-description:Remove docker-compose.selenium-chrome_extras.yaml file + if [ -f docker-compose.selenium-chrome_extras.yaml ]; then + if grep -q '#ddev-generated' docker-compose.selenium-chrome_extras.yaml; then + rm -f docker-compose.selenium-chrome_extras.yaml + else + echo "Unwilling to remove '$DDEV_APPROOT/.ddev/docker-compose.selenium-chrome_extras.yaml' because it does not have #ddev-generated in it; you can manually delete it if it is safe to delete." + fi + fi diff --git a/.ddev/config.selenium-standalone-chrome.yaml b/.ddev/config.selenium-standalone-chrome.yaml index 7f5336b42..842c650b8 100644 --- a/.ddev/config.selenium-standalone-chrome.yaml +++ b/.ddev/config.selenium-standalone-chrome.yaml @@ -1,3 +1,7 @@ +#ddev-generated +# Remove the line above if you don't want this file to be overwritten when you run +# ddev get ddev/ddev-selenium-standalone-chrome +# # This file comes from https://github.com/ddev/ddev-selenium-standalone-chrome # web_environment: @@ -8,16 +12,20 @@ web_environment: # Use disable-dev-shm-usage instead of setting shm_usage # https://developers.google.com/web/tools/puppeteer/troubleshooting#tips # The format of chromeOptions is defined at https://chromedriver.chromium.org/capabilities - - MINK_DRIVER_ARGS_WEBDRIVER=[\"chrome\", {\"browserName\":\"chrome\",\"chromeOptions\":{\"w3c\":false,\"args\":[\"--window-size=1920,1080\", \"--disable-gpu\", \"--no-sandbox\", \"--disable-dev-shm-usage\"]}}, \"http://selenium-chrome:4444/wd/hub\"] + - MINK_DRIVER_ARGS_WEBDRIVER=[\"chrome\", {\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"w3c\":true,\"args\":[\"--disable-dev-shm-usage\",\"--disable-gpu\",\"--headless\",\"--dns-prefetch-disable\"]}}, \"http://selenium-chrome:4444/wd/hub\"] # Nightwatch - DRUPAL_TEST_BASE_URL=http://web - DRUPAL_TEST_DB_URL=mysql://db:db@db/db - DRUPAL_TEST_WEBDRIVER_HOSTNAME=selenium-chrome - DRUPAL_TEST_WEBDRIVER_PORT=4444 - DRUPAL_TEST_WEBDRIVER_PATH_PREFIX=/wd/hub + - DRUPAL_TEST_WEBDRIVER_W3C=true + # --window-size=1920,1080 is needed to fix random timeouts in tests. See: https://community.latenode.com/t/selenium-webdriver-timeout-issue-when-running-in-headless-mode-with-c/21952/4 + - DRUPAL_TEST_WEBDRIVER_CHROME_ARGS=--disable-dev-shm-usage --disable-gpu --headless --dns-prefetch-disable --window-size=1920,1080 - DRUPAL_TEST_CHROMEDRIVER_AUTOSTART=false - DRUPAL_NIGHTWATCH_SEARCH_DIRECTORY=../ - DRUPAL_NIGHTWATCH_IGNORE_DIRECTORIES=node_modules,vendor,.*,sites/*/files,sites/*/private,sites/simpletest - DRUPAL_NIGHTWATCH_OUTPUT=reports/nightwatch + # DTT - DTT_BASE_URL=http://web - - DTT_MINK_DRIVER_ARGS=[\"chrome\", {\"browserName\":\"chrome\",\"chromeOptions\":{\"w3c\":false,\"args\":[\"--window-size=1920,1080\", \"--disable-gpu\", \"--no-sandbox\", \"--disable-dev-shm-usage\"]}}, \"http://selenium-chrome:4444/wd/hub\"] + - DTT_MINK_DRIVER_ARGS=[\"chrome\", {\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"w3c\":true,\"args\":[\"--disable-dev-shm-usage\",\"--disable-gpu\",\"--headless\",\"--dns-prefetch-disable\"]}}, \"http://selenium-chrome:4444/wd/hub\"] diff --git a/.ddev/docker-compose.selenium-chrome.yaml b/.ddev/docker-compose.selenium-chrome.yaml index 4ce4b691e..1a67ffe19 100644 --- a/.ddev/docker-compose.selenium-chrome.yaml +++ b/.ddev/docker-compose.selenium-chrome.yaml @@ -1,9 +1,12 @@ +#ddev-generated +# Remove the line above if you don't want this file to be overwritten when you run +# ddev get ddev/ddev-selenium-standalone-chrome +# # This file comes from https://github.com/ddev/ddev-selenium-standalone-chrome # -version: '3.6' services: selenium-chrome: - image: seleniarm/standalone-chromium:4.1.4-20220429 + image: selenium/standalone-chromium:138.0 container_name: ddev-${DDEV_SITENAME}-selenium-chrome expose: # The internal noVNC port, which operates over HTTP so it can be exposed @@ -13,17 +16,17 @@ services: - VIRTUAL_HOST=$DDEV_HOSTNAME - HTTPS_EXPOSE=7900:7900 - HTTP_EXPOSE=7910:7900 - - SCREEN_WIDTH=1920 - - SCREEN_HEIGHT=1080 - external_links: - - ddev-router:${DDEV_SITENAME}.${DDEV_TLD} - #ports: - # VNC access for a traditional VNC client like macOS "Screen Sharing". - # - "5900:5900" + - VNC_NO_PASSWORD=1 + # To enable VNC access for traditional VNC clients like macOS "Screen Sharing", + # uncomment the following two lines. + #ports: + # - "5900:5900" labels: com.ddev.site-name: ${DDEV_SITENAME} com.ddev.approot: $DDEV_APPROOT volumes: + # To enable file uploads in E2E tests. + - ${DDEV_APPROOT}:/var/www/html:r - ".:/mnt/ddev_config" web: diff --git a/.ddev/docker-compose.selenium-chrome_extras.yaml b/.ddev/docker-compose.selenium-chrome_extras.yaml new file mode 100644 index 000000000..4b8e2336f --- /dev/null +++ b/.ddev/docker-compose.selenium-chrome_extras.yaml @@ -0,0 +1,5 @@ +#ddev-generated +services: + selenium-chrome: + external_links: + - "ddev-router:${DDEV_PROJECT}.${DDEV_TLD}" From f3f4a8abca6a99c9121d552c4e9dc4d086106594 Mon Sep 17 00:00:00 2001 From: Amitai Burstein Date: Thu, 14 Aug 2025 11:48:28 +0300 Subject: [PATCH 2/2] Adapt README --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 60dd29a8a..ca2144035 100644 --- a/README.md +++ b/README.md @@ -210,10 +210,8 @@ See the [example](https://github.com/Gizra/drupal-starter/blob/main/web/modules/ # Run a single method from a test file. ddev phpunit --filter testHomepageCache web/modules/custom/server_general/tests/src/ExistingSite/ServerGeneralHomepageTest.php -We also have capability to write tests which run on a headless chrome browser with -Javascript capabilities. See [`Drupal\Tests\server_general\ExistingSite\ServerGeneralSelenium2TestBase`](https://github.com/Gizra/drupal-starter/blob/aa3c204dc7ac279964a694c675c35062c7fbcd9f/web/modules/custom/server_general/tests/src/ExistingSite/ServerGeneralSelenium2TestBase.php) -for the test base, and [`Drupal\Tests\server_general\ExistingSite\ServerGeneralHomepageTest`](https://github.com/Gizra/drupal-starter/blob/aa3c204dc7ac279964a694c675c35062c7fbcd9f/web/modules/custom/server_general/tests/src/ExistingSite/ServerGeneralHomepageTest.php) for the -example implementation. +We also have capability to write tests which run on a headless Chrome browser with +Javascript capabilities. See [`ServerGeneralHomepageTest`](https://github.com/Gizra/drupal-starter/blob/aa3c204dc7ac279964a694c675c35062c7fbcd9f/web/modules/custom/server_general/tests/src/ExistingSite/ServerGeneralHomepageTest.php) for an example. ### Debugging @@ -221,7 +219,7 @@ When it is hard to understand a test failure, a peek into the browser might help For Selenium-based ones, you can take screenshots using the `takeScreenshot()` method. This captures and saves the screenshot in `/web/sites/simpletest/screenshots`. You can also watch what the tests are doing in the browser using noVNC. To do so, simply open a browser and open -https://drupal-starter.ddev.site:7900 and click Connect. The password is `secret`. Now simply run the tests +https://drupal-starter.ddev.site:7900 and click Connect. Now run the tests and you can see the test running in the browser. For faster, virtual browser-based tests, you can use `createHtmlSnapshot` and it will dump the HTML content