Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[grid] Ignored options when they are prefixed, safari specif as well #15574

Merged
merged 3 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class DefaultSlotMatcher implements SlotMatcher, Serializable {
matched in the Node or in the browser driver.
*/
private static final List<String> EXTENSION_CAPABILITIES_PREFIXES =
Arrays.asList("goog:", "moz:", "ms:", "se:");
Arrays.asList("goog:", "moz:", "ms:", "safari:", "se:");

@Override
public boolean matches(Capabilities stereotype, Capabilities capabilities) {
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Loading