-
-
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?
[grid] Only ignore extension caps with object/array values #14485
Conversation
PR Reviewer Guide 🔍
|
a82c998
to
14999b7
Compare
PR Code Suggestions ✨
|
14999b7
to
dbe50be
Compare
.filter(name -> !"platformName".equalsIgnoreCase(name)) | ||
.map( | ||
name -> { | ||
if (capabilities.getCapability(name) instanceof String) { |
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.
.orElse(true); | ||
.filter(name -> name.contains(":")) | ||
.filter(name -> capabilities.getCapability(name) != null) | ||
.map(name -> { |
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.
This revised comparison will only evaluate values that are strings, numbers, or Booleans; complex values (objects and arrays) are ignored. The prior "special" treatment of four recognized extension capability prefixes (goog:
, moz:
, ms:
, and se:
) has been replaced by this consistent handling of all extension capabilities.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
The merge
operation that necessitated this special-case handling has been eliminated. The session factory shouldn't be altering clients' requested capabilities.
ac4802b
to
2d9609b
Compare
"amsterdam", | ||
"ms:fruit", | ||
"mango"); | ||
"food:dairy", |
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.
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 comment
The 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 comment
The 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.
@@ -148,7 +149,7 @@ boolean isDownloadEnabled(WebDriverInfo driver, String customMsg) { | |||
reported.add(caps); | |||
return Collections.singleton(HelperFactory.create(config, caps)); | |||
}); | |||
String expected = driver.getDisplayName(); | |||
String expected = "Edge".equals(driver.getDisplayName()) ? Browser.EDGE.browserName() : driver.getDisplayName(); |
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.
This test was broken when I got here. For Microsoft Edge, the display name is Edge
, but the browser name is MicrosoftEdge
. Consequently, the expected value would never be matched.
2d9609b
to
cca2c28
Compare
"amsterdam", | ||
"ms:fruit", | ||
"mango"); | ||
"food:dairy", |
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.
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.
d5aeb2e
to
84b6795
Compare
6a5663f
to
d993e8c
Compare
d993e8c
to
378cb93
Compare
a48362c
to
e3253b5
Compare
7f259f9
to
11bd7d3
Compare
11bd7d3
to
a46bb83
Compare
b29674d
to
5e7e1ab
Compare
@diemol @krmahadevan Please help review this when time permits! |
ee1fc8f
to
88ebc67
Compare
88ebc67
to
5a9b636
Compare
User description
Description
The existing handling of extension capabilities assigns special significance to four recognized prefixes:
goog:
,moz:
,ms:
, andse:
. Capabilities with these prefixes are entirely ignored by the current default slot matcher implementation, but custom prefixes are considered, as well as those for Safari and Appium. This inconsistency means that properties in extension capabilities with complex values (objects and arrays) can cause affectednewSession
requests to fail even though extension capabilities are supposed to be vendor-specific and should probably not be evaluated by the default slot matcher.As a compromise, this PR eliminates the "special" status of the four recognized prefixes, opting instead to ignore all extension capabilities with complex values. This maintains the existing behavior regarding the Options objects of Chrome, Firefox, and Edge while allowing node configurations and
newSession
requests to include extension capabilities that won't affect slot matching.Motivation and Context
Revolves #14461
The strategy employed by the PR is that extension capabilities which should be considered for matching can be expressed as capabilities with simple values and those which should be ignored can be specified as map elements or list items. This is a generalization of existing patterns from current use cases:
Recommended slot matcher enhancements
To reduce the need for custom slot matchers, we could extend the WebDriverInfo interface to add a new method that vendors could implement to evaluate their own criteria:
The default implementation would return
null
to indicate that no evaluation has been performed. If the vendor chooses to implement thematches
method, their initial step must be to invoke their ownisSupporting
method, returningnull
if the corresponding driver doesn't support the specified capabilities.The implementation in DefaultSlotMatcher would be updated to iterate over the available WebDriverInfo providers, retaining only those whose
isSupporting
methods returntrue
. Thematches
methods of this filtered list of providers will then be applied to the available nodes to determine which of these satisfies the criteria specified by the client request. The nodes that satisfy these evaluations (if any) would then be evaluated against the remaining common criteria.Another potential enhancement would be to enable vendor-specific
matches
methods to return a weighted integer result instead of a simpleBoolean
. This would enable best-match behavior. Perhaps this is getting too complicated, though.Types of changes
Checklist
PR Type
Bug fix, Tests
Description
DefaultSlotMatcher
, opting to ignore all extension capabilities with complex values.RelaySessionFactory
to streamline session creation by removing redundant capability filtering.DefaultSlotMatcherTest
to align with the new handling of extension capabilities, using maps for complex values.Changes walkthrough 📝
DefaultSlotMatcher.java
Revise extension capabilities handling in DefaultSlotMatcher
java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java
values.
RelaySessionFactory.java
Simplify session creation in RelaySessionFactory
java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java
DefaultSlotMatcherTest.java
Update DefaultSlotMatcher tests for revised capability handling
java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java
handling.