Skip to content

Commit 1b33894

Browse files
authored
Selenium debug via VNC viewer (#3)
1 parent 613ddbb commit 1b33894

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

.env.dist

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
WEB_PORT=8080
22
MYSQL_PORT=3306
3-
CHROME_PORT=9515
3+
SELENIUM_PORT=4444
4+
VNC_PORT=5900
45
BASE_URI=http://127.0.0.1:8080
56
UID=1000
67
GID=1000
8+
9+
## HEADLESS CHROME
10+
# SELENIUM_IMAGE=selenium/standalone-chrome
11+
# MINK_DRIVER_ARGS_WEBDRIVER='["chrome", {"browserName":"chrome", "goog:chromeOptions":{"args":["--no-sandbox", "--disable-dev-shm-usage", "--headless"], "w3c": false}}, "http://127.0.0.1:4444/wd/hub"]'
12+
13+
## CHROME DEBUG
14+
# SELENIUM_IMAGE=selenium/standalone-chrome-debug
15+
# MINK_DRIVER_ARGS_WEBDRIVER='["chrome", {"browserName":"chrome", "goog:chromeOptions":{"args":["--no-sandbox", "--disable-dev-shm-usage"], "w3c": false}}, "http://127.0.0.1:4444/wd/hub"]'
16+
17+
## FIREFOX DEBUG
18+
# SELENIUM_IMAGE=selenium/standalone-firefox-debug
19+
# MINK_DRIVER_ARGS_WEBDRIVER='["firefox", {"browserName":"firefox"}, "http://127.0.0.1:4444/wd/hub"]'

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ phpunit app/core/tests/Drupal/Tests/Core/DrupalKernel/
7878
## Debugging
7979

8080
Xdebug can be enabled for HTTP requests via the Xdebug helper browser extension:
81-
81+
8282
* Firefox - [Xdebug Helper for Firefox](https://addons.mozilla.org/en-US/firefox/addon/xdebug-helper-for-firefox/)
8383
* Chrome - [Xdebug helper](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc)
8484

@@ -92,6 +92,14 @@ docker-compose exec php-cli bash
9292
XDEBUG_SESSION=1 phpunit app/core/tests/Drupal/Tests/Core/DrupalTest.php --filter=testSetContainer
9393
```
9494

95+
## Debugging WebDriver tests with Selenium and VNC
96+
97+
The `.env.dist` file contains examples for how to configure the `selenium` service to use either
98+
Chrome or Firefox in debug mode. This exposes a VNC port (default 5900) that you can connect to
99+
in order to see tests running in the browser. Using a VNC client such as Remmina or VNC Viewer,
100+
simply connect to port `127.0.0.1:5900` with the password `secret`. If you've changed the `VNC_PORT`
101+
environment variable be sure to connect to that port instead.
102+
95103
## Contributing
96104

97105
Once you're up and running you'll have Drupal core checked out in the app directory. From here you

docker-compose.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ services:
44
ports:
55
- "${WEB_PORT:-8080}:8080"
66
- "${MYSQL_PORT:-3306}:3306"
7-
- "${CHROME_PORT:-9515}:9515"
7+
- "${SELENIUM_PORT:-4444}:4444"
8+
- "${VNC_PORT:-5900}:5900"
89
extra_hosts:
910
- "host.docker.internal:host-gateway"
1011
volumes:
@@ -37,6 +38,7 @@ services:
3738
environment:
3839
- DRUSH_OPTIONS_URI=${BASE_URI:-http://127.0.0.1:8080}
3940
- BROWSERTEST_OUTPUT_BASE_URL=${BASE_URI:-http://127.0.0.1:8080}
41+
- MINK_DRIVER_ARGS_WEBDRIVER
4042
- PHP_IDE_CONFIG=serverName=localhost
4143
volumes:
4244
- ./:/data
@@ -45,6 +47,6 @@ services:
4547
image: skpr/mtk-mysql-empty:latest
4648
network_mode: service:nginx
4749

48-
chrome:
49-
image: drupalci/webdriver-chromedriver:production
50+
selenium:
51+
image: ${SELENIUM_IMAGE:-selenium/standalone-chrome}
5052
network_mode: service:nginx

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
1919
<env name="MINK_DRIVER_CLASS" value=""/>
2020
<env name="MINK_DRIVER_ARGS" value=""/>
21-
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox", "--disable-dev-shm-usage"], "w3c": false}}, "http://127.0.0.1:9515"]'/>
21+
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome", "goog:chromeOptions":{"args":["--headless", "--no-sandbox", "--disable-dev-shm-usage"], "w3c": false}}, "http://127.0.0.1:4444/wd/hub"]'/>
2222
</php>
2323
<testsuites>
2424
<testsuite name="unit">

0 commit comments

Comments
 (0)