Moodle Behat: Accessing host chromedriver from docker
From time to time, you may want Behat tests on your docker container to connect to chromedriver on your host so that you can easily debug a failing Behat test.
To do this, it is important that chromedriver is started as follows:
chromedriver –whitelisted-ips= –allowed-origins=host.docker.internal
Your Moodle Behat config will then need to reference your host. This is done by setting ‘wd_host’ to ‘host.docker.internal:9515’
$CFG->behat_profiles = [
‘default’ => [
‘browser’ => ‘chrome’,
‘tags’ => ‘@javascript’,
‘wd_host’ => ‘host.docker.internal:9515’
],
‘headless’ => [
‘browser’ => ‘chrome’,
‘wd_host’ => ‘host.docker.internal:9515’,
‘tags’ => ‘@javascript’,
‘capabilities’ => [
‘chrome’ => [
‘switches’ => [
‘–no-sandbox’,
‘–headless’,
‘–disable-gpu’
]
],
‘extra_capabilities’ => [
‘chromeOptions’ => [
‘args’ => [
‘headless’,
‘no-gpu’
]
]
]
]
]
];
Running Behat on your docker container with the profile flag “headless” will allow you to see the tests running on your host. E.g:
vendor/bin/behat –config /yourmoodlepath/behat/behatrun/behat/behat.yml –profile=headless Source: https://brudinie.medium.com/feed
- eLearning Producer (12-Month Contract) – 24th August 2025
- Job offered: eLearning Producer (12-Month Contract) – 25th July 2025
- QA engineer at Moodle HQ – 23rd June 2025