Skip to content

Commit d9e9eca

Browse files
authored
Refine slot matchers; fix README version updater (#275)
1 parent a61215d commit d9e9eca

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ test {
151151

152152
scmVersion {
153153
hooks {
154-
pre 'fileUpdate', [file: 'README.md', pattern: {v, p -> /(<version>)\d+\.\d+\.\d+(-s[23]<\/version>)/}, replacement: {v, p -> "\$1$v\$2"}]
155-
pre 'fileUpdate', [file: 'README.md', pattern: {v, p -> /(selenium-foundation:)\d+\.\d+\.\d+(-s[23])/}, replacement: {v, p -> "\$1$v\$2"}]
154+
pre 'fileUpdate', [file: 'README.md', pattern: {v, p -> /(<version>)\d+\.\d+\.\d+(-s[34]<\/version>)/}, replacement: {v, p -> "\$1$v\$2"}]
155+
pre 'fileUpdate', [file: 'README.md', pattern: {v, p -> /(selenium-foundation:)\d+\.\d+\.\d+(-s[34])/}, replacement: {v, p -> "\$1$v\$2"}]
156156
pre 'commit'
157157
post 'push'
158158
}

src/selenium3/java/com/nordstrom/automation/selenium/core/FoundationSlotMatcher.java

+26-3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,30 @@ public Boolean apply(Map<String, Object> providedCapabilities, Map<String, Objec
9696
}
9797
}
9898

99+
class BrowserVersionValidator implements Validator {
100+
@Override
101+
public Boolean apply(Map<String, Object> providedCapabilities, Map<String, Object> requestedCapabilities) {
102+
if ("htmlunit".equals(requestedCapabilities.get(BROWSER_NAME))) {
103+
return true;
104+
}
105+
106+
Object requested = Optional.ofNullable(requestedCapabilities.get(CapabilityType.BROWSER_VERSION))
107+
.orElse(requestedCapabilities.get(CapabilityType.VERSION));
108+
if (anything(requested)) {
109+
return true;
110+
}
111+
Object provided = Optional.ofNullable(providedCapabilities.get(CapabilityType.BROWSER_VERSION))
112+
.orElse(providedCapabilities.get(CapabilityType.VERSION));
113+
Platform requestedPlatform = extractPlatform(requested);
114+
if (requestedPlatform != null) {
115+
Platform providedPlatform = extractPlatform(provided);
116+
return providedPlatform != null && providedPlatform.is(requestedPlatform);
117+
}
118+
119+
return provided != null && Objects.equals(requested.toString(), provided.toString());
120+
}
121+
}
122+
99123
class SimplePropertyValidator implements Validator {
100124
private List<String> toConsider;
101125

@@ -168,9 +192,8 @@ private boolean getUseTechnologyPreview(Map<String, Object> capabilities) {
168192
private final List<Validator> validators = new ArrayList<>();
169193
{
170194
validators.addAll(Arrays.asList(new PlatformValidator(), new AliasedPropertyValidator(BROWSER_NAME, "browser"),
171-
new AliasedPropertyValidator(CapabilityType.BROWSER_VERSION, CapabilityType.VERSION),
172-
new SimplePropertyValidator(CapabilityType.APPLICATION_NAME), new FirefoxSpecificValidator(),
173-
new SafariSpecificValidator()));
195+
new BrowserVersionValidator(), new SimplePropertyValidator(CapabilityType.APPLICATION_NAME),
196+
new FirefoxSpecificValidator(), new SafariSpecificValidator()));
174197
}
175198

176199
public void addToConsider(String capabilityName) {

src/selenium4/java/com/nordstrom/automation/selenium/core/FoundationSlotMatcher.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ public boolean matches(Capabilities stereotype, Capabilities capabilities) {
7777
|| capabilities.getBrowserVersion().isEmpty()
7878
|| Objects.equals(capabilities.getBrowserVersion(), "stable")
7979
|| Objects.equals(stereotype.getBrowserVersion(), capabilities.getBrowserVersion());
80-
boolean platformNameMatch = Browser.HTMLUNIT.is(capabilities)
81-
|| capabilities.getPlatformName() == null
80+
boolean platformNameMatch = capabilities.getPlatformName() == null
8281
|| Objects.equals(stereotype.getPlatformName(), capabilities.getPlatformName())
8382
|| (stereotype.getPlatformName() != null
8483
&& stereotype.getPlatformName().is(capabilities.getPlatformName()));

0 commit comments

Comments
 (0)