-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Only ignore extension caps with object/array values #14485
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,6 @@ | |
import java.util.logging.Logger; | ||
import org.openqa.selenium.Capabilities; | ||
import org.openqa.selenium.ImmutableCapabilities; | ||
import org.openqa.selenium.MutableCapabilities; | ||
import org.openqa.selenium.SessionNotCreatedException; | ||
import org.openqa.selenium.WebDriverException; | ||
import org.openqa.selenium.grid.data.CreateSessionRequest; | ||
|
@@ -50,7 +49,6 @@ | |
import org.openqa.selenium.internal.Debug; | ||
import org.openqa.selenium.internal.Either; | ||
import org.openqa.selenium.internal.Require; | ||
import org.openqa.selenium.remote.CapabilityType; | ||
import org.openqa.selenium.remote.Command; | ||
import org.openqa.selenium.remote.Dialect; | ||
import org.openqa.selenium.remote.DriverCommand; | ||
|
@@ -149,15 +147,6 @@ public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sess | |
"New session request capabilities do not " + "match the stereotype.")); | ||
} | ||
|
||
// remove browserName capability if 'appium:app' is present as it breaks appium tests when app | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
// is provided | ||
// they are mutually exclusive | ||
MutableCapabilities filteredStereotype = new MutableCapabilities(stereotype); | ||
if (capabilities.getCapability("appium:app") != null) { | ||
filteredStereotype.setCapability(CapabilityType.BROWSER_NAME, (String) null); | ||
} | ||
|
||
capabilities = capabilities.merge(filteredStereotype); | ||
LOG.info("Starting session for " + capabilities); | ||
|
||
try (Span span = tracer.getCurrentContext().createSpan("relay_session_factory.apply")) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.Capabilities; | ||
import org.openqa.selenium.ImmutableCapabilities; | ||
|
@@ -424,7 +426,7 @@ void multipleExtensionPrefixedCapabilitiesDoNotMatchWhenOneIsDifferent() { | |
} | ||
|
||
@Test | ||
void vendorExtensionPrefixedCapabilitiesAreIgnoredForMatching() { | ||
void vendorExtensionPrefixedCapabilitiesWithSimpleValuesAreConsideredForMatching() { | ||
Capabilities stereotype = | ||
new ImmutableCapabilities( | ||
CapabilityType.BROWSER_NAME, | ||
|
@@ -450,6 +452,36 @@ void vendorExtensionPrefixedCapabilitiesAreIgnoredForMatching() { | |
"gouda", | ||
"ms:fruit", | ||
"orange"); | ||
assertThat(slotMatcher.matches(stereotype, capabilities)).isFalse(); | ||
} | ||
|
||
@Test | ||
void vendorExtensionPrefixedCapabilitiesWithComplexValuesAreIgnoredForMatching() { | ||
Capabilities stereotype = | ||
new ImmutableCapabilities( | ||
CapabilityType.BROWSER_NAME, | ||
"chrome", | ||
CapabilityType.BROWSER_VERSION, | ||
"84", | ||
CapabilityType.PLATFORM_NAME, | ||
Platform.WINDOWS, | ||
"food:dairy", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test has been updated to verify the revised behavior, in which all extension capabilities with complex values are ignored for purposes of node matching. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is a good idea to create a new test and let the existing test be as it is to verify the changes don't cause a breaking change for the users. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I restored the original test, altering the method name and inverting the expectation to correspond with the revised behavior. |
||
Map.of("cheese", "amsterdam"), | ||
"food:fruit", | ||
List.of("mango")); | ||
|
||
Capabilities capabilities = | ||
new ImmutableCapabilities( | ||
CapabilityType.BROWSER_NAME, | ||
"chrome", | ||
CapabilityType.BROWSER_VERSION, | ||
"84", | ||
CapabilityType.PLATFORM_NAME, | ||
Platform.WINDOWS, | ||
"food:dairy", | ||
Map.of("cheese", "gouda"), | ||
"food:fruit", | ||
List.of("orange")); | ||
assertThat(slotMatcher.matches(stereotype, capabilities)).isTrue(); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of this conditional fails to consider that the corresponding stereotype capability could have a non-String value (including
null
), which would produce unexpected behavior. The revised implementation will only perform the case-insensitive comparison if the capability in the session request and the node stereotype both have String values.