From 6ff5c0e9ecfa7254eab63387b0b784bc7dd65057 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Fri, 4 Apr 2025 17:35:02 +0200 Subject: [PATCH] [grid] Ignored options when they are prefixed, safari specif as well Fixes #15481 Fixes #14485 --- .../grid/data/DefaultSlotMatcher.java | 5 +++- .../grid/data/DefaultSlotMatcherTest.java | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java b/java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java index 3db617bbd5335..2f9b5528965dd 100644 --- a/java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java +++ b/java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java @@ -49,7 +49,7 @@ public class DefaultSlotMatcher implements SlotMatcher, Serializable { matched in the Node or in the browser driver. */ private static final List EXTENSION_CAPABILITIES_PREFIXES = - Arrays.asList("goog:", "moz:", "ms:", "se:"); + Arrays.asList("goog:", "moz:", "ms:", "safari:", "se:"); @Override public boolean matches(Capabilities stereotype, Capabilities capabilities) { @@ -154,9 +154,12 @@ private Boolean extensionCapabilitiesMatch(Capabilities stereotype, Capabilities We match extension capabilities when they are not prefixed with any of the EXTENSION_CAPABILITIES_PREFIXES items. Also, we match them only when the capabilities of the new session request contains that specific extension capability. + We are also filtering "options" extension capabilities, as they should be handled + by the remote endpoint. */ return stereotype.getCapabilityNames().stream() .filter(name -> name.contains(":")) + .filter(name -> !name.toLowerCase().contains("options")) .filter(name -> capabilities.asMap().containsKey(name)) .filter(name -> EXTENSION_CAPABILITIES_PREFIXES.stream().noneMatch(name::contains)) .map( diff --git a/java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java b/java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java index 845a8471d8bde..2b002e6422731 100644 --- a/java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java +++ b/java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java @@ -565,6 +565,32 @@ void vendorExtensionPrefixedCapabilitiesAreIgnoredForMatching() { assertThat(slotMatcher.matches(stereotype, capabilities)).isTrue(); } + @Test + void extensionPrefixedOptionCapabilityIsIgnoredForMatching() { + Capabilities stereotype = + new ImmutableCapabilities( + CapabilityType.BROWSER_NAME, + "chrome", + CapabilityType.BROWSER_VERSION, + "84", + CapabilityType.PLATFORM_NAME, + Platform.WINDOWS, + "node:options", + "appium"); + + Capabilities capabilities = + new ImmutableCapabilities( + CapabilityType.BROWSER_NAME, + "chrome", + CapabilityType.BROWSER_VERSION, + "84", + CapabilityType.PLATFORM_NAME, + Platform.WINDOWS, + "node:options", + "selenium"); + assertThat(slotMatcher.matches(stereotype, capabilities)).isTrue(); + } + @Test void emptyCapabilitiesDoNotMatch() { Capabilities stereotype =