@appium/base-driver 8.3.0 → 8.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/build/lib/basedriver/capabilities.d.ts +80 -0
  2. package/build/lib/basedriver/capabilities.d.ts.map +1 -0
  3. package/build/lib/basedriver/capabilities.js +12 -13
  4. package/build/lib/basedriver/commands/event.d.ts +9 -0
  5. package/build/lib/basedriver/commands/event.d.ts.map +1 -0
  6. package/build/lib/basedriver/commands/event.js +21 -23
  7. package/build/lib/basedriver/commands/find.d.ts +11 -0
  8. package/build/lib/basedriver/commands/find.d.ts.map +1 -0
  9. package/build/lib/basedriver/commands/find.js +42 -37
  10. package/build/lib/basedriver/commands/index.d.ts +8 -0
  11. package/build/lib/basedriver/commands/index.d.ts.map +1 -0
  12. package/build/lib/basedriver/commands/index.js +17 -16
  13. package/build/lib/basedriver/commands/log.d.ts +12 -0
  14. package/build/lib/basedriver/commands/log.d.ts.map +1 -0
  15. package/build/lib/basedriver/commands/log.js +23 -27
  16. package/build/lib/basedriver/commands/session.d.ts +11 -0
  17. package/build/lib/basedriver/commands/session.d.ts.map +1 -0
  18. package/build/lib/basedriver/commands/session.js +21 -149
  19. package/build/lib/basedriver/commands/settings.d.ts +10 -0
  20. package/build/lib/basedriver/commands/settings.d.ts.map +1 -0
  21. package/build/lib/basedriver/commands/settings.js +19 -19
  22. package/build/lib/basedriver/commands/timeout.d.ts +8 -0
  23. package/build/lib/basedriver/commands/timeout.d.ts.map +1 -0
  24. package/build/lib/basedriver/commands/timeout.js +118 -139
  25. package/build/lib/basedriver/core.d.ts +235 -0
  26. package/build/lib/basedriver/core.d.ts.map +1 -0
  27. package/build/lib/basedriver/core.js +283 -0
  28. package/build/lib/basedriver/desired-caps.d.ts +5 -0
  29. package/build/lib/basedriver/desired-caps.d.ts.map +1 -0
  30. package/build/lib/basedriver/desired-caps.js +2 -4
  31. package/build/lib/basedriver/device-settings.d.ts +32 -0
  32. package/build/lib/basedriver/device-settings.d.ts.map +1 -0
  33. package/build/lib/basedriver/device-settings.js +20 -14
  34. package/build/lib/basedriver/driver.d.ts +83 -0
  35. package/build/lib/basedriver/driver.d.ts.map +1 -0
  36. package/build/lib/basedriver/driver.js +101 -256
  37. package/build/lib/basedriver/helpers.d.ts +132 -0
  38. package/build/lib/basedriver/helpers.d.ts.map +1 -0
  39. package/build/lib/basedriver/helpers.js +16 -2
  40. package/build/lib/basedriver/logger.d.ts +3 -0
  41. package/build/lib/basedriver/logger.d.ts.map +1 -0
  42. package/build/lib/basedriver/logger.js +2 -4
  43. package/build/lib/constants.d.ts +9 -0
  44. package/build/lib/constants.d.ts.map +1 -0
  45. package/build/lib/constants.js +2 -4
  46. package/build/lib/express/crash.d.ts +3 -0
  47. package/build/lib/express/crash.d.ts.map +1 -0
  48. package/build/lib/express/crash.js +2 -4
  49. package/build/lib/express/express-logging.d.ts +3 -0
  50. package/build/lib/express/express-logging.d.ts.map +1 -0
  51. package/build/lib/express/express-logging.js +2 -4
  52. package/build/lib/express/idempotency.d.ts +2 -0
  53. package/build/lib/express/idempotency.d.ts.map +1 -0
  54. package/build/lib/express/idempotency.js +2 -4
  55. package/build/lib/express/logger.d.ts +3 -0
  56. package/build/lib/express/logger.d.ts.map +1 -0
  57. package/build/lib/express/logger.js +2 -4
  58. package/build/lib/express/middleware.d.ts +9 -0
  59. package/build/lib/express/middleware.d.ts.map +1 -0
  60. package/build/lib/express/middleware.js +2 -4
  61. package/build/lib/express/server.d.ts +10 -0
  62. package/build/lib/express/server.d.ts.map +1 -0
  63. package/build/lib/express/server.js +2 -4
  64. package/build/lib/express/static.d.ts +6 -0
  65. package/build/lib/express/static.d.ts.map +1 -0
  66. package/build/lib/express/static.js +2 -4
  67. package/build/lib/express/websocket.d.ts +64 -0
  68. package/build/lib/express/websocket.d.ts.map +1 -0
  69. package/build/lib/express/websocket.js +40 -41
  70. package/build/lib/helpers/capabilities.d.ts +13 -0
  71. package/build/lib/helpers/capabilities.d.ts.map +1 -0
  72. package/build/lib/helpers/capabilities.js +40 -2
  73. package/build/lib/index.d.ts +183 -0
  74. package/build/lib/index.d.ts.map +1 -0
  75. package/build/lib/index.js +41 -23
  76. package/build/lib/jsonwp-proxy/protocol-converter.d.ts +48 -0
  77. package/build/lib/jsonwp-proxy/protocol-converter.d.ts.map +1 -0
  78. package/build/lib/jsonwp-proxy/protocol-converter.js +2 -4
  79. package/build/lib/jsonwp-proxy/proxy.d.ts +41 -0
  80. package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -0
  81. package/build/lib/jsonwp-proxy/proxy.js +25 -9
  82. package/build/lib/jsonwp-status/status.d.ts +159 -0
  83. package/build/lib/jsonwp-status/status.d.ts.map +1 -0
  84. package/build/lib/jsonwp-status/status.js +2 -4
  85. package/build/lib/protocol/errors.d.ts +310 -0
  86. package/build/lib/protocol/errors.d.ts.map +1 -0
  87. package/build/lib/protocol/errors.js +82 -5
  88. package/build/lib/protocol/helpers.d.ts +22 -0
  89. package/build/lib/protocol/helpers.d.ts.map +1 -0
  90. package/build/lib/protocol/helpers.js +2 -4
  91. package/build/lib/protocol/index.d.ts +16 -0
  92. package/build/lib/protocol/index.d.ts.map +1 -0
  93. package/build/lib/protocol/index.js +8 -10
  94. package/build/lib/protocol/protocol.d.ts +11 -0
  95. package/build/lib/protocol/protocol.d.ts.map +1 -0
  96. package/build/lib/protocol/protocol.js +3 -9
  97. package/build/lib/protocol/routes.d.ts +6 -0
  98. package/build/lib/protocol/routes.d.ts.map +1 -0
  99. package/build/lib/protocol/routes.js +18 -4
  100. package/build/lib/protocol/validators.d.ts +8 -0
  101. package/build/lib/protocol/validators.d.ts.map +1 -0
  102. package/build/lib/protocol/validators.js +2 -4
  103. package/build/test/basedriver/README.md +5 -0
  104. package/build/test/basedriver/driver-e2e-tests.js +2 -4
  105. package/build/test/basedriver/driver-tests.js +31 -6
  106. package/build/test/basedriver/index.js +2 -4
  107. package/build/test/e2e/basedriver/driver.e2e.spec.js +15 -0
  108. package/build/test/e2e/basedriver/helpers.e2e.spec.js +192 -0
  109. package/build/test/e2e/basedriver/websockets.e2e.spec.js +87 -0
  110. package/build/test/e2e/express/server.e2e.spec.js +159 -0
  111. package/build/test/e2e/jsonwp-proxy/proxy.e2e.spec.js +59 -0
  112. package/build/test/e2e/protocol/fake-driver.js +163 -0
  113. package/build/test/e2e/protocol/helpers.js +25 -0
  114. package/build/test/e2e/protocol/protocol.e2e.spec.js +1186 -0
  115. package/build/test/helpers.js +2 -4
  116. package/build/test/unit/basedriver/capabilities.spec.js +672 -0
  117. package/build/test/unit/basedriver/capability.spec.js +353 -0
  118. package/build/test/unit/basedriver/commands/event.spec.js +110 -0
  119. package/build/test/unit/basedriver/commands/log.spec.js +92 -0
  120. package/build/test/unit/basedriver/driver.spec.js +15 -0
  121. package/build/test/unit/basedriver/helpers.spec.js +151 -0
  122. package/build/test/unit/basedriver/timeout.spec.js +135 -0
  123. package/build/test/unit/express/server.spec.js +155 -0
  124. package/build/test/unit/express/static.spec.js +26 -0
  125. package/build/test/unit/jsonwp-proxy/mock-request.js +91 -0
  126. package/build/test/unit/jsonwp-proxy/protocol-converter.spec.js +171 -0
  127. package/build/test/unit/jsonwp-proxy/proxy.spec.js +292 -0
  128. package/build/test/unit/jsonwp-proxy/url.spec.js +165 -0
  129. package/build/test/unit/jsonwp-status/status.spec.js +34 -0
  130. package/build/test/unit/protocol/errors.spec.js +390 -0
  131. package/build/test/unit/protocol/routes.spec.js +80 -0
  132. package/build/test/unit/protocol/validator.spec.js +149 -0
  133. package/build/tsconfig.tsbuildinfo +1 -0
  134. package/lib/basedriver/capabilities.js +49 -10
  135. package/lib/basedriver/commands/event.js +49 -31
  136. package/lib/basedriver/commands/find.js +108 -43
  137. package/lib/basedriver/commands/index.js +25 -19
  138. package/lib/basedriver/commands/log.js +60 -33
  139. package/lib/basedriver/commands/session.js +39 -141
  140. package/lib/basedriver/commands/settings.js +33 -13
  141. package/lib/basedriver/commands/timeout.js +153 -153
  142. package/lib/basedriver/core.js +497 -0
  143. package/lib/basedriver/desired-caps.js +1 -1
  144. package/lib/basedriver/device-settings.js +47 -12
  145. package/lib/basedriver/driver.js +272 -383
  146. package/lib/basedriver/helpers.js +18 -2
  147. package/lib/express/websocket.js +35 -32
  148. package/lib/helpers/capabilities.js +60 -1
  149. package/lib/index.js +16 -12
  150. package/lib/jsonwp-proxy/proxy.js +26 -6
  151. package/lib/protocol/errors.js +42 -42
  152. package/lib/protocol/index.js +4 -4
  153. package/lib/protocol/protocol.js +1 -3
  154. package/lib/protocol/routes.js +9 -0
  155. package/package.json +22 -14
  156. package/test/basedriver/README.md +5 -0
  157. package/test/basedriver/driver-e2e-tests.js +1 -1
  158. package/test/basedriver/driver-tests.js +31 -2
  159. package/build/test/basedriver/capabilities-specs.js +0 -674
  160. package/build/test/basedriver/capability-specs.js +0 -355
  161. package/build/test/basedriver/commands/event-specs.js +0 -112
  162. package/build/test/basedriver/commands/log-specs.js +0 -87
  163. package/build/test/basedriver/driver-e2e-specs.js +0 -17
  164. package/build/test/basedriver/driver-specs.js +0 -17
  165. package/build/test/basedriver/helpers-e2e-specs.js +0 -194
  166. package/build/test/basedriver/helpers-specs.js +0 -153
  167. package/build/test/basedriver/timeout-specs.js +0 -137
  168. package/build/test/basedriver/websockets-e2e-specs.js +0 -84
  169. package/build/test/express/server-e2e-specs.js +0 -161
  170. package/build/test/express/server-specs.js +0 -157
  171. package/build/test/express/static-specs.js +0 -28
  172. package/build/test/jsonwp-proxy/mock-request.js +0 -93
  173. package/build/test/jsonwp-proxy/protocol-converter-specs.js +0 -173
  174. package/build/test/jsonwp-proxy/proxy-e2e-specs.js +0 -61
  175. package/build/test/jsonwp-proxy/proxy-specs.js +0 -294
  176. package/build/test/jsonwp-proxy/url-specs.js +0 -167
  177. package/build/test/jsonwp-status/status-specs.js +0 -36
  178. package/build/test/protocol/errors-specs.js +0 -388
  179. package/build/test/protocol/fake-driver.js +0 -165
  180. package/build/test/protocol/helpers.js +0 -27
  181. package/build/test/protocol/protocol-e2e-specs.js +0 -1188
  182. package/build/test/protocol/routes-specs.js +0 -82
  183. package/build/test/protocol/validator-specs.js +0 -151
  184. package/index.d.ts +0 -386
  185. package/test/basedriver/capabilities-specs.js +0 -537
  186. package/test/basedriver/capability-specs.js +0 -383
  187. package/test/basedriver/commands/event-specs.js +0 -74
  188. package/test/basedriver/commands/log-specs.js +0 -79
  189. package/test/basedriver/driver-e2e-specs.js +0 -8
  190. package/test/basedriver/driver-specs.js +0 -8
  191. package/test/basedriver/fixtures/BadZippedApp.zip +0 -1
  192. package/test/basedriver/fixtures/FakeAndroidApp.apk +0 -1
  193. package/test/basedriver/fixtures/FakeAndroidApp.asd +0 -0
  194. package/test/basedriver/fixtures/FakeIOSApp.app +0 -1
  195. package/test/basedriver/fixtures/FakeIOSApp.app.zip +0 -0
  196. package/test/basedriver/fixtures/FakeIOSApp.ipa +0 -0
  197. package/test/basedriver/fixtures/custom-element-finder-bad.js +0 -5
  198. package/test/basedriver/fixtures/custom-element-finder.js +0 -29
  199. package/test/basedriver/helpers-e2e-specs.js +0 -187
  200. package/test/basedriver/helpers-specs.js +0 -137
  201. package/test/basedriver/timeout-specs.js +0 -128
  202. package/test/basedriver/websockets-e2e-specs.js +0 -75
@@ -1,383 +0,0 @@
1
- // @ts-check
2
-
3
- import B from 'bluebird';
4
- import { default as BaseDriver, errors } from '../../lib';
5
- import logger from '../../lib/basedriver/logger';
6
- import { createSandbox } from 'sinon';
7
-
8
- describe('Desired Capabilities', function () {
9
- let d;
10
- let sandbox;
11
-
12
- beforeEach(function () {
13
- d = new BaseDriver();
14
- sandbox = createSandbox();
15
- sandbox.spy(d.log, 'warn');
16
- sandbox.spy(logger, 'warn');
17
- });
18
-
19
- afterEach(function () {
20
- sandbox.restore();
21
- });
22
-
23
- it('should require platformName and deviceName', async function () {
24
- await d.createSession({
25
- firstMatch: [{}]
26
- }).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /platformName/);
27
- });
28
-
29
-
30
- it('should require platformName', async function () {
31
- await d.createSession({
32
- alwaysMatch: {
33
- 'appium:deviceName': 'Delorean'
34
- }
35
- }).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /platformName/);
36
- });
37
-
38
- it('should not care about cap order', async function () {
39
- await d.createSession(null, null, {
40
- alwaysMatch: {
41
- 'appium:deviceName': 'Delorean',
42
- platformName: 'iOS'
43
- }
44
- }).should.eventually.be.fulfilled;
45
- });
46
-
47
- it('should check required caps which are added to driver', async function () {
48
- d.desiredCapConstraints = {
49
- necessary: {
50
- presence: true
51
- },
52
- proper: {
53
- presence: true,
54
- isString: true,
55
- inclusion: ['Delorean', 'Reventon']
56
- }
57
- };
58
-
59
- await d.createSession(null, null, {
60
- alwaysMatch: {
61
- 'platformName': 'iOS',
62
- 'appium:deviceName': 'Delorean'
63
- }
64
- }).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /necessary.*proper/);
65
- });
66
-
67
- it('should check added required caps in addition to base', async function () {
68
- d.desiredCapConstraints = {
69
- necessary: {
70
- presence: true
71
- },
72
- proper: {
73
- presence: true,
74
- isString: true,
75
- inclusion: ['Delorean', 'Reventon']
76
- }
77
- };
78
-
79
- await d.createSession(null, null, {
80
- alwaysMatch: {
81
- 'appium:necessary': 'yup'
82
- }
83
- }).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /platformName/);
84
- });
85
-
86
- it('should accept extra capabilities', async function () {
87
- await d.createSession(null, null, {
88
- alwaysMatch: {
89
- 'platformName': 'iOS',
90
- 'appium:deviceName': 'Delorean',
91
- 'appium:extra': 'cheese',
92
- 'appium:hold the': 'sauce'
93
- }
94
- }).should.eventually.be.fulfilled;
95
- });
96
-
97
- it('should log the use of extra caps', async function () {
98
- this.timeout(500);
99
-
100
- await d.createSession(null, null, {
101
- alwaysMatch: {
102
- 'platformName': 'iOS',
103
- 'appium:deviceName': 'Delorean',
104
- 'appium:extra': 'cheese',
105
- 'appium:hold the': 'sauce'
106
- }
107
- });
108
-
109
- d.log.warn.should.have.been.called;
110
- });
111
-
112
- it('should be sensitive to the case of caps', async function () {
113
- await d.createSession(null, null, {
114
- alwaysMatch: {
115
- 'platformname': 'iOS',
116
- 'appium:deviceName': 'Delorean'
117
- }
118
- }).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /platformName/);
119
- });
120
-
121
- describe('boolean capabilities', function () {
122
- it('should allow a string "false"', async function () {
123
- await d.createSession(null, null, {
124
- alwaysMatch: {
125
- 'platformName': 'iOS',
126
- 'appium:deviceName': 'Delorean',
127
- 'appium:noReset': 'false'
128
- }
129
- });
130
- d.log.warn.should.have.been.called;
131
-
132
- let sessions = await d.getSessions();
133
- sessions[0].capabilities.noReset.should.eql(false);
134
- });
135
-
136
- it('should allow a string "true"', async function () {
137
- await d.createSession(null, null, {
138
- alwaysMatch: {
139
- 'platformName': 'iOS',
140
- 'appium:deviceName': 'Delorean',
141
- 'appium:noReset': 'true'
142
- }
143
- });
144
- d.log.warn.should.have.been.called;
145
-
146
- let sessions = await d.getSessions();
147
- sessions[0].capabilities.noReset.should.eql(true);
148
- });
149
-
150
- it('should allow a string "true" in string capabilities', async function () {
151
- await d.createSession(null, null, {
152
- alwaysMatch: {
153
- 'platformName': 'iOS',
154
- 'appium:deviceName': 'Delorean',
155
- 'appium:language': 'true'
156
- }
157
- });
158
- d.log.warn.should.not.have.been.called;
159
-
160
- let sessions = await d.getSessions();
161
- sessions[0].capabilities.language.should.eql('true');
162
- });
163
- });
164
-
165
- describe('number capabilities', function () {
166
- it('should allow a string "1"', async function () {
167
- await d.createSession(null, null, {
168
- alwaysMatch: {
169
- 'platformName': 'iOS',
170
- 'appium:deviceName': 'Delorean',
171
- 'appium:newCommandTimeout': '1'
172
- }
173
- });
174
- d.log.warn.should.have.been.called;
175
-
176
- let sessions = await d.getSessions();
177
- sessions[0].capabilities.newCommandTimeout.should.eql(1);
178
- });
179
-
180
- it('should allow a string "1.1"', async function () {
181
- await d.createSession(null, null, {
182
- alwaysMatch: {
183
- 'platformName': 'iOS',
184
- 'appium:deviceName': 'Delorean',
185
- 'appium:newCommandTimeout': '1.1'
186
- }
187
- });
188
- d.log.warn.should.have.been.called;
189
-
190
- let sessions = await d.getSessions();
191
- sessions[0].capabilities.newCommandTimeout.should.eql(1.1);
192
- });
193
-
194
- it('should allow a string "1" in string capabilities', async function () {
195
- await d.createSession(null, null, {
196
- alwaysMatch: {
197
- 'platformName': 'iOS',
198
- 'appium:deviceName': 'Delorean',
199
- 'appium:language': '1'
200
- }
201
- });
202
- d.log.warn.should.not.have.been.called;
203
-
204
- let sessions = await d.getSessions();
205
- sessions[0].capabilities.language.should.eql('1');
206
- });
207
- });
208
-
209
- it ('should error if objects in caps', async function () {
210
- await d.createSession(null, null, {
211
- alwaysMatch: {
212
- 'platformName': {a: 'iOS'},
213
- 'appium:deviceName': 'Delorean'
214
- }
215
- }).should.eventually.be.rejectedWith(errors.SessionNotCreatedError, /platformName/i);
216
- });
217
-
218
- it('should check for deprecated caps', async function () {
219
- this.timeout(500);
220
-
221
- d.desiredCapConstraints = {
222
- 'lynx-version': {
223
- deprecated: true
224
- }
225
- };
226
-
227
- await d.createSession(null, null, {
228
- alwaysMatch: {
229
- 'platformName': 'iOS',
230
- 'appium:deviceName': 'Delorean',
231
- 'appium:lynx-version': 5
232
- }
233
- });
234
-
235
- logger.warn.should.have.been.called;
236
- });
237
-
238
- it('should not warn if deprecated=false', async function () {
239
- this.timeout(500);
240
-
241
- d.desiredCapConstraints = {
242
- 'lynx-version': {
243
- deprecated: false
244
- }
245
- };
246
-
247
- await d.createSession(null, null, {
248
- alwaysMatch: {
249
- 'platformName': 'iOS',
250
- 'appium:deviceName': 'Delorean',
251
- 'appium:lynx-version': 5
252
- }
253
- });
254
-
255
- d.log.warn.should.not.have.been.called;
256
- });
257
-
258
- it('should not validate against null/undefined caps', async function () {
259
- d.desiredCapConstraints = {
260
- 'foo': {
261
- isString: true
262
- }
263
- };
264
-
265
- try {
266
- await d.createSession(null, null, {
267
- alwaysMatch: {
268
- platformName: 'iOS',
269
- 'appium:deviceName': 'Dumb',
270
- 'appium:foo': null
271
- }
272
- });
273
- } finally {
274
- await d.deleteSession();
275
- }
276
-
277
- await d.createSession(null, null, {
278
- alwaysMatch: {
279
- platformName: 'iOS',
280
- 'appium:deviceName': 'Dumb',
281
- 'appium:foo': 1
282
- }
283
- }).should.eventually.be.rejectedWith(/'foo' must be of type string/);
284
-
285
- try {
286
- await d.createSession(null, null, {
287
- alwaysMatch: {
288
- platformName: 'iOS',
289
- 'appium:deviceName': 'Dumb',
290
- 'appium:foo': undefined
291
- }
292
- });
293
- } finally {
294
- await d.deleteSession();
295
- }
296
-
297
- try {
298
- await d.createSession(null, null, {
299
- alwaysMatch: {
300
- platformName: 'iOS',
301
- 'appium:deviceName': 'Dumb',
302
- 'appium:foo': ''
303
- }
304
- });
305
- } finally {
306
- await d.deleteSession();
307
- }
308
- });
309
-
310
- it('should still validate null/undefined/empty caps whose presence is required', async function () {
311
- d.desiredCapConstraints = {
312
- foo: {
313
- presence: true
314
- },
315
- };
316
-
317
- await d.createSession(null, null, {
318
- alwaysMatch: {
319
- platformName: 'iOS',
320
- 'appium:deviceName': 'Dumb',
321
- 'appium:foo': null
322
- }
323
- }).should.eventually.be.rejectedWith(/blank/);
324
-
325
- await d.createSession(null, {
326
- alwaysMatch: {
327
- platformName: 'iOS',
328
- 'appium:deviceName': 'Dumb',
329
- 'appium:foo': ''
330
- }
331
- }).should.eventually.be.rejectedWith(/blank/);
332
-
333
- await d.createSession({
334
- firstMatch: [{
335
- platformName: 'iOS',
336
- 'appium:deviceName': 'Dumb',
337
- 'appium:foo': {}
338
- }]
339
- }).should.eventually.be.rejectedWith(/blank/);
340
-
341
- await d.createSession({
342
- alwaysMatch: {
343
- platformName: 'iOS',
344
- 'appium:deviceName': 'Dumb',
345
- 'appium:foo': []
346
- }
347
- }).should.eventually.be.rejectedWith(/blank/);
348
-
349
- await d.createSession({
350
- alwaysMatch: {
351
- platformName: 'iOS',
352
- 'appium:deviceName': 'Dumb',
353
- 'appium:foo': ' '
354
- }
355
- }).should.eventually.be.rejectedWith(/blank/);
356
- });
357
-
358
- describe('w3c', function () {
359
- it('should accept w3c capabilities', async function () {
360
- const [sessionId, caps] = await d.createSession(null, null, {
361
- alwaysMatch: {
362
- platformName: 'iOS',
363
- 'appium:deviceName': 'Delorean'
364
- }, firstMatch: [{}],
365
- });
366
- try {
367
- sessionId.should.exist;
368
- caps.should.eql({
369
- platformName: 'iOS',
370
- deviceName: 'Delorean',
371
- });
372
- } finally {
373
- await d.deleteSession();
374
- }
375
- });
376
-
377
- it('should raise an error if w3c capabilities is not a plain JSON object', async function () {
378
- const testValues = [true, 'string', [], 100];
379
- // this loop runs in parallel, and does not guarantee all assertions will be made
380
- await B.map(testValues, (val) => d.createSession(null, null, val).should.eventually.be.rejectedWith(errors.SessionNotCreatedError));
381
- });
382
- });
383
- });
@@ -1,74 +0,0 @@
1
- import _ from 'lodash';
2
- import { BaseDriver } from '../../../lib';
3
-
4
-
5
-
6
- describe('logging custom events', function () {
7
- it('should allow logging of events', async function () {
8
- const d = new BaseDriver();
9
- d._eventHistory.should.eql({commands: []});
10
- await d.logCustomEvent('myorg', 'myevent');
11
- _.keys(d._eventHistory).should.eql(['commands', 'myorg:myevent']);
12
- });
13
- it('should get all events including custom ones', async function () {
14
- const d = new BaseDriver();
15
- d._eventHistory.should.eql({commands: []});
16
- d.logEvent('appiumEvent');
17
- await d.logCustomEvent('myorg', 'myevent');
18
- const events = await d.getLogEvents();
19
- _.keys(events).should.eql(['commands', 'appiumEvent', 'myorg:myevent']);
20
- });
21
- });
22
-
23
- describe('#getLogEvents', function () {
24
- it('should allow to get all events', async function () {
25
- const d = new BaseDriver();
26
- d._eventHistory.should.eql({commands: []});
27
- d._eventHistory.testCommand = ['1', '2', '3'];
28
- await d.getLogEvents().should.eql({
29
- commands: [], testCommand: ['1', '2', '3']
30
- });
31
- });
32
-
33
- it('should filter with testCommand', async function () {
34
- const d = new BaseDriver();
35
- d._eventHistory.should.eql({commands: []});
36
- d._eventHistory.testCommand = ['1', '2', '3'];
37
- await d.getLogEvents('testCommand').should.eql({
38
- testCommand: ['1', '2', '3']
39
- });
40
- });
41
-
42
- it('should not filter with wrong but can be a part of the event name', async function () {
43
- const d = new BaseDriver();
44
- d._eventHistory.should.eql({commands: []});
45
- d._eventHistory.testCommand = ['1', '2', '3'];
46
- await d.getLogEvents('testCommandDummy').should.eql({});
47
- });
48
-
49
- it('should filter with multiple event keys', async function () {
50
- const d = new BaseDriver();
51
- d._eventHistory.should.eql({commands: []});
52
- d._eventHistory.testCommand = ['1', '2', '3'];
53
- d._eventHistory.testCommand2 = ['4', '5'];
54
- await d.getLogEvents(['testCommand', 'testCommand2']).should.eql({
55
- testCommand: ['1', '2', '3'], testCommand2: ['4', '5']
56
- });
57
- });
58
-
59
- it('should filter with custom events', async function () {
60
- const d = new BaseDriver();
61
- d._eventHistory.should.eql({commands: []});
62
- d._eventHistory['custom:appiumEvent'] = ['1', '2', '3'];
63
- await d.getLogEvents(['custom:appiumEvent']).should.eql({
64
- 'custom:appiumEvent': ['1', '2', '3']
65
- });
66
- });
67
-
68
- it('should not filter with no existed event name', async function () {
69
- const d = new BaseDriver();
70
- d._eventHistory.should.eql({commands: []});
71
- d._eventHistory.testCommand = ['1', '2', '3'];
72
- await d.getLogEvents(['noEventName']).should.eql({});
73
- });
74
- });
@@ -1,79 +0,0 @@
1
- import logCommands from '../../../lib/basedriver/commands/log';
2
- import { createSandbox } from 'sinon';
3
- import _ from 'lodash';
4
-
5
-
6
- const expect = chai.expect;
7
-
8
- const FIRST_LOGS = ['first', 'logs'];
9
- const SECOND_LOGS = ['second', 'logs'];
10
- const SUPPORTED_LOG_TYPES = {
11
- one: {
12
- description: 'First logs',
13
- getter: () => _.clone(FIRST_LOGS),
14
- },
15
- two: {
16
- description: 'Seconds logs',
17
- getter: () => _.clone(SECOND_LOGS),
18
- },
19
- };
20
-
21
- describe('log commands -', function () {
22
- let sandbox;
23
-
24
- beforeEach(function () {
25
- sandbox = createSandbox();
26
- // reset the supported log types
27
- logCommands.supportedLogTypes = {};
28
- logCommands.log = {debug: _.noop};
29
- });
30
-
31
- afterEach(function () {
32
- sandbox.restore();
33
- });
34
-
35
- describe('getLogTypes', function () {
36
- it('should return empty array when no supported log types', async function () {
37
- (await logCommands.getLogTypes()).should.eql([]);
38
- });
39
- it('should return keys to log type object', async function () {
40
- logCommands.supportedLogTypes = SUPPORTED_LOG_TYPES;
41
- (await logCommands.getLogTypes()).should.eql(['one', 'two']);
42
- });
43
- });
44
- describe('getLog', function () {
45
- beforeEach(function () {
46
- sandbox.spy(SUPPORTED_LOG_TYPES.one, 'getter');
47
- sandbox.spy(SUPPORTED_LOG_TYPES.two, 'getter');
48
- });
49
- afterEach(function () {
50
- SUPPORTED_LOG_TYPES.one.getter.restore();
51
- SUPPORTED_LOG_TYPES.two.getter.restore();
52
- });
53
- it('should throw error if log type not supported', async function () {
54
- await logCommands.getLog('one').should.eventually.be.rejected;
55
- SUPPORTED_LOG_TYPES.one.getter.called.should.be.false;
56
- SUPPORTED_LOG_TYPES.two.getter.called.should.be.false;
57
- });
58
- it('should throw an error with available log types if log type not supported', async function () {
59
- logCommands.supportedLogTypes = SUPPORTED_LOG_TYPES;
60
- let err;
61
- try {
62
- await logCommands.getLog('three');
63
- } catch (_err) {
64
- err = _err;
65
- }
66
- expect(err).to.exist;
67
- err.message.should.eql(`Unsupported log type 'three'. Supported types: {"one":"First logs","two":"Seconds logs"}`);
68
- SUPPORTED_LOG_TYPES.one.getter.called.should.be.false;
69
- SUPPORTED_LOG_TYPES.two.getter.called.should.be.false;
70
- });
71
- it('should call getter on appropriate log when found', async function () {
72
- logCommands.supportedLogTypes = SUPPORTED_LOG_TYPES;
73
- let logs = await logCommands.getLog('one');
74
- logs.should.eql(FIRST_LOGS);
75
- SUPPORTED_LOG_TYPES.one.getter.called.should.be.true;
76
- SUPPORTED_LOG_TYPES.two.getter.called.should.be.false;
77
- });
78
- });
79
- });
@@ -1,8 +0,0 @@
1
- // transpile:mocha
2
-
3
- import BaseDriver from '../../lib';
4
- import baseDriverE2ETests from './driver-e2e-tests';
5
- baseDriverE2ETests(BaseDriver, {
6
- platformName: 'iOS',
7
- 'appium:deviceName': 'Delorean'
8
- });
@@ -1,8 +0,0 @@
1
- // transpile:mocha
2
-
3
- import BaseDriver from '../../lib';
4
- import baseDriverUnitTests from './driver-tests';
5
- baseDriverUnitTests(BaseDriver, {
6
- platformName: 'iOS',
7
- 'appium:deviceName': 'Delorean'
8
- });
@@ -1 +0,0 @@
1
- zip zip zip
@@ -1 +0,0 @@
1
- this is not really an apk
@@ -1 +0,0 @@
1
- this is not really an app
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- notFind: function () { // eslint-disable-line object-shorthand
3
- return [];
4
- }
5
- };
@@ -1,29 +0,0 @@
1
- module.exports = {
2
- find: function (driver, logger, selector, multiple) { // eslint-disable-line object-shorthand
3
- if (!driver || !driver.opts) {
4
- throw new Error('Expected driver object');
5
- }
6
-
7
- if (!logger || !logger.info) {
8
- throw new Error('Expected logger object');
9
- }
10
-
11
- if (selector === 'foo') {
12
- return ['bar'];
13
- }
14
-
15
- if (selector === 'foos') {
16
- if (multiple) {
17
- return ['baz1', 'baz2'];
18
- }
19
-
20
- return ['bar1', 'bar2'];
21
- }
22
-
23
- if (selector === 'error') {
24
- throw new Error('This is a plugin error');
25
- }
26
-
27
- return [];
28
- }
29
- };