diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml
index 55d2ff3a6f42aba76b3974e33efed2be5fff1c40..e1248e18a812cefbb20bceb3498ebeceb256c1b8 100644
--- a/tests/acceptance/config/behat.yml
+++ b/tests/acceptance/config/behat.yml
@@ -27,14 +27,18 @@ default:
     Behat\MinkExtension:
       sessions:
         default:
-          selenium2: ~
+          selenium2:
+            wd_host: %selenium.server%
         John:
-          selenium2: ~
+          selenium2:
+            wd_host: %selenium.server%
         Jane:
-          selenium2: ~
+          selenium2:
+            wd_host: %selenium.server%
         Rubeus:
           # Rubeus uses a browser that has CSS grid support.
           selenium2:
+            wd_host: %selenium.server%
             capabilities:
               firefox:
                 profile: %paths.base%/firefox-profiles/css-grid-enabled.zip
diff --git a/tests/acceptance/run-local.sh b/tests/acceptance/run-local.sh
index eda119d74ccb77a268a2cec549c1394a7d03cef6..916b3b67db63a6457e1b32537a874293de2d2de0 100755
--- a/tests/acceptance/run-local.sh
+++ b/tests/acceptance/run-local.sh
@@ -172,32 +172,19 @@ FILE_CONTENTS=$(<$ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml)
 echo "${FILE_CONTENTS//$ORIGINAL/$REPLACEMENT}" > $ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml
 
 if [ "$SELENIUM_SERVER" != "$DEFAULT_SELENIUM_SERVER" ]; then
-	# Set the Selenium server to be used by Mink; this extends the default
-	# configuration from "config/behat.yml".
-	export BEHAT_PARAMS='
-{
-    "extensions": {
-        "Behat\\MinkExtension": {
-            "sessions": {
-                "default": {
-                    "selenium2": {
-                        "wd_host": "http://'"$SELENIUM_SERVER"'/wd/hub"
-                    }
-                },
-                "John": {
-                    "selenium2": {
-                        "wd_host": "http://'"$SELENIUM_SERVER"'/wd/hub"
-                    }
-                },
-                "Jane": {
-                    "selenium2": {
-                        "wd_host": "http://'"$SELENIUM_SERVER"'/wd/hub"
-                    }
-                }
-            }
-        }
-    }
-}'
+	# Set the Selenium server to be used by Mink. Although Mink sessions can be
+	# extended through BEHAT_PARAMS this would require adding here too each new
+	# session added to "behat.yml", including those added in the acceptance
+	# tests of apps. Instead, the default "behat.yml" configuration file is
+	# adjusted to replace the simulated "selenium.server" variable by its value
+	# before the configuration file is parsed by Behat.
+	ORIGINAL="wd_host: %selenium.server%"
+	REPLACEMENT="wd_host: http://$SELENIUM_SERVER/wd/hub"
+	# As the substitution does not involve regular expressions or multilines it
+	# can be done just with Bash. Moreover, this does not require escaping the
+	# regular expression characters that may appear in the URL, like "/".
+	FILE_CONTENTS=$(<$ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml)
+	echo "${FILE_CONTENTS//$ORIGINAL/$REPLACEMENT}" > $ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml
 fi
 
 composer install