Skip to content

Commit 025d96e

Browse files
committed
[grid] Improving DefaultSlotMatcher in case browserName is empty.
1 parent eef1f40 commit 025d96e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* <ul>
3434
* <li>browserName
3535
* <li>browserVersion
36-
* <li>platform
36+
* <li>platformName
3737
* </ul>
3838
* Then the {@code stereotype} must contain the same values.
3939
* </ul>
@@ -53,14 +53,13 @@ public boolean matches(Capabilities stereotype, Capabilities capabilities) {
5353
// Platform matching is special, we do it below
5454
.filter(name -> !"platform".equalsIgnoreCase(name) && !"platformName".equalsIgnoreCase(name))
5555
.map(name -> {
56-
Object value = capabilities.getCapability(name);
57-
boolean matches;
58-
if (value instanceof String) {
59-
matches = stereotype.getCapability(name).toString().equalsIgnoreCase(value.toString());
56+
if (capabilities.getCapability(name) instanceof String) {
57+
return stereotype.getCapability(name).toString()
58+
.equalsIgnoreCase(capabilities.getCapability(name).toString());
6059
} else {
61-
matches = value == null || Objects.equals(stereotype.getCapability(name), value);
60+
return capabilities.getCapability(name) == null ||
61+
Objects.equals(stereotype.getCapability(name), capabilities.getCapability(name));
6262
}
63-
return matches;
6463
})
6564
.reduce(Boolean::logicalAnd)
6665
.orElse(false);
@@ -71,7 +70,7 @@ public boolean matches(Capabilities stereotype, Capabilities capabilities) {
7170

7271
// Simple browser, browserVersion and platformName match
7372
boolean browserNameMatch =
74-
capabilities.getBrowserName() == null ||
73+
(capabilities.getBrowserName() == null || capabilities.getBrowserName().isEmpty()) ||
7574
Objects.equals(stereotype.getBrowserName(), capabilities.getBrowserName());
7675
boolean browserVersionMatch =
7776
(capabilities.getBrowserVersion() == null || capabilities.getBrowserVersion().isEmpty()) ||

0 commit comments

Comments
 (0)