MDL-68525 behat: chrome/switches caps not allowed in Chrome > 81
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Sun, 26 Apr 2020 16:17:13 +0000 (18:17 +0200)
committerAndrew Nicols <andrew@nicols.co.uk>
Tue, 28 Apr 2020 04:31:58 +0000 (12:31 +0800)
Now we need to use extra_capabilities/chromeOptions/args instead

The former was deprecated long ago, it seems that Chrome 81 has
stopped accepting it. The later seems to be working at very least
since Chrome 76 (haven't gone further back).

lib/behat/classes/behat_config_util.php

index 8bd3815..095c0e2 100644 (file)
@@ -637,14 +637,17 @@ class behat_config_util {
             if (!isset($values['capabilities'])) {
                 $values['capabilities'] = [];
             }
-            if (!isset($values['capabilities']['chrome'])) {
-                $values['capabilities']['chrome'] = [];
+            if (!isset($values['capabilities']['extra_capabilities'])) {
+                $values['capabilities']['extra_capabilities'] = [];
             }
-            if (!isset($values['capabilities']['chrome']['switches'])) {
-                $values['capabilities']['chrome']['switches'] = [];
+            if (!isset($values['capabilities']['extra_capabilities']['chromeOptions'])) {
+                $values['capabilities']['extra_capabilities']['chromeOptions'] = [];
             }
-            $values['capabilities']['chrome']['switches'][] = '--unlimited-storage';
-            $values['capabilities']['chrome']['switches'][] = '--disable-web-security';
+            if (!isset($values['capabilities']['extra_capabilities']['chromeOptions']['args'])) {
+                $values['capabilities']['extra_capabilities']['chromeOptions']['args'] = [];
+            }
+            $values['capabilities']['extra_capabilities']['chromeOptions']['args'][] = '--unlimited-storage';
+            $values['capabilities']['extra_capabilities']['chromeOptions']['args'][] = '--disable-web-security';
 
             // If the mobile app is enabled, check its version and add appropriate tags.
             if ($mobiletags = $this->get_mobile_version_tags()) {