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
- Moodle jobs: Full-time eLearning Consultant – Full-time – Telecommute – 20th January 2025
- Moodle jobs: Moodle UX/UI designer – Contract – Remote – 7th December 2024
- PHP 8.0 Model Classes with constructor promotion – 24th November 2024