@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
@@ -16,8 +16,6 @@ const CREATE_SESSION_COMMAND = 'createSession';
16
16
  const DELETE_SESSION_COMMAND = 'deleteSession';
17
17
  const GET_STATUS_COMMAND = 'getStatus';
18
18
 
19
- class Protocol {}
20
-
21
19
  function determineProtocol (createSessionArgs) {
22
20
  return _.some(createSessionArgs, isW3cCaps) ? PROTOCOLS.W3C : PROTOCOLS.MJSONWP;
23
21
  }
@@ -456,7 +454,7 @@ async function doJwpProxy (driver, req, res) {
456
454
 
457
455
 
458
456
  export {
459
- Protocol, routeConfiguringFunction, isSessionCommand,
457
+ routeConfiguringFunction, isSessionCommand,
460
458
  driverShouldDoJwpProxy, determineProtocol, CREATE_SESSION_COMMAND,
461
459
  DELETE_SESSION_COMMAND, GET_STATUS_COMMAND,
462
460
  };
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  import _ from 'lodash';
2
4
  import { util } from '@appium/support';
3
5
  import { PROTOCOLS, DEFAULT_BASE_PATH } from '../constants';
@@ -14,6 +16,7 @@ const SET_ALERT_TEXT_PAYLOAD_PARAMS = {
14
16
  // define the routes, mapping of HTTP methods to particular driver commands,
15
17
  // and any parameters that are expected in a request
16
18
  // parameters can be `required` or `optional`
19
+ /** @type {import('@appium/types').MethodMap} */
17
20
  const METHOD_MAP = {
18
21
  '/status': {
19
22
  GET: {command: 'getStatus'}
@@ -240,6 +243,12 @@ const METHOD_MAP = {
240
243
  '/session/:sessionId/element/:elementId/shadow': {
241
244
  GET: {command: 'elementShadowRoot'}
242
245
  },
246
+ '/session/:sessionId/shadow/:shadowId/element': {
247
+ POST: {command: 'findElementFromShadowRoot', payloadParams: {required: ['using', 'value']}}
248
+ },
249
+ '/session/:sessionId/shadow/:shadowId/elements': {
250
+ POST: {command: 'findElementsFromShadowRoot', payloadParams: {required: ['using', 'value']}}
251
+ },
243
252
  '/session/:sessionId/element/:elementId/css/:propertyName': {
244
253
  GET: {command: 'getCssProperty'}
245
254
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appium/base-driver",
3
- "version": "8.3.0",
3
+ "version": "8.4.1",
4
4
  "description": "Base driver class for Appium drivers",
5
5
  "keywords": [
6
6
  "automation",
@@ -32,36 +32,43 @@
32
32
  "lib",
33
33
  "static",
34
34
  "test/basedriver",
35
- "!test/basedriver/fixtures",
35
+ "!test/e2e/fixtures",
36
36
  "build",
37
- "!build/test/basedriver/fixtures"
37
+ "!build/test/e2e/fixtures"
38
38
  ],
39
39
  "scripts": {
40
- "dev": "gulp dev --no-notif",
41
- "build": "gulp transpile",
42
- "test": "gulp unit-test:run",
43
- "test:e2e": "gulp e2e-test:run"
40
+ "build": "npm run build:distfiles && npm run build:test",
41
+ "build:distfiles": "babel lib --root-mode=upward --out-dir=build/lib",
42
+ "build:test": "babel test --root-mode=upward --out-dir=build/test --copy-files",
43
+ "dev": "run-p \"build:distfiles -- --watch\" \"build:test -- --watch\"",
44
+ "fix": "npm run lint -- --fix",
45
+ "lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
46
+ "test": "npm run test:unit",
47
+ "test:e2e": "mocha --require ../../test/setup-babel.js --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
48
+ "test:unit": "mocha --require ../../test/setup-babel.js \"./test/unit/**/*.spec.js\""
44
49
  },
45
50
  "dependencies": {
46
- "@appium/support": "^2.56.0",
47
- "@babel/runtime": "7.17.8",
51
+ "@appium/support": "file:../support",
52
+ "@babel/runtime": "7.17.9",
48
53
  "@colors/colors": "1.5.0",
49
54
  "async-lock": "1.3.1",
50
55
  "asyncbox": "2.9.2",
51
56
  "axios": "0.26.1",
52
57
  "bluebird": "3.7.2",
53
- "body-parser": "1.19.2",
58
+ "body-parser": "1.20.0",
54
59
  "es6-error": "4.1.1",
55
60
  "express": "4.17.3",
56
61
  "http-status-codes": "2.2.0",
57
62
  "lodash": "4.17.21",
58
- "lru-cache": "7.7.1",
63
+ "lru-cache": "7.8.1",
59
64
  "method-override": "3.0.0",
60
65
  "morgan": "1.10.0",
61
66
  "serve-favicon": "2.5.0",
62
67
  "source-map-support": "0.5.21",
63
- "validate.js": "0.13.1",
64
- "ws": "7.5.7"
68
+ "validate.js": "0.13.1"
69
+ },
70
+ "devDependencies": {
71
+ "ws": "8.5.0"
65
72
  },
66
73
  "engines": {
67
74
  "node": ">=12",
@@ -70,5 +77,6 @@
70
77
  "publishConfig": {
71
78
  "access": "public"
72
79
  },
73
- "gitHead": "f5cce0f29d31699decea63ed94c4506f7af469df"
80
+ "types": "./build/lib/index.d.ts",
81
+ "gitHead": "ec6a90a797d2dadb407922426be16efaec9def07"
74
82
  }
@@ -0,0 +1,5 @@
1
+ # Driver Test Helpers
2
+
3
+ This directory contains modules which expose test suites that an external driver can use to test against the base implementation. They are published in the `@appium/base-driver` package.
4
+
5
+ Drivers wanting to leverage these suites will want to add `@appium/base-driver` to their `devDependencies`.
@@ -2,7 +2,7 @@ import _ from 'lodash';
2
2
  import { BaseDriver, server, routeConfiguringFunction, DeviceSettings } from '../../lib';
3
3
  import axios from 'axios';
4
4
  import B from 'bluebird';
5
- import {TEST_HOST, getTestPort, createAppiumURL, METHODS} from '../helpers';
5
+ import { TEST_HOST, getTestPort, createAppiumURL, METHODS } from '../helpers';
6
6
  import { PREFIXED_APPIUM_OPTS_CAP } from '../../lib/basedriver/capabilities';
7
7
  const {POST, DELETE} = METHODS;
8
8
 
@@ -10,6 +10,35 @@ function baseDriverUnitTests (DriverClass, defaultCaps = {}) {
10
10
  // to display the driver under test in report
11
11
  const className = DriverClass.name || '(unknown driver)';
12
12
 
13
+ describe('static property', function () {
14
+ describe('baseVersion', function () {
15
+ it('should exist', function () {
16
+ DriverClass.baseVersion.should.exist;
17
+ });
18
+ });
19
+ });
20
+
21
+ describe('Log prefix', function () {
22
+
23
+ it('should setup log prefix', async function () {
24
+ const d = new DriverClass();
25
+ const previousPrefix = d.log.prefix;
26
+ await d.createSession({
27
+ alwaysMatch: Object.assign({}, defaultCaps, {
28
+ platformName: 'Fake',
29
+ 'appium:deviceName': 'Commodore 64',
30
+ }),
31
+ firstMatch: [{}],
32
+ });
33
+ try {
34
+ previousPrefix.should.not.eql(d.log.prefix);
35
+ } finally {
36
+ await d.deleteSession();
37
+ previousPrefix.should.eql(d.log.prefix);
38
+ }
39
+ });
40
+
41
+ });
13
42
 
14
43
  describe(`BaseDriver (as ${className})`, function () {
15
44
  let d, w3cCaps;
@@ -183,8 +212,8 @@ function baseDriverUnitTests (DriverClass, defaultCaps = {}) {
183
212
  throw new Error('multipass');
184
213
  }.bind(d);
185
214
 
186
- afterEach(function () {
187
- d.clearNewCommandTimeout();
215
+ afterEach(async function () {
216
+ await d.clearNewCommandTimeout();
188
217
  });
189
218
 
190
219
  it('should queue commands and.executeCommand/respond in the order received', async function () {