Open uuf6429 opened 4 days ago
The MinkSeleniumDriver does this:
// Join $desiredCapabilities with defaultCapabilities
$desiredCapabilities = array_replace(self::getDefaultCapabilities(), $desiredCapabilities);
The self::getDefaultCapabilities()
method returns:
array(
'browserName' => 'firefox',
'name' => 'Behat Test',
);
So it's the array_replace
function logic, that decides what will happen. PHP documentation says, that it's non-recursive.
This way you can only fully override a particular capability. In case of moz:firefoxOptions
this means:
No nested merging.
@uuf6429 , Would such behavior cause any issues?
Ah, in WebdriverClassicDriver (this repo) you're doing different kind of merging. Anyway, we need to have a test to cover the correct default merging logic in either driver I guess.
https://github.com/minkphp/webdriver-classic-driver/blob/61b12d05f4185a1f9d0676fc66d559c1e435a97a/src/WebdriverClassicDriver.php#L801 ☝️ That condition means that we cannot overwrite capabilities by the php-webdriver - in case of Firefox, because of this: https://github.com/php-webdriver/php-webdriver/blob/4c18b78d93e4a724ad2dd6427ed658e61a45c569/lib/Remote/DesiredCapabilities.php#L299
For example, the following firefox capability change would not work:
(that also applies to the default one; we're not able to overwrite anything predefined in the php-webdriver defaults)
I think this code was copied from MinkSelenium2Driver, so I never really thought about it.
On a related note, I'm unsure how in general we are supposed to behave - should we be merging config, or generally overwriting it? That applies to php-webdriver defaults, our defaults and the end user's desired capaibilities.