@appium/base-driver 8.5.2 → 8.5.5
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.
- package/build/lib/basedriver/capabilities.d.ts.map +1 -1
- package/build/lib/basedriver/capabilities.js +1 -1
- package/build/lib/basedriver/commands/event.js +1 -1
- package/build/lib/basedriver/commands/find.d.ts.map +1 -1
- package/build/lib/basedriver/commands/find.js +1 -1
- package/build/lib/basedriver/commands/index.js +1 -1
- package/build/lib/basedriver/commands/log.d.ts.map +1 -1
- package/build/lib/basedriver/commands/log.js +1 -1
- package/build/lib/basedriver/commands/session.js +1 -1
- package/build/lib/basedriver/commands/settings.d.ts.map +1 -1
- package/build/lib/basedriver/commands/settings.js +1 -1
- package/build/lib/basedriver/commands/timeout.d.ts.map +1 -1
- package/build/lib/basedriver/commands/timeout.js +1 -1
- package/build/lib/basedriver/core.d.ts +120 -139
- package/build/lib/basedriver/core.d.ts.map +1 -1
- package/build/lib/basedriver/core.js +1 -49
- package/build/lib/basedriver/desired-caps.d.ts +5 -2
- package/build/lib/basedriver/desired-caps.d.ts.map +1 -1
- package/build/lib/basedriver/desired-caps.js +14 -18
- package/build/lib/basedriver/device-settings.d.ts +9 -9
- package/build/lib/basedriver/device-settings.d.ts.map +1 -1
- package/build/lib/basedriver/device-settings.js +4 -4
- package/build/lib/basedriver/driver.d.ts +43 -38
- package/build/lib/basedriver/driver.d.ts.map +1 -1
- package/build/lib/basedriver/driver.js +58 -11
- package/build/lib/basedriver/helpers.d.ts +8 -3
- package/build/lib/basedriver/helpers.d.ts.map +1 -1
- package/build/lib/basedriver/helpers.js +4 -6
- package/build/lib/basedriver/logger.d.ts +1 -1
- package/build/lib/basedriver/logger.d.ts.map +1 -1
- package/build/lib/basedriver/logger.js +1 -1
- package/build/lib/constants.js +1 -1
- package/build/lib/express/crash.d.ts.map +1 -1
- package/build/lib/express/crash.js +1 -1
- package/build/lib/express/express-logging.d.ts.map +1 -1
- package/build/lib/express/express-logging.js +1 -1
- package/build/lib/express/idempotency.js +1 -1
- package/build/lib/express/logger.d.ts +1 -1
- package/build/lib/express/logger.d.ts.map +1 -1
- package/build/lib/express/logger.js +1 -1
- package/build/lib/express/middleware.d.ts.map +1 -1
- package/build/lib/express/middleware.js +1 -1
- package/build/lib/express/server.d.ts +21 -0
- package/build/lib/express/server.d.ts.map +1 -1
- package/build/lib/express/server.js +4 -9
- package/build/lib/express/static.d.ts.map +1 -1
- package/build/lib/express/static.js +2 -2
- package/build/lib/express/websocket.d.ts +14 -11
- package/build/lib/express/websocket.d.ts.map +1 -1
- package/build/lib/express/websocket.js +2 -2
- package/build/lib/helpers/capabilities.d.ts.map +1 -1
- package/build/lib/helpers/capabilities.js +1 -1
- package/build/lib/index.d.ts +2 -1
- package/build/lib/index.js +7 -1
- package/build/lib/jsonwp-proxy/protocol-converter.d.ts.map +1 -1
- package/build/lib/jsonwp-proxy/protocol-converter.js +2 -2
- package/build/lib/jsonwp-proxy/proxy.d.ts +30 -5
- package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.js +20 -4
- package/build/lib/jsonwp-status/status.d.ts.map +1 -1
- package/build/lib/jsonwp-status/status.js +2 -2
- package/build/lib/protocol/errors.d.ts +17 -8
- package/build/lib/protocol/errors.d.ts.map +1 -1
- package/build/lib/protocol/errors.js +9 -5
- package/build/lib/protocol/helpers.js +1 -1
- package/build/lib/protocol/index.js +1 -1
- package/build/lib/protocol/protocol.d.ts.map +1 -1
- package/build/lib/protocol/protocol.js +1 -1
- package/build/lib/protocol/routes.d.ts +17 -3
- package/build/lib/protocol/routes.d.ts.map +1 -1
- package/build/lib/protocol/routes.js +1 -1
- package/build/lib/protocol/validators.js +1 -1
- package/build/test/basedriver/driver-e2e-tests.js +1 -1
- package/build/test/basedriver/driver-tests.js +1 -1
- package/build/test/basedriver/index.js +1 -1
- package/build/test/e2e/basedriver/driver.e2e.spec.js +1 -1
- package/build/test/e2e/basedriver/helpers.e2e.spec.js +1 -1
- package/build/test/e2e/basedriver/websockets.e2e.spec.js +1 -1
- package/build/test/e2e/express/server.e2e.spec.js +1 -1
- package/build/test/e2e/jsonwp-proxy/proxy.e2e.spec.js +1 -1
- package/build/test/e2e/protocol/fake-driver.js +1 -1
- package/build/test/e2e/protocol/helpers.js +1 -1
- package/build/test/e2e/protocol/protocol.e2e.spec.js +13 -13
- package/build/test/helpers.js +1 -1
- package/build/test/unit/basedriver/capabilities.spec.js +12 -12
- package/build/test/unit/basedriver/capability.spec.js +15 -15
- package/build/test/unit/basedriver/commands/event.spec.js +1 -1
- package/build/test/unit/basedriver/commands/log.spec.js +1 -1
- package/build/test/unit/basedriver/device-settings.spec.js +1 -1
- package/build/test/unit/basedriver/driver.spec.js +1 -1
- package/build/test/unit/basedriver/helpers.spec.js +33 -33
- package/build/test/unit/basedriver/timeout.spec.js +1 -1
- package/build/test/unit/express/server.spec.js +1 -1
- package/build/test/unit/express/static.spec.js +2 -2
- package/build/test/unit/jsonwp-proxy/mock-request.js +1 -1
- package/build/test/unit/jsonwp-proxy/protocol-converter.spec.js +1 -1
- package/build/test/unit/jsonwp-proxy/proxy.spec.js +2 -2
- package/build/test/unit/jsonwp-proxy/url.spec.js +1 -1
- package/build/test/unit/jsonwp-status/status.spec.js +1 -1
- package/build/test/unit/protocol/errors.spec.js +1 -1
- package/build/test/unit/protocol/routes.spec.js +1 -1
- package/build/test/unit/protocol/validator.spec.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/basedriver/capabilities.js +95 -47
- package/lib/basedriver/commands/event.js +4 -4
- package/lib/basedriver/commands/find.js +12 -26
- package/lib/basedriver/commands/index.js +7 -7
- package/lib/basedriver/commands/log.js +5 -7
- package/lib/basedriver/commands/session.js +3 -3
- package/lib/basedriver/commands/settings.js +3 -5
- package/lib/basedriver/commands/timeout.js +18 -23
- package/lib/basedriver/core.js +150 -229
- package/lib/basedriver/desired-caps.js +30 -29
- package/lib/basedriver/device-settings.js +21 -20
- package/lib/basedriver/driver.js +131 -96
- package/lib/basedriver/helpers.js +124 -81
- package/lib/basedriver/logger.js +1 -1
- package/lib/constants.js +2 -6
- package/lib/express/crash.js +4 -6
- package/lib/express/express-logging.js +26 -24
- package/lib/express/idempotency.js +16 -16
- package/lib/express/logger.js +1 -1
- package/lib/express/middleware.js +49 -33
- package/lib/express/server.js +68 -44
- package/lib/express/static.js +11 -12
- package/lib/express/websocket.js +26 -16
- package/lib/helpers/capabilities.js +11 -16
- package/lib/index.js +50 -33
- package/lib/jsonwp-proxy/protocol-converter.js +85 -69
- package/lib/jsonwp-proxy/proxy.js +116 -53
- package/lib/jsonwp-status/status.js +36 -29
- package/lib/protocol/errors.js +469 -292
- package/lib/protocol/helpers.js +5 -8
- package/lib/protocol/index.js +22 -15
- package/lib/protocol/protocol.js +103 -55
- package/lib/protocol/routes.js +430 -273
- package/lib/protocol/validators.js +5 -5
- package/package.json +9 -11
- package/test/basedriver/driver-e2e-tests.js +92 -66
- package/test/basedriver/driver-tests.js +90 -33
- package/test/basedriver/index.js +1 -1
package/lib/basedriver/core.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
/* eslint-disable no-unused-vars */
|
|
3
2
|
/* eslint-disable require-await */
|
|
4
3
|
|
|
5
|
-
import {
|
|
4
|
+
import {fs, logger} from '@appium/support';
|
|
6
5
|
import AsyncLock from 'async-lock';
|
|
7
|
-
import {
|
|
6
|
+
import {EventEmitter} from 'events';
|
|
8
7
|
import _ from 'lodash';
|
|
9
8
|
import os from 'os';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { validateCaps } from './capabilities';
|
|
13
|
-
import { desiredCapabilityConstraints } from './desired-caps';
|
|
9
|
+
import {DEFAULT_BASE_PATH, PROTOCOLS} from '../constants';
|
|
10
|
+
import {errors} from '../protocol';
|
|
14
11
|
import DeviceSettings from './device-settings';
|
|
15
12
|
import helpers from './helpers';
|
|
16
13
|
|
|
@@ -24,7 +21,6 @@ const ON_UNEXPECTED_SHUTDOWN_EVENT = 'onUnexpectedShutdown';
|
|
|
24
21
|
* @implements {Core}
|
|
25
22
|
*/
|
|
26
23
|
class DriverCore {
|
|
27
|
-
|
|
28
24
|
/**
|
|
29
25
|
* Make the basedriver version available so for any driver which inherits from this package, we
|
|
30
26
|
* know which version of basedriver it inherited from
|
|
@@ -32,40 +28,40 @@ class DriverCore {
|
|
|
32
28
|
static baseVersion = BASEDRIVER_VER;
|
|
33
29
|
|
|
34
30
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
* @type {string?}
|
|
32
|
+
*/
|
|
37
33
|
sessionId = null;
|
|
38
34
|
|
|
39
35
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
* @type {import('@appium/types').DriverOpts}
|
|
37
|
+
*/
|
|
42
38
|
opts;
|
|
43
39
|
|
|
44
40
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
* @type {ServerArgs}
|
|
42
|
+
*/
|
|
47
43
|
initialOpts;
|
|
48
44
|
|
|
49
45
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
* @type {Capabilities}
|
|
47
|
+
*/
|
|
52
48
|
caps;
|
|
53
49
|
|
|
54
50
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
* @type {W3CCapabilities}
|
|
52
|
+
*/
|
|
57
53
|
originalCaps;
|
|
58
54
|
|
|
59
55
|
helpers = helpers;
|
|
60
56
|
|
|
61
57
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
* basePath is used for several purposes, for example in setting up
|
|
59
|
+
* proxying to other drivers, since we need to know what the base path
|
|
60
|
+
* of any incoming request might look like. We set it to the default
|
|
61
|
+
* initially but it is automatically updated during any actual program
|
|
62
|
+
* execution by the routeConfiguringFunction, which is necessarily run as
|
|
63
|
+
* the entrypoint for any Appium server
|
|
64
|
+
*/
|
|
69
65
|
basePath = DEFAULT_BASE_PATH;
|
|
70
66
|
|
|
71
67
|
relaxedSecurityEnabled = false;
|
|
@@ -95,45 +91,39 @@ class DriverCore {
|
|
|
95
91
|
/** @type {EventHistory} */
|
|
96
92
|
_eventHistory = {commands: []};
|
|
97
93
|
|
|
98
|
-
_constraints = _.cloneDeep(desiredCapabilityConstraints);
|
|
99
|
-
|
|
100
94
|
// used to handle driver events
|
|
101
95
|
/** @type {NodeJS.EventEmitter} */
|
|
102
96
|
eventEmitter = new EventEmitter();
|
|
103
97
|
|
|
104
98
|
/**
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
* @type {AppiumLogger}
|
|
100
|
+
*/
|
|
107
101
|
_log;
|
|
108
102
|
|
|
109
103
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
* @protected
|
|
105
|
+
*/
|
|
112
106
|
shutdownUnexpectedly = false;
|
|
113
107
|
|
|
114
108
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
*/
|
|
109
|
+
* @type {boolean}
|
|
110
|
+
*/
|
|
118
111
|
shouldValidateCaps;
|
|
119
112
|
|
|
120
113
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
* @protected
|
|
115
|
+
*/
|
|
123
116
|
commandsQueueGuard = new AsyncLock();
|
|
124
117
|
|
|
125
118
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
119
|
+
* settings should be instantiated by drivers which extend BaseDriver, but
|
|
120
|
+
* we set it to an empty DeviceSettings instance here to make sure that the
|
|
121
|
+
* default settings are applied even if an extending driver doesn't utilize
|
|
122
|
+
* the settings functionality itself
|
|
123
|
+
*/
|
|
131
124
|
settings = new DeviceSettings();
|
|
132
125
|
|
|
133
|
-
constructor (
|
|
134
|
-
opts = /** @type {DriverOpts} */ ({}),
|
|
135
|
-
shouldValidateCaps = true,
|
|
136
|
-
) {
|
|
126
|
+
constructor(opts = /** @type {ServerArgs} */ ({}), shouldValidateCaps = true) {
|
|
137
127
|
this._log = logger.getLogger(helpers.generateDriverLogPrefix(this));
|
|
138
128
|
|
|
139
129
|
// setup state
|
|
@@ -141,8 +131,7 @@ class DriverCore {
|
|
|
141
131
|
|
|
142
132
|
// use a custom tmp dir to avoid losing data and app when computer is
|
|
143
133
|
// restarted
|
|
144
|
-
this.opts.tmpDir =
|
|
145
|
-
this.opts.tmpDir || process.env.APPIUM_TMP_DIR || os.tmpdir();
|
|
134
|
+
this.opts.tmpDir = this.opts.tmpDir || process.env.APPIUM_TMP_DIR || os.tmpdir();
|
|
146
135
|
|
|
147
136
|
// base-driver internals
|
|
148
137
|
this.shouldValidateCaps = shouldValidateCaps;
|
|
@@ -153,63 +142,63 @@ class DriverCore {
|
|
|
153
142
|
this.sessionId = null;
|
|
154
143
|
}
|
|
155
144
|
|
|
156
|
-
get log
|
|
145
|
+
get log() {
|
|
157
146
|
return this._log;
|
|
158
147
|
}
|
|
159
148
|
|
|
160
149
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
onUnexpectedShutdown
|
|
150
|
+
* Set a callback handler if needed to execute a custom piece of code
|
|
151
|
+
* when the driver is shut down unexpectedly. Multiple calls to this method
|
|
152
|
+
* will cause the handler to be executed mutiple times
|
|
153
|
+
*
|
|
154
|
+
* @param {(...args: any[]) => void} handler The code to be executed on unexpected shutdown.
|
|
155
|
+
* The function may accept one argument, which is the actual error instance, which
|
|
156
|
+
* caused the driver to shut down.
|
|
157
|
+
*/
|
|
158
|
+
onUnexpectedShutdown(handler) {
|
|
170
159
|
this.eventEmitter.on(ON_UNEXPECTED_SHUTDOWN_EVENT, handler);
|
|
171
160
|
}
|
|
172
161
|
|
|
173
162
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
get driverData
|
|
163
|
+
* This property is used by AppiumDriver to store the data of the
|
|
164
|
+
* specific driver sessions. This data can be later used to adjust
|
|
165
|
+
* properties for driver instances running in parallel.
|
|
166
|
+
* Override it in inherited driver classes if necessary.
|
|
167
|
+
*
|
|
168
|
+
* @return {Record<string,unknown>} Driver properties mapping
|
|
169
|
+
*/
|
|
170
|
+
get driverData() {
|
|
182
171
|
return {};
|
|
183
172
|
}
|
|
184
173
|
|
|
185
174
|
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
get isCommandsQueueEnabled
|
|
175
|
+
* This property controls the way {#executeCommand} method
|
|
176
|
+
* handles new driver commands received from the client.
|
|
177
|
+
* Override it for inherited classes only in special cases.
|
|
178
|
+
*
|
|
179
|
+
* @return {boolean} If the returned value is true (default) then all the commands
|
|
180
|
+
* received by the particular driver instance are going to be put into the queue,
|
|
181
|
+
* so each following command will not be executed until the previous command
|
|
182
|
+
* execution is completed. False value disables that queue, so each driver command
|
|
183
|
+
* is executed independently and does not wait for anything.
|
|
184
|
+
*/
|
|
185
|
+
get isCommandsQueueEnabled() {
|
|
197
186
|
return true;
|
|
198
187
|
}
|
|
199
188
|
|
|
200
189
|
/*
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
get eventHistory
|
|
190
|
+
* make eventHistory a property and return a cloned object so a consumer can't
|
|
191
|
+
* inadvertently change data outside of logEvent
|
|
192
|
+
*/
|
|
193
|
+
get eventHistory() {
|
|
205
194
|
return _.cloneDeep(this._eventHistory);
|
|
206
195
|
}
|
|
207
196
|
|
|
208
197
|
/**
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
logEvent
|
|
198
|
+
* API method for driver developers to log timings for important events
|
|
199
|
+
* @param {string} eventName
|
|
200
|
+
*/
|
|
201
|
+
logEvent(eventName) {
|
|
213
202
|
if (eventName === 'commands') {
|
|
214
203
|
throw new Error('Cannot log commands directly');
|
|
215
204
|
}
|
|
@@ -226,119 +215,58 @@ class DriverCore {
|
|
|
226
215
|
}
|
|
227
216
|
|
|
228
217
|
/**
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
async getStatus
|
|
218
|
+
* Overridden in appium driver, but here so that individual drivers can be
|
|
219
|
+
* tested with clients that poll
|
|
220
|
+
*/
|
|
221
|
+
async getStatus() {
|
|
233
222
|
return {};
|
|
234
223
|
}
|
|
235
224
|
|
|
236
|
-
// we only want subclasses to ever extend the contraints
|
|
237
|
-
set desiredCapConstraints (constraints) {
|
|
238
|
-
this._constraints = Object.assign(this._constraints, constraints);
|
|
239
|
-
// 'presence' means different things in different versions of the validator,
|
|
240
|
-
// when we say 'true' we mean that it should not be able to be empty
|
|
241
|
-
for (const [, value] of _.toPairs(this._constraints)) {
|
|
242
|
-
if (value && value.presence === true) {
|
|
243
|
-
value.presence = {
|
|
244
|
-
allowEmpty: false,
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
get desiredCapConstraints () {
|
|
251
|
-
return this._constraints;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
225
|
/**
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
sessionExists
|
|
226
|
+
* method required by MJSONWP in order to determine whether it should
|
|
227
|
+
* respond with an invalid session response
|
|
228
|
+
* @param {string} [sessionId]
|
|
229
|
+
* @returns {boolean}
|
|
230
|
+
*/
|
|
231
|
+
sessionExists(sessionId) {
|
|
261
232
|
if (!sessionId) return false; // eslint-disable-line curly
|
|
262
233
|
return sessionId === this.sessionId;
|
|
263
234
|
}
|
|
264
235
|
|
|
265
236
|
/**
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
driverForSession
|
|
237
|
+
* method required by MJSONWP in order to determine if the command should
|
|
238
|
+
* be proxied directly to the driver
|
|
239
|
+
* @param {string} sessionId
|
|
240
|
+
* @returns {Core | null}
|
|
241
|
+
*/
|
|
242
|
+
driverForSession(sessionId) {
|
|
272
243
|
return this;
|
|
273
244
|
}
|
|
274
245
|
|
|
275
|
-
|
|
276
|
-
*
|
|
277
|
-
* @param {Capabilities} caps
|
|
278
|
-
*/
|
|
279
|
-
logExtraCaps (caps) {
|
|
280
|
-
let extraCaps = _.difference(_.keys(caps), _.keys(this._constraints));
|
|
281
|
-
if (extraCaps.length) {
|
|
282
|
-
this.log.warn(
|
|
283
|
-
`The following capabilities were provided, but are not ` +
|
|
284
|
-
`recognized by Appium:`,
|
|
285
|
-
);
|
|
286
|
-
for (const cap of extraCaps) {
|
|
287
|
-
this.log.warn(` ${cap}`);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
*
|
|
294
|
-
* @param {Capabilities} caps
|
|
295
|
-
* @returns {boolean}
|
|
296
|
-
*/
|
|
297
|
-
validateDesiredCaps (caps) {
|
|
298
|
-
if (!this.shouldValidateCaps) {
|
|
299
|
-
return true;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
try {
|
|
303
|
-
validateCaps(caps, this._constraints);
|
|
304
|
-
} catch (e) {
|
|
305
|
-
this.log.errorAndThrow(
|
|
306
|
-
new errors.SessionNotCreatedError(
|
|
307
|
-
`The desiredCapabilities object was not valid for the ` +
|
|
308
|
-
`following reason(s): ${e.message}`,
|
|
309
|
-
),
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
this.logExtraCaps(caps);
|
|
314
|
-
|
|
315
|
-
return true;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
isMjsonwpProtocol () {
|
|
246
|
+
isMjsonwpProtocol() {
|
|
319
247
|
return this.protocol === PROTOCOLS.MJSONWP;
|
|
320
248
|
}
|
|
321
249
|
|
|
322
|
-
isW3CProtocol
|
|
250
|
+
isW3CProtocol() {
|
|
323
251
|
return this.protocol === PROTOCOLS.W3C;
|
|
324
252
|
}
|
|
325
253
|
|
|
326
|
-
setProtocolMJSONWP
|
|
254
|
+
setProtocolMJSONWP() {
|
|
327
255
|
this.protocol = PROTOCOLS.MJSONWP;
|
|
328
256
|
}
|
|
329
257
|
|
|
330
|
-
setProtocolW3C
|
|
258
|
+
setProtocolW3C() {
|
|
331
259
|
this.protocol = PROTOCOLS.W3C;
|
|
332
260
|
}
|
|
333
261
|
|
|
334
262
|
/**
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
isFeatureEnabled
|
|
263
|
+
* Check whether a given feature is enabled via its name
|
|
264
|
+
*
|
|
265
|
+
* @param {string} name - name of feature/command
|
|
266
|
+
*
|
|
267
|
+
* @returns {Boolean}
|
|
268
|
+
*/
|
|
269
|
+
isFeatureEnabled(name) {
|
|
342
270
|
// if we have explicitly denied this feature, return false immediately
|
|
343
271
|
if (this.denyInsecure && _.includes(this.denyInsecure, name)) {
|
|
344
272
|
return false;
|
|
@@ -360,35 +288,31 @@ class DriverCore {
|
|
|
360
288
|
}
|
|
361
289
|
|
|
362
290
|
/**
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
ensureFeatureEnabled
|
|
291
|
+
* Assert that a given feature is enabled and throw a helpful error if it's
|
|
292
|
+
* not
|
|
293
|
+
*
|
|
294
|
+
* @param {string} name - name of feature/command
|
|
295
|
+
*/
|
|
296
|
+
ensureFeatureEnabled(name) {
|
|
369
297
|
if (!this.isFeatureEnabled(name)) {
|
|
370
298
|
throw new Error(
|
|
371
299
|
`Potentially insecure feature '${name}' has not been ` +
|
|
372
300
|
`enabled. If you want to enable this feature and accept ` +
|
|
373
301
|
`the security ramifications, please do so by following ` +
|
|
374
302
|
`the documented instructions at https://github.com/appium` +
|
|
375
|
-
`/appium/blob/master/docs/en/writing-running-appium/security.md
|
|
303
|
+
`/appium/blob/master/docs/en/writing-running-appium/security.md`
|
|
376
304
|
);
|
|
377
305
|
}
|
|
378
306
|
}
|
|
379
307
|
|
|
380
308
|
/**
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
validateLocatorStrategy
|
|
309
|
+
*
|
|
310
|
+
* @param {string} strategy
|
|
311
|
+
* @param {boolean} [webContext]
|
|
312
|
+
*/
|
|
313
|
+
validateLocatorStrategy(strategy, webContext = false) {
|
|
386
314
|
let validStrategies = this.locatorStrategies;
|
|
387
|
-
this.log.debug(
|
|
388
|
-
`Valid locator strategies for this request: ${validStrategies.join(
|
|
389
|
-
', ',
|
|
390
|
-
)}`,
|
|
391
|
-
);
|
|
315
|
+
this.log.debug(`Valid locator strategies for this request: ${validStrategies.join(', ')}`);
|
|
392
316
|
|
|
393
317
|
if (webContext) {
|
|
394
318
|
validStrategies = validStrategies.concat(this.webLocatorStrategies);
|
|
@@ -396,52 +320,52 @@ class DriverCore {
|
|
|
396
320
|
|
|
397
321
|
if (!_.includes(validStrategies, strategy)) {
|
|
398
322
|
throw new errors.InvalidSelectorError(
|
|
399
|
-
`Locator Strategy '${strategy}' is not supported for this session
|
|
323
|
+
`Locator Strategy '${strategy}' is not supported for this session`
|
|
400
324
|
);
|
|
401
325
|
}
|
|
402
326
|
}
|
|
403
327
|
|
|
404
328
|
/**
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
proxyActive
|
|
329
|
+
*
|
|
330
|
+
* @param {string} [sessionId]
|
|
331
|
+
* @returns {boolean}
|
|
332
|
+
*/
|
|
333
|
+
proxyActive(sessionId) {
|
|
410
334
|
return false;
|
|
411
335
|
}
|
|
412
336
|
|
|
413
337
|
/**
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
getProxyAvoidList
|
|
338
|
+
*
|
|
339
|
+
* @param {string} sessionId
|
|
340
|
+
* @returns {[string, RegExp][]}
|
|
341
|
+
*/
|
|
342
|
+
getProxyAvoidList(sessionId) {
|
|
419
343
|
return [];
|
|
420
344
|
}
|
|
421
345
|
|
|
422
346
|
/**
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
canProxy
|
|
347
|
+
*
|
|
348
|
+
* @param {string} [sessionId]
|
|
349
|
+
* @returns {boolean}
|
|
350
|
+
*/
|
|
351
|
+
canProxy(sessionId) {
|
|
428
352
|
return false;
|
|
429
353
|
}
|
|
430
354
|
|
|
431
355
|
/**
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
proxyRouteIsAvoided
|
|
356
|
+
* Whether a given command route (expressed as method and url) should not be
|
|
357
|
+
* proxied according to this driver
|
|
358
|
+
*
|
|
359
|
+
* @param {string} sessionId - the current sessionId (in case the driver runs
|
|
360
|
+
* multiple session ids and requires it). This is not used in this method but
|
|
361
|
+
* should be made available to overridden methods.
|
|
362
|
+
* @param {import('@appium/types').HTTPMethod} method - HTTP method of the route
|
|
363
|
+
* @param {string} url - url of the route
|
|
364
|
+
* @param {any} [body] - webdriver request body
|
|
365
|
+
*
|
|
366
|
+
* @returns {boolean} - whether the route should be avoided
|
|
367
|
+
*/
|
|
368
|
+
proxyRouteIsAvoided(sessionId, method, url, body) {
|
|
445
369
|
for (let avoidSchema of this.getProxyAvoidList(sessionId)) {
|
|
446
370
|
if (!_.isArray(avoidSchema) || avoidSchema.length !== 2) {
|
|
447
371
|
throw new Error('Proxy avoidance must be a list of pairs');
|
|
@@ -453,10 +377,7 @@ class DriverCore {
|
|
|
453
377
|
if (!_.isRegExp(avoidPathRegex)) {
|
|
454
378
|
throw new Error('Proxy avoidance path must be a regular expression');
|
|
455
379
|
}
|
|
456
|
-
let normalizedUrl = url.replace(
|
|
457
|
-
new RegExp(`^${_.escapeRegExp(this.basePath)}`),
|
|
458
|
-
'',
|
|
459
|
-
);
|
|
380
|
+
let normalizedUrl = url.replace(new RegExp(`^${_.escapeRegExp(this.basePath)}`), '');
|
|
460
381
|
if (avoidMethod === method && avoidPathRegex.test(normalizedUrl)) {
|
|
461
382
|
return true;
|
|
462
383
|
}
|
|
@@ -465,18 +386,18 @@ class DriverCore {
|
|
|
465
386
|
}
|
|
466
387
|
|
|
467
388
|
/**
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
addManagedDriver
|
|
389
|
+
*
|
|
390
|
+
* @param {Driver} driver
|
|
391
|
+
*/
|
|
392
|
+
addManagedDriver(driver) {
|
|
472
393
|
this.managedDrivers.push(driver);
|
|
473
394
|
}
|
|
474
395
|
|
|
475
|
-
getManagedDrivers
|
|
396
|
+
getManagedDrivers() {
|
|
476
397
|
return this.managedDrivers;
|
|
477
398
|
}
|
|
478
399
|
|
|
479
|
-
async clearNewCommandTimeout
|
|
400
|
+
async clearNewCommandTimeout() {
|
|
480
401
|
if (this.noCommandTimer) {
|
|
481
402
|
clearTimeout(this.noCommandTimer);
|
|
482
403
|
this.noCommandTimer = null;
|
|
@@ -491,7 +412,7 @@ export {DriverCore};
|
|
|
491
412
|
* @typedef {import('@appium/types').W3CCapabilities} W3CCapabilities
|
|
492
413
|
* @typedef {import('@appium/types').Driver} Driver
|
|
493
414
|
* @typedef {import('@appium/types').Core} Core
|
|
494
|
-
* @typedef {import('@appium/types').ServerArgs}
|
|
415
|
+
* @typedef {import('@appium/types').ServerArgs} ServerArgs
|
|
495
416
|
* @typedef {import('@appium/types').EventHistory} EventHistory
|
|
496
417
|
* @typedef {import('@appium/types').AppiumLogger} AppiumLogger
|
|
497
418
|
*/
|