Dropping capabilities that can cause geckodriver to reject new session request because it performs additional capability matching. Honestly I see no reason at all why geckodriver does matching and rejects new session requests. It makes it toally useless in custom grid environments (in company, or cloud vendors) that often use non-standard platform names.
package org.openqa.selenium.firefox;
import static org.openqa.selenium.firefox.FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE;
+import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;
+import static org.openqa.selenium.remote.CapabilityType.BROWSER_VERSION;
+import static org.openqa.selenium.remote.CapabilityType.PLATFORM_NAME;
import static org.openqa.selenium.remote.CapabilityType.PROXY;
import com.google.common.collect.Maps;
@@ -193,15 +196,11 @@ private static Capabilities dropCapabilities(Capabilities capabilities) {
return new ImmutableCapabilities();
}
- MutableCapabilities caps;
-
- if (isLegacy(capabilities)) {
- final Set<String> toRemove = Sets.newHashSet(BINARY, PROFILE);
- caps = new MutableCapabilities(
+ final Set<String> toRemove = isLegacy(capabilities)
+ ? Sets.newHashSet(BINARY, PROFILE)
+ : Sets.newHashSet(BROWSER_NAME, BROWSER_VERSION, PLATFORM_NAME);
+ MutableCapabilities caps = new MutableCapabilities(
Maps.filterKeys(capabilities.asMap(), key -> !toRemove.contains(key)));
- } else {
- caps = new MutableCapabilities(capabilities);
- }
// Ensure that the proxy is in a state fit to be sent to the extension
Proxy proxy = Proxy.extractFrom(capabilities);
