@@ -25,25 +25,6 @@ class BehatCommand extends AbstractMoodleCommand
2525{
2626 use ExecuteTrait;
2727
28- /**
29- * Selenium legacy Firefox image.
30- */
31- private string $ seleniumLegacyFirefoxImage = 'selenium/standalone-firefox:2.53.1 ' ;
32-
33- /**
34- * Selenium standalone Firefox image.
35- *
36- * @todo: Make this configurable.
37- */
38- private string $ seleniumFirefoxImage = 'selenium/standalone-firefox:3 ' ;
39-
40- /**
41- * Selenium standalone Chrome image.
42- *
43- * @todo: Make this configurable.
44- */
45- private string $ seleniumChromeImage = 'selenium/standalone-chrome:3 ' ;
46-
4728 /**
4829 * Wait this many microseconds for Selenium server to start/stop.
4930 *
@@ -150,13 +131,7 @@ private function startServerProcesses(InputInterface $input): void
150131 $ profile = getenv ('MOODLE_BEHAT_DEFAULT_BROWSER ' ) ?: (getenv ('MOODLE_APP ' ) ? 'chrome ' : 'firefox ' );
151132 }
152133
153- if ($ profile === 'chrome ' ) {
154- $ image = $ this ->seleniumChromeImage ;
155- } elseif ($ this ->usesLegacyPhpWebdriver ()) {
156- $ image = $ this ->seleniumLegacyFirefoxImage ;
157- } else {
158- $ image = $ this ->seleniumFirefoxImage ;
159- }
134+ $ image = $ this ->getSeleniumImage ($ profile );
160135
161136 $ cmd = [
162137 'docker ' ,
@@ -226,4 +201,23 @@ private function usesLegacyPhpWebdriver(): bool
226201
227202 return strpos (file_get_contents ($ composerlock ), 'instaclick/php-webdriver ' ) !== false ;
228203 }
204+
205+ private function getSeleniumImage (string $ profile ): string
206+ {
207+ $ image = getenv ('MOODLE_BEHAT_SELENIUM_IMAGE ' );
208+
209+ if (!empty ($ image )) {
210+ return $ image ;
211+ }
212+
213+ if ($ profile === 'chrome ' ) {
214+ return getenv ('MOODLE_BEHAT_SELENIUM_CHROME_IMAGE ' ) ?: 'selenium/standalone-chrome:3 ' ;
215+ }
216+
217+ if ($ this ->usesLegacyPhpWebdriver ()) {
218+ return 'selenium/standalone-firefox:2.53.1 ' ;
219+ }
220+
221+ return getenv ('MOODLE_BEHAT_SELENIUM_FIREFOX_IMAGE ' ) ?: 'selenium/standalone-firefox:3 ' ;
222+ }
229223}
0 commit comments