totara / totara-docker-dev

A docker setup to create a development environment for Totara Learn
MIT License
49 stars 32 forks source link

Selenium on M1 #212

Closed KevinHottinger closed 1 year ago

KevinHottinger commented 2 years ago

Currently the selenium image we use by default is not supported on M1 macs

 --- Failed hooks:

    BeforeScenario # behat_hooks::before_scenario()
      Resetting of Mink session failed (Exception)

To get around this we found switching to a different image 'seleniarm' which is experimental and community supported seems to resolve this.

Switched to seleniarm/standalone-chromium:4.3.0-20220624

See the Docs here: https://github.com/SeleniumHQ/docker-selenium#experimental-mult-arch-aarch64armhfamd64-images

Would it be possible to switch image versions based on a env variable?

derschatta commented 2 years ago

hm good catch. We would need to try this together I think. The alternative is to provide additional container definitions for arm in the compose files.

benfes commented 1 year ago

Just to add to this, I've found that seleniarm/standalone-chromium:4.3.0-20220624 - didn't work for me, however version seleniarm/standalone-chromium:106.0 did work - but config.php needs to be updated with the following settings:

// ...
if ($DOCKER_DEV->major_version >= 10) {
    // Behat config for Totara 10+
    $CFG->behat_profiles['default'] = array(
        'browser' => 'chrome',
        'wd_host' => "http://$DOCKER_DEV->behat_host:4444/wd/hub",
        'capabilities' => array(
            'browserName' => 'chrome',
            'browserVersion' => '106.0',
            'platform' => 'Linux',
            // 'version' => 50,
            // 'browser' => 'chrome',
            'extra_capabilities' => array(
 //...

Specifically browserName, browserVersion, platform

There are issues with some of the later chromium versions - so stick this this one (106) for now.

benfes commented 1 year ago

You'll also want to update the extra_capabilities to ensure chrome is matched for following session requests:

// ...
'extra_capabilities' => array(
        'alwaysMatch' => array(
                'browserName' => 'chrome',
        ),
// ...
derschatta commented 1 year ago

You'll also want to update the extra_capabilities to ensure chrome is matched for following session requests:

// ...
'extra_capabilities' => array(
        'alwaysMatch' => array(
                'browserName' => 'chrome',
        ),
// ...

If the capabilities 'browserName', 'browserVersion' and 'platform' is set correctly I don't think this is necessary. At least in my tests I did not need it.