@@ -79,14 +79,29 @@ public boolean matches(Capabilities stereotype, Capabilities capabilities) {
79
79
}
80
80
81
81
// At the end, a simple browser, browserVersion and platformName match
82
- boolean browserNameMatch = browserNameMatch (stereotype , capabilities );
83
- boolean browserVersionMatch = browserVersionMatch (stereotype , capabilities );
84
- boolean platformNameMatch = platformNameMatch (stereotype , capabilities );
85
-
82
+ boolean browserNameMatch =
83
+ (capabilities .getBrowserName () == null || capabilities .getBrowserName ().isEmpty ())
84
+ || Objects .equals (stereotype .getBrowserName (), capabilities .getBrowserName ())
85
+ || specificRelayCapabilitiesAppMatch (capabilities );
86
+ boolean browserVersionMatch =
87
+ (capabilities .getBrowserVersion () == null
88
+ || capabilities .getBrowserVersion ().isEmpty ()
89
+ || Objects .equals (capabilities .getBrowserVersion (), "stable" ))
90
+ || browserVersionMatch (stereotype .getBrowserVersion (), capabilities .getBrowserVersion ())
91
+ || specificRelayCapabilitiesAppMatch (capabilities );
92
+ boolean platformNameMatch =
93
+ capabilities .getPlatformName () == null
94
+ || Objects .equals (stereotype .getPlatformName (), capabilities .getPlatformName ())
95
+ || (stereotype .getPlatformName () != null
96
+ && stereotype .getPlatformName ().is (capabilities .getPlatformName ()));
86
97
return browserNameMatch && browserVersionMatch && platformNameMatch ;
87
98
}
88
99
89
- private boolean initialMatch (Capabilities stereotype , Capabilities capabilities ) {
100
+ private boolean browserVersionMatch (String stereotype , String capabilities ) {
101
+ return new SemanticVersionComparator ().compare (stereotype , capabilities ) == 0 ;
102
+ }
103
+
104
+ private Boolean initialMatch (Capabilities stereotype , Capabilities capabilities ) {
90
105
return stereotype .getCapabilityNames ().stream ()
91
106
// Matching of extension capabilities is implementation independent. Skip them
92
107
.filter (name -> !name .contains (":" ))
@@ -112,7 +127,7 @@ private boolean initialMatch(Capabilities stereotype, Capabilities capabilities)
112
127
.orElse (true );
113
128
}
114
129
115
- private boolean managedDownloadsEnabled (Capabilities stereotype , Capabilities capabilities ) {
130
+ private Boolean managedDownloadsEnabled (Capabilities stereotype , Capabilities capabilities ) {
116
131
// First lets check if user wanted a Node with managed downloads enabled
117
132
Object raw = capabilities .getCapability ("se:downloadsEnabled" );
118
133
if (raw == null || !Boolean .parseBoolean (raw .toString ())) {
@@ -125,7 +140,7 @@ private boolean managedDownloadsEnabled(Capabilities stereotype, Capabilities ca
125
140
return raw != null && Boolean .parseBoolean (raw .toString ());
126
141
}
127
142
128
- private boolean platformVersionMatch (Capabilities stereotype , Capabilities capabilities ) {
143
+ private Boolean platformVersionMatch (Capabilities stereotype , Capabilities capabilities ) {
129
144
/*
130
145
This platform version match is not W3C compliant but users can add Appium servers as
131
146
Nodes, so we avoid delaying the match until the Slot, which makes the whole matching
@@ -142,7 +157,7 @@ private boolean platformVersionMatch(Capabilities stereotype, Capabilities capab
142
157
.orElse (true );
143
158
}
144
159
145
- private boolean extensionCapabilitiesMatch (Capabilities stereotype , Capabilities capabilities ) {
160
+ private Boolean extensionCapabilitiesMatch (Capabilities stereotype , Capabilities capabilities ) {
146
161
/*
147
162
We match extension capabilities when they are not prefixed with any of the
148
163
EXTENSION_CAPABILITIES_PREFIXES items. Also, we match them only when the capabilities
@@ -172,32 +187,7 @@ private boolean extensionCapabilitiesMatch(Capabilities stereotype, Capabilities
172
187
.orElse (true );
173
188
}
174
189
175
- private boolean browserNameMatch (Capabilities stereotype , Capabilities capabilities ) {
176
- return (capabilities .getBrowserName () == null || capabilities .getBrowserName ().isEmpty ())
177
- || Objects .equals (stereotype .getBrowserName (), capabilities .getBrowserName ())
178
- || specificRelayCapabilitiesAppMatch (capabilities );
179
- }
180
-
181
- private boolean browserVersionMatch (String stereotype , String capabilities ) {
182
- return new SemanticVersionComparator ().compare (stereotype , capabilities ) == 0 ;
183
- }
184
-
185
- private boolean browserVersionMatch (Capabilities stereotype , Capabilities capabilities ) {
186
- return (capabilities .getBrowserVersion () == null
187
- || capabilities .getBrowserVersion ().isEmpty ()
188
- || Objects .equals (capabilities .getBrowserVersion (), "stable" ))
189
- || browserVersionMatch (stereotype .getBrowserVersion (), capabilities .getBrowserVersion ())
190
- || specificRelayCapabilitiesAppMatch (capabilities );
191
- }
192
-
193
- private boolean platformNameMatch (Capabilities stereotype , Capabilities capabilities ) {
194
- return capabilities .getPlatformName () == null
195
- || Objects .equals (stereotype .getPlatformName (), capabilities .getPlatformName ())
196
- || (stereotype .getPlatformName () != null
197
- && stereotype .getPlatformName ().is (capabilities .getPlatformName ()));
198
- }
199
-
200
- public static boolean specificRelayCapabilitiesAppMatch (Capabilities capabilities ) {
190
+ public static Boolean specificRelayCapabilitiesAppMatch (Capabilities capabilities ) {
201
191
/*
202
192
This match is specific for the Relay capabilities that are related to the Appium server for native application.
203
193
- If browserName is defined then we always assume it’s a hybrid browser session, so no app-related caps should be provided
0 commit comments