20
20
import static org .assertj .core .api .Assertions .assertThat ;
21
21
22
22
import org .junit .Test ;
23
+ import org .openqa .selenium .Capabilities ;
23
24
import org .openqa .selenium .ImmutableCapabilities ;
24
25
import org .openqa .selenium .Platform ;
25
26
import org .openqa .selenium .remote .CapabilityType ;
@@ -30,133 +31,149 @@ public class DefaultSlotMatcherTest {
30
31
31
32
@ Test
32
33
public void fullMatch () {
33
- ImmutableCapabilities stereotype = new ImmutableCapabilities (
34
+ Capabilities stereotype = new ImmutableCapabilities (
34
35
CapabilityType .BROWSER_NAME , "chrome" ,
35
36
CapabilityType .BROWSER_VERSION , "80" ,
36
37
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
37
38
);
38
- ImmutableCapabilities capabilities = new ImmutableCapabilities (
39
+ Capabilities capabilities = new ImmutableCapabilities (
39
40
CapabilityType .BROWSER_NAME , "chrome" ,
40
41
CapabilityType .BROWSER_VERSION , "80" ,
41
42
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
42
43
);
43
- assertThat (slotMatcher .matches (capabilities , stereotype )).isTrue ();
44
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isTrue ();
44
45
}
45
46
46
47
@ Test
47
48
public void matchesBrowserAndVersion () {
48
- ImmutableCapabilities stereotype = new ImmutableCapabilities (
49
+ Capabilities stereotype = new ImmutableCapabilities (
49
50
CapabilityType .BROWSER_NAME , "chrome" ,
50
51
CapabilityType .BROWSER_VERSION , "80" ,
51
52
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
52
53
);
53
- ImmutableCapabilities capabilities = new ImmutableCapabilities (
54
+ Capabilities capabilities = new ImmutableCapabilities (
54
55
CapabilityType .BROWSER_NAME , "chrome" ,
55
56
CapabilityType .BROWSER_VERSION , "80"
56
57
);
57
- assertThat (slotMatcher .matches (capabilities , stereotype )).isTrue ();
58
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isTrue ();
58
59
}
59
60
60
61
@ Test
61
62
public void matchesBrowser () {
62
- ImmutableCapabilities stereotype = new ImmutableCapabilities (
63
+ Capabilities stereotype = new ImmutableCapabilities (
63
64
CapabilityType .BROWSER_NAME , "chrome" ,
64
65
CapabilityType .BROWSER_VERSION , "80" ,
65
66
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
66
67
);
67
- ImmutableCapabilities capabilities = new ImmutableCapabilities (
68
+ Capabilities capabilities = new ImmutableCapabilities (
68
69
CapabilityType .BROWSER_NAME , "chrome"
69
70
);
70
- assertThat (slotMatcher .matches (capabilities , stereotype )).isTrue ();
71
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isTrue ();
71
72
}
72
73
73
74
@ Test
74
75
public void platformDoesNotMatch () {
75
- ImmutableCapabilities stereotype = new ImmutableCapabilities (
76
+ Capabilities stereotype = new ImmutableCapabilities (
76
77
CapabilityType .BROWSER_NAME , "chrome" ,
77
78
CapabilityType .BROWSER_VERSION , "80" ,
78
79
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
79
80
);
80
- ImmutableCapabilities capabilities = new ImmutableCapabilities (
81
+ Capabilities capabilities = new ImmutableCapabilities (
81
82
CapabilityType .BROWSER_NAME , "chrome" ,
82
83
CapabilityType .BROWSER_VERSION , "80" ,
83
84
CapabilityType .PLATFORM_NAME , Platform .MAC
84
85
);
85
- assertThat (slotMatcher .matches (capabilities , stereotype )).isFalse ();
86
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isFalse ();
86
87
}
87
88
88
89
@ Test
89
90
public void browserDoesNotMatch () {
90
- ImmutableCapabilities stereotype = new ImmutableCapabilities (
91
+ Capabilities stereotype = new ImmutableCapabilities (
91
92
CapabilityType .BROWSER_NAME , "chrome" ,
92
93
CapabilityType .BROWSER_VERSION , "80" ,
93
94
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
94
95
);
95
- ImmutableCapabilities capabilities = new ImmutableCapabilities (
96
+ Capabilities capabilities = new ImmutableCapabilities (
96
97
CapabilityType .BROWSER_NAME , "firefox" ,
97
98
CapabilityType .BROWSER_VERSION , "80" ,
98
99
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
99
100
);
100
- assertThat (slotMatcher .matches (capabilities , stereotype )).isFalse ();
101
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isFalse ();
101
102
}
102
103
103
104
@ Test
104
105
public void browserVersionDoesNotMatch () {
105
- ImmutableCapabilities stereotype = new ImmutableCapabilities (
106
+ Capabilities stereotype = new ImmutableCapabilities (
106
107
CapabilityType .BROWSER_NAME , "chrome" ,
107
108
CapabilityType .BROWSER_VERSION , "80" ,
108
109
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
109
110
);
110
- ImmutableCapabilities capabilities = new ImmutableCapabilities (
111
+ Capabilities capabilities = new ImmutableCapabilities (
111
112
CapabilityType .BROWSER_NAME , "chrome" ,
112
113
CapabilityType .BROWSER_VERSION , "84" ,
113
114
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
114
115
);
115
- assertThat (slotMatcher .matches (capabilities , stereotype )).isFalse ();
116
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isFalse ();
116
117
}
117
118
118
119
@ Test
119
120
public void requestedPlatformDoesNotMatch () {
120
- ImmutableCapabilities stereotype = new ImmutableCapabilities (
121
+ Capabilities stereotype = new ImmutableCapabilities (
121
122
CapabilityType .BROWSER_NAME , "chrome" ,
122
123
CapabilityType .BROWSER_VERSION , "80"
123
124
);
124
125
125
- ImmutableCapabilities capabilities = new ImmutableCapabilities (
126
+ Capabilities capabilities = new ImmutableCapabilities (
126
127
CapabilityType .BROWSER_NAME , "chrome" ,
127
- CapabilityType .BROWSER_VERSION , "84 " ,
128
+ CapabilityType .BROWSER_VERSION , "80 " ,
128
129
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
129
130
);
130
- assertThat (slotMatcher .matches (capabilities , stereotype )).isFalse ();
131
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isFalse ();
131
132
}
132
133
133
134
@ Test
134
- public void requestedBrowserVersionDoesNotMatch () {
135
- ImmutableCapabilities stereotype = new ImmutableCapabilities (
135
+ public void shouldNotMatchIfRequestedBrowserVersionIsMissingFromStereotype () {
136
+ Capabilities stereotype = new ImmutableCapabilities (
136
137
CapabilityType .BROWSER_NAME , "chrome" ,
137
138
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
138
139
);
139
140
140
- ImmutableCapabilities capabilities = new ImmutableCapabilities (
141
+ Capabilities capabilities = new ImmutableCapabilities (
141
142
CapabilityType .BROWSER_NAME , "chrome" ,
142
143
CapabilityType .BROWSER_VERSION , "84" ,
143
144
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
144
145
);
145
- assertThat (slotMatcher .matches (capabilities , stereotype )).isFalse ();
146
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isFalse ();
146
147
}
147
148
148
149
@ Test
149
- public void matchesWithJWPCaps () {
150
- ImmutableCapabilities stereotype = new ImmutableCapabilities (
150
+ public void matchesWithJsonWireProtocolCaps () {
151
+ Capabilities stereotype = new ImmutableCapabilities (
151
152
CapabilityType .BROWSER_NAME , "chrome" ,
152
153
CapabilityType .BROWSER_VERSION , "80" ,
153
154
CapabilityType .PLATFORM_NAME , Platform .WINDOWS
154
155
);
155
- ImmutableCapabilities capabilities = new ImmutableCapabilities (
156
+ Capabilities capabilities = new ImmutableCapabilities (
156
157
CapabilityType .BROWSER_NAME , "chrome" ,
157
158
CapabilityType .VERSION , "80" ,
158
159
CapabilityType .PLATFORM , Platform .WINDOWS
159
160
);
160
- assertThat (slotMatcher .matches (capabilities , stereotype )).isTrue ();
161
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isTrue ();
162
+ }
163
+
164
+ @ Test
165
+ public void shouldNotMatchCapabilitiesThatAreDifferentButDoNotContainCommonCapabilityNames () {
166
+ Capabilities stereotype = new ImmutableCapabilities ("acceptInsecureCerts" , "true" );
167
+ Capabilities capabilities = new ImmutableCapabilities ("acceptInsecureCerts" , "false" );
168
+
169
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isFalse ();
170
+ }
171
+
172
+ @ Test
173
+ public void shouldMatchCapabilitiesThatAreTheSameButDoNotContainCommonCapabilityNames () {
174
+ Capabilities stereotype = new ImmutableCapabilities ("strictFileInteractability" , "true" );
175
+ Capabilities capabilities = new ImmutableCapabilities ("strictFileInteractability" , "true" );
176
+
177
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isTrue ();
161
178
}
162
179
}
0 commit comments