Skip to content

Commit 797a859

Browse files
committed
[java] Improving default matcher to enable Appium
In many cases, session requests for Appium servers won't include a browserName or a browserVersion. If many common W3C caps are missing, the matcher was returning false. This change passes the matching logic to the extension matching. Now Appium session requests are better matched.
1 parent c884550 commit 797a859

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private Boolean initialMatch(Capabilities stereotype, Capabilities capabilities)
103103
}
104104
})
105105
.reduce(Boolean::logicalAnd)
106-
.orElse(false);
106+
.orElse(true);
107107
}
108108

109109
private Boolean platformVersionMatch(Capabilities stereotype, Capabilities capabilities) {

java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
package org.openqa.selenium.grid.data;
1919

20-
import static org.assertj.core.api.Assertions.assertThat;
21-
2220
import org.junit.jupiter.api.Test;
2321
import org.openqa.selenium.Capabilities;
2422
import org.openqa.selenium.ImmutableCapabilities;
2523
import org.openqa.selenium.Platform;
2624
import org.openqa.selenium.remote.CapabilityType;
2725

26+
import static org.assertj.core.api.Assertions.assertThat;
27+
2828
public class DefaultSlotMatcherTest {
2929

3030
private final DefaultSlotMatcher slotMatcher = new DefaultSlotMatcher();
@@ -381,4 +381,23 @@ public void emptyCapabilitiesDoNotMatch() {
381381
assertThat(slotMatcher.matches(stereotype, capabilities)).isFalse();
382382
}
383383

384+
@Test
385+
public void extensionCapsAlsoMatch() {
386+
Capabilities stereotype = new ImmutableCapabilities(
387+
CapabilityType.PLATFORM_NAME, Platform.IOS,
388+
"appium:platformVersion", "15.5",
389+
"appium:automationName", "XCUITest",
390+
"appium:deviceName", "iPhone 13"
391+
);
392+
393+
Capabilities capabilities = new ImmutableCapabilities(
394+
CapabilityType.PLATFORM_NAME, Platform.IOS,
395+
"appium:platformVersion", "15.5",
396+
"appium:automationName", "XCUITest",
397+
"appium:noReset", true,
398+
"appium:deviceName", "iPhone 13"
399+
);
400+
401+
assertThat(slotMatcher.matches(stereotype, capabilities)).isTrue();
402+
}
384403
}

0 commit comments

Comments
 (0)