appium 2.0.0-beta.26 → 2.0.0-beta.29
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/appium.d.ts +215 -0
- package/build/lib/appium.d.ts.map +1 -0
- package/build/lib/appium.js +62 -54
- package/build/lib/cli/args.d.ts +20 -0
- package/build/lib/cli/args.d.ts.map +1 -0
- package/build/lib/cli/args.js +1 -1
- package/build/lib/cli/driver-command.d.ts +36 -0
- package/build/lib/cli/driver-command.d.ts.map +1 -0
- package/build/lib/cli/driver-command.js +8 -7
- package/build/lib/cli/extension-command.d.ts +345 -0
- package/build/lib/cli/extension-command.d.ts.map +1 -0
- package/build/lib/cli/extension-command.js +52 -38
- package/build/lib/cli/extension.d.ts +14 -0
- package/build/lib/cli/extension.d.ts.map +1 -0
- package/build/lib/cli/extension.js +7 -2
- package/build/lib/cli/parser.d.ts +79 -0
- package/build/lib/cli/parser.d.ts.map +1 -0
- package/build/lib/cli/parser.js +1 -1
- package/build/lib/cli/plugin-command.d.ts +39 -0
- package/build/lib/cli/plugin-command.d.ts.map +1 -0
- package/build/lib/cli/plugin-command.js +6 -7
- package/build/lib/cli/utils.d.ts +29 -0
- package/build/lib/cli/utils.d.ts.map +1 -0
- package/build/lib/cli/utils.js +1 -1
- package/build/lib/config-file.d.ts +100 -0
- package/build/lib/config-file.d.ts.map +1 -0
- package/build/lib/config-file.js +1 -1
- package/build/lib/config.d.ts +40 -0
- package/build/lib/config.d.ts.map +1 -0
- package/build/lib/config.js +2 -2
- package/build/lib/constants.d.ts +48 -0
- package/build/lib/constants.d.ts.map +1 -0
- package/build/lib/constants.js +1 -1
- package/build/lib/extension/driver-config.d.ts +84 -0
- package/build/lib/extension/driver-config.d.ts.map +1 -0
- package/build/lib/extension/driver-config.js +1 -1
- package/build/lib/extension/extension-config.d.ts +170 -0
- package/build/lib/extension/extension-config.d.ts.map +1 -0
- package/build/lib/extension/extension-config.js +2 -2
- package/build/lib/extension/index.d.ts +39 -0
- package/build/lib/extension/index.d.ts.map +1 -0
- package/build/lib/extension/index.js +1 -1
- package/build/lib/extension/manifest.d.ts +174 -0
- package/build/lib/extension/manifest.d.ts.map +1 -0
- package/build/lib/extension/manifest.js +1 -1
- package/build/lib/extension/package-changed.d.ts +11 -0
- package/build/lib/extension/package-changed.d.ts.map +1 -0
- package/build/lib/extension/package-changed.js +1 -1
- package/build/lib/extension/plugin-config.d.ts +62 -0
- package/build/lib/extension/plugin-config.d.ts.map +1 -0
- package/build/lib/extension/plugin-config.js +1 -1
- package/build/lib/grid-register.d.ts +10 -0
- package/build/lib/grid-register.d.ts.map +1 -0
- package/build/lib/logger.d.ts +3 -0
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logsink.d.ts +4 -0
- package/build/lib/logsink.d.ts.map +1 -0
- package/build/lib/logsink.js +1 -1
- package/build/lib/main.d.ts +51 -0
- package/build/lib/main.d.ts.map +1 -0
- package/build/lib/main.js +1 -1
- package/build/lib/schema/arg-spec.d.ts +143 -0
- package/build/lib/schema/arg-spec.d.ts.map +1 -0
- package/build/lib/schema/arg-spec.js +1 -1
- package/build/lib/schema/cli-args.d.ts +19 -0
- package/build/lib/schema/cli-args.d.ts.map +1 -0
- package/build/lib/schema/cli-args.js +1 -1
- package/build/lib/schema/cli-transformers.d.ts +5 -0
- package/build/lib/schema/cli-transformers.d.ts.map +1 -0
- package/build/lib/schema/cli-transformers.js +1 -1
- package/build/lib/schema/index.d.ts +3 -0
- package/build/lib/schema/index.d.ts.map +1 -0
- package/build/lib/schema/keywords.d.ts +24 -0
- package/build/lib/schema/keywords.d.ts.map +1 -0
- package/build/lib/schema/keywords.js +1 -1
- package/build/lib/schema/schema.d.ts +259 -0
- package/build/lib/schema/schema.d.ts.map +1 -0
- package/build/lib/schema/schema.js +3 -3
- package/build/lib/utils.d.ts +66 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +6 -4
- package/build/tsconfig.tsbuildinfo +1 -0
- package/lib/appium.js +163 -81
- package/lib/cli/args.js +1 -2
- package/lib/cli/driver-command.js +11 -8
- package/lib/cli/extension-command.js +129 -80
- package/lib/cli/extension.js +13 -3
- package/lib/cli/parser.js +1 -2
- package/lib/cli/plugin-command.js +16 -6
- package/lib/cli/utils.js +1 -1
- package/lib/config-file.js +3 -4
- package/lib/config.js +12 -8
- package/lib/constants.js +0 -1
- package/lib/extension/driver-config.js +31 -12
- package/lib/extension/extension-config.js +21 -22
- package/lib/extension/index.js +1 -2
- package/lib/extension/manifest.js +23 -127
- package/lib/extension/package-changed.js +0 -1
- package/lib/extension/plugin-config.js +9 -7
- package/lib/logsink.js +4 -0
- package/lib/main.js +9 -10
- package/lib/schema/arg-spec.js +10 -6
- package/lib/schema/cli-args.js +0 -1
- package/lib/schema/cli-transformers.js +0 -1
- package/lib/schema/keywords.js +0 -1
- package/lib/schema/schema.js +2 -3
- package/lib/utils.js +49 -16
- package/package.json +12 -14
- package/types/appium-manifest.d.ts +61 -0
- package/types/cli.d.ts +134 -0
- package/types/extension.d.ts +56 -0
- package/types/external-manifest.d.ts +58 -0
- package/types/index.d.ts +7 -0
- package/build/lib/appium-config.schema.json +0 -278
- package/build/lib/schema/appium-config-schema.js +0 -251
- package/lib/schema/appium-config-schema.js +0 -287
- package/types/appium-config.d.ts +0 -197
- package/types/types.d.ts +0 -245
package/lib/appium.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
1
2
|
import _ from 'lodash';
|
|
2
3
|
import { getBuildInfo, updateBuildInfo, APPIUM_VER } from './config';
|
|
3
|
-
import { BaseDriver, errors, isSessionCommand,
|
|
4
|
+
import { BaseDriver, DriverCore, errors, isSessionCommand,
|
|
4
5
|
CREATE_SESSION_COMMAND, DELETE_SESSION_COMMAND, GET_STATUS_COMMAND
|
|
5
6
|
} from '@appium/base-driver';
|
|
6
7
|
import AsyncLock from 'async-lock';
|
|
@@ -8,7 +9,11 @@ import { parseCapsForInnerDriver, pullSettings } from './utils';
|
|
|
8
9
|
import { util, node, logger } from '@appium/support';
|
|
9
10
|
import { getDefaultsForExtension } from './schema';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Invariant set of base constraints
|
|
14
|
+
* @type {Readonly<Constraints>}
|
|
15
|
+
*/
|
|
16
|
+
const desiredCapabilityConstraints = Object.freeze({
|
|
12
17
|
automationName: {
|
|
13
18
|
presence: true,
|
|
14
19
|
isString: true,
|
|
@@ -17,67 +22,99 @@ const desiredCapabilityConstraints = {
|
|
|
17
22
|
presence: true,
|
|
18
23
|
isString: true,
|
|
19
24
|
},
|
|
20
|
-
};
|
|
25
|
+
});
|
|
21
26
|
|
|
22
27
|
const sessionsListGuard = new AsyncLock();
|
|
23
28
|
const pendingDriversGuard = new AsyncLock();
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @implements {SessionHandler}
|
|
32
|
+
*/
|
|
33
|
+
class AppiumDriver extends DriverCore {
|
|
34
|
+
/**
|
|
35
|
+
* Access to sessions list must be guarded with a Semaphore, because
|
|
36
|
+
* it might be changed by other async calls at any time
|
|
37
|
+
* It is not recommended to access this property directly from the outside
|
|
38
|
+
* @type {Record<string,ExternalDriver>}
|
|
39
|
+
*/
|
|
40
|
+
sessions = {};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Access to pending drivers list must be guarded with a Semaphore, because
|
|
44
|
+
* it might be changed by other async calls at any time
|
|
45
|
+
* It is not recommended to access this property directly from the outside
|
|
46
|
+
* @type {Record<string,ExternalDriver[]>}
|
|
47
|
+
*/
|
|
48
|
+
pendingDrivers = {};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Note that {@linkcode AppiumDriver} has no `newCommandTimeout` method.
|
|
52
|
+
* `AppiumDriver` does not set and observe its own timeouts; individual
|
|
53
|
+
* sessions (managed drivers) do instead.
|
|
54
|
+
*/
|
|
55
|
+
newCommandTimeoutMs = 0;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* List of active plugins
|
|
59
|
+
* @type {PluginClass[]}
|
|
60
|
+
*/
|
|
61
|
+
pluginClasses = [];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* map of sessions to actual plugin instances per session
|
|
65
|
+
* @type {Record<string,InstanceType<PluginClass>[]>}
|
|
66
|
+
*/
|
|
67
|
+
sessionPlugins = {};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* some commands are sessionless, so we need a set of plugins for them
|
|
71
|
+
* @type {InstanceType<PluginClass>[]}
|
|
72
|
+
*/
|
|
73
|
+
sessionlessPlugins = [];;
|
|
74
|
+
|
|
75
|
+
/** @type {DriverConfig} */
|
|
76
|
+
driverConfig;
|
|
77
|
+
|
|
78
|
+
/** @type {AppiumServer} */
|
|
79
|
+
server;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @param {DriverOpts} opts
|
|
83
|
+
*/
|
|
84
|
+
constructor (opts) {
|
|
27
85
|
// It is necessary to set `--tmp` here since it should be set to
|
|
28
86
|
// process.env.APPIUM_TMP_DIR once at an initial point in the Appium lifecycle.
|
|
29
87
|
// The process argument will be referenced by BaseDriver.
|
|
30
88
|
// Please call @appium/support.tempDir module to apply this benefit.
|
|
31
|
-
if (
|
|
32
|
-
process.env.APPIUM_TMP_DIR =
|
|
89
|
+
if (opts.tmpDir) {
|
|
90
|
+
process.env.APPIUM_TMP_DIR = opts.tmpDir;
|
|
33
91
|
}
|
|
34
92
|
|
|
35
|
-
super(
|
|
93
|
+
super(opts);
|
|
36
94
|
|
|
37
95
|
this.desiredCapConstraints = desiredCapabilityConstraints;
|
|
38
96
|
|
|
39
|
-
|
|
40
|
-
this.newCommandTimeoutMs = 0;
|
|
41
|
-
|
|
42
|
-
this.args = {...args};
|
|
43
|
-
|
|
44
|
-
// Access to sessions list must be guarded with a Semaphore, because
|
|
45
|
-
// it might be changed by other async calls at any time
|
|
46
|
-
// It is not recommended to access this property directly from the outside
|
|
47
|
-
this.sessions = {};
|
|
48
|
-
|
|
49
|
-
// Access to pending drivers list must be guarded with a Semaphore, because
|
|
50
|
-
// it might be changed by other async calls at any time
|
|
51
|
-
// It is not recommended to access this property directly from the outside
|
|
52
|
-
this.pendingDrivers = {};
|
|
53
|
-
|
|
54
|
-
/** @type {PluginExtensionClass[]} */
|
|
55
|
-
this.pluginClasses = []; // list of which plugins are active
|
|
56
|
-
this.sessionPlugins = {}; // map of sessions to actual plugin instances per session
|
|
57
|
-
this.sessionlessPlugins = []; // some commands are sessionless, so we need a set of plugins for them
|
|
97
|
+
this.args = {...opts};
|
|
58
98
|
|
|
59
99
|
// allow this to happen in the background, so no `await`
|
|
60
|
-
|
|
100
|
+
// catch this to avoid an unhandled rejection
|
|
101
|
+
// eslint-disable-next-line promise/prefer-await-to-then,promise/prefer-await-to-callbacks
|
|
102
|
+
updateBuildInfo().catch((err) => {
|
|
103
|
+
this.log.debug(err);
|
|
104
|
+
});
|
|
61
105
|
}
|
|
62
106
|
|
|
63
107
|
/**
|
|
64
108
|
* Retrieves logger instance for the current umbrella driver instance
|
|
65
|
-
* @override
|
|
66
109
|
*/
|
|
67
110
|
get log () {
|
|
68
111
|
if (!this._log) {
|
|
69
|
-
const instanceName = `${this.constructor.name}@${node.getObjectId(this).substring(0,
|
|
112
|
+
const instanceName = `${this.constructor.name}@${node.getObjectId(this).substring(0, 4)}`;
|
|
70
113
|
this._log = logger.getLogger(instanceName);
|
|
71
114
|
}
|
|
72
115
|
return this._log;
|
|
73
116
|
}
|
|
74
117
|
|
|
75
|
-
/** @type {import('./extension/driver-config').DriverConfig|undefined} */
|
|
76
|
-
driverConfig;
|
|
77
|
-
|
|
78
|
-
/** @type {import('express').Express|undefined} */
|
|
79
|
-
server;
|
|
80
|
-
|
|
81
118
|
/**
|
|
82
119
|
* Cancel commands queueing for the umbrella Appium driver
|
|
83
120
|
*/
|
|
@@ -100,9 +137,8 @@ class AppiumDriver extends BaseDriver {
|
|
|
100
137
|
};
|
|
101
138
|
}
|
|
102
139
|
|
|
103
|
-
async getSessions () {
|
|
104
|
-
|
|
105
|
-
return _.toPairs(sessions)
|
|
140
|
+
async getSessions () { // eslint-disable-line require-await
|
|
141
|
+
return _.toPairs(this.sessions)
|
|
106
142
|
.map(([id, driver]) => ({id, capabilities: driver.caps}));
|
|
107
143
|
}
|
|
108
144
|
|
|
@@ -128,12 +164,12 @@ class AppiumDriver extends BaseDriver {
|
|
|
128
164
|
* If the extension has provided a schema, validation has already happened.
|
|
129
165
|
*
|
|
130
166
|
* Any arg which is equal to its default value will not be assigned to the extension.
|
|
131
|
-
* @param {
|
|
167
|
+
* @param {ExtensionType} extType 'driver' or 'plugin'
|
|
132
168
|
* @param {string} extName the name of the extension
|
|
133
169
|
* @param {Object} extInstance the driver or plugin instance
|
|
134
170
|
*/
|
|
135
171
|
assignCliArgsToExtension (extType, extName, extInstance) {
|
|
136
|
-
const allCliArgsForExt = this.args[extType]?.[extName];
|
|
172
|
+
const allCliArgsForExt = /** @type {Record<string,unknown>|undefined} */(this.args[extType]?.[extName]);
|
|
137
173
|
if (!_.isEmpty(allCliArgsForExt)) {
|
|
138
174
|
const defaults = getDefaultsForExtension(extType, extName);
|
|
139
175
|
const cliArgs = _.isEmpty(defaults)
|
|
@@ -147,24 +183,26 @@ class AppiumDriver extends BaseDriver {
|
|
|
147
183
|
|
|
148
184
|
/**
|
|
149
185
|
* Create a new session
|
|
150
|
-
* @param {
|
|
151
|
-
* @param {
|
|
152
|
-
* @param {
|
|
153
|
-
* @
|
|
186
|
+
* @param {W3CCapabilities} jsonwpCaps JSONWP formatted desired capabilities
|
|
187
|
+
* @param {W3CCapabilities} reqCaps Required capabilities (JSONWP standard)
|
|
188
|
+
* @param {W3CCapabilities} w3cCapabilities W3C capabilities
|
|
189
|
+
* @param {import('@appium/types').DriverData[]} [driverData]
|
|
154
190
|
*/
|
|
155
|
-
async createSession (jsonwpCaps, reqCaps, w3cCapabilities) {
|
|
191
|
+
async createSession (jsonwpCaps, reqCaps, w3cCapabilities, driverData) {
|
|
156
192
|
const defaultCapabilities = _.cloneDeep(this.args.defaultCapabilities);
|
|
157
193
|
const defaultSettings = pullSettings(defaultCapabilities);
|
|
158
194
|
jsonwpCaps = _.cloneDeep(jsonwpCaps);
|
|
159
|
-
const jwpSettings =
|
|
195
|
+
const jwpSettings = {...defaultSettings, ...pullSettings(jsonwpCaps)};
|
|
160
196
|
w3cCapabilities = _.cloneDeep(w3cCapabilities);
|
|
161
197
|
// It is possible that the client only provides caps using JSONWP standard,
|
|
162
198
|
// although firstMatch/alwaysMatch properties are still present.
|
|
163
199
|
// In such case we assume the client understands W3C protocol and merge the given
|
|
164
200
|
// JSONWP caps to W3C caps
|
|
165
|
-
const w3cSettings =
|
|
166
|
-
|
|
167
|
-
|
|
201
|
+
const w3cSettings = {
|
|
202
|
+
...jwpSettings,
|
|
203
|
+
...pullSettings((w3cCapabilities ?? {}).alwaysMatch ?? {})
|
|
204
|
+
};
|
|
205
|
+
for (const firstMatchEntry of ((w3cCapabilities ?? {}).firstMatch ?? [])) {
|
|
168
206
|
Object.assign(w3cSettings, pullSettings(firstMatchEntry));
|
|
169
207
|
}
|
|
170
208
|
|
|
@@ -179,9 +217,9 @@ class AppiumDriver extends BaseDriver {
|
|
|
179
217
|
defaultCapabilities
|
|
180
218
|
);
|
|
181
219
|
|
|
182
|
-
const {desiredCaps, processedJsonwpCapabilities, processedW3CCapabilities
|
|
220
|
+
const {desiredCaps, processedJsonwpCapabilities, processedW3CCapabilities} = /** @type {import('./utils').ParsedDriverCaps} */(parsedCaps);
|
|
183
221
|
protocol = parsedCaps.protocol;
|
|
184
|
-
|
|
222
|
+
const error = /** @type {import('./utils').InvalidCaps} */(parsedCaps).error;
|
|
185
223
|
// If the parsing of the caps produced an error, throw it in here
|
|
186
224
|
if (error) {
|
|
187
225
|
throw error;
|
|
@@ -198,7 +236,14 @@ class AppiumDriver extends BaseDriver {
|
|
|
198
236
|
await this.deleteAllSessions();
|
|
199
237
|
}
|
|
200
238
|
|
|
201
|
-
|
|
239
|
+
/**
|
|
240
|
+
* @type {DriverData[]}
|
|
241
|
+
*/
|
|
242
|
+
let runningDriversData = [];
|
|
243
|
+
/**
|
|
244
|
+
* @type {DriverData[]}
|
|
245
|
+
*/
|
|
246
|
+
let otherPendingDriversData = [];
|
|
202
247
|
|
|
203
248
|
const driverInstance = new InnerDriver(this.args, true);
|
|
204
249
|
|
|
@@ -231,21 +276,17 @@ class AppiumDriver extends BaseDriver {
|
|
|
231
276
|
|
|
232
277
|
|
|
233
278
|
// This assignment is required for correct web sockets functionality inside the driver
|
|
234
|
-
driverInstance.server = this.server;
|
|
235
|
-
|
|
236
279
|
// Drivers/plugins might also want to know where they are hosted
|
|
237
|
-
driverInstance.
|
|
238
|
-
driverInstance.serverPort = this.args.port;
|
|
239
|
-
driverInstance.serverPath = this.args.basePath;
|
|
280
|
+
driverInstance.assignServer(this.server, this.args.address, this.args.port, this.args.basePath);
|
|
240
281
|
|
|
241
282
|
try {
|
|
242
|
-
runningDriversData = await this.curSessionDataForDriver(InnerDriver);
|
|
283
|
+
runningDriversData = await this.curSessionDataForDriver(InnerDriver) ?? [];
|
|
243
284
|
} catch (e) {
|
|
244
285
|
throw new errors.SessionNotCreatedError(e.message);
|
|
245
286
|
}
|
|
246
287
|
await pendingDriversGuard.acquire(AppiumDriver.name, () => {
|
|
247
288
|
this.pendingDrivers[InnerDriver.name] = this.pendingDrivers[InnerDriver.name] || [];
|
|
248
|
-
otherPendingDriversData = this.pendingDrivers[InnerDriver.name].map((drv) => drv.driverData);
|
|
289
|
+
otherPendingDriversData = _.compact(this.pendingDrivers[InnerDriver.name].map((drv) => drv.driverData));
|
|
249
290
|
this.pendingDrivers[InnerDriver.name].push(driverInstance);
|
|
250
291
|
});
|
|
251
292
|
|
|
@@ -257,9 +298,7 @@ class AppiumDriver extends BaseDriver {
|
|
|
257
298
|
[...runningDriversData, ...otherPendingDriversData]
|
|
258
299
|
);
|
|
259
300
|
protocol = driverInstance.protocol;
|
|
260
|
-
|
|
261
|
-
this.sessions[innerSessionId] = driverInstance;
|
|
262
|
-
});
|
|
301
|
+
this.sessions[innerSessionId] = driverInstance;
|
|
263
302
|
} finally {
|
|
264
303
|
await pendingDriversGuard.acquire(AppiumDriver.name, () => {
|
|
265
304
|
_.pull(this.pendingDrivers[InnerDriver.name], driverInstance);
|
|
@@ -329,27 +368,32 @@ class AppiumDriver extends BaseDriver {
|
|
|
329
368
|
}
|
|
330
369
|
}
|
|
331
370
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
371
|
+
/**
|
|
372
|
+
*
|
|
373
|
+
* @param {import('../types/extension').DriverClass} InnerDriver
|
|
374
|
+
* @returns {Promise<DriverData[]>}}
|
|
375
|
+
*/
|
|
376
|
+
async curSessionDataForDriver (InnerDriver) { // eslint-disable-line require-await
|
|
377
|
+
const data = _.compact(_.values(this.sessions)
|
|
378
|
+
.filter((s) => s.constructor.name === InnerDriver.name)
|
|
379
|
+
.map((s) => s.driverData));
|
|
380
|
+
for (const datum of data) {
|
|
338
381
|
if (!datum) {
|
|
339
382
|
throw new Error(`Problem getting session data for driver type ` +
|
|
340
|
-
|
|
341
|
-
`driverData'?`);
|
|
383
|
+
`${InnerDriver.name}; does it implement 'get driverData'?`);
|
|
342
384
|
}
|
|
343
385
|
}
|
|
344
386
|
return data;
|
|
345
387
|
}
|
|
346
388
|
|
|
389
|
+
/**
|
|
390
|
+
* @param {string} sessionId
|
|
391
|
+
*/
|
|
347
392
|
async deleteSession (sessionId) {
|
|
348
393
|
let protocol;
|
|
349
394
|
try {
|
|
350
|
-
let otherSessionsData
|
|
351
|
-
|
|
352
|
-
await sessionsListGuard.acquire(AppiumDriver.name, () => {
|
|
395
|
+
let otherSessionsData;
|
|
396
|
+
const dstSession = await sessionsListGuard.acquire(AppiumDriver.name, () => {
|
|
353
397
|
if (!this.sessions[sessionId]) {
|
|
354
398
|
return;
|
|
355
399
|
}
|
|
@@ -357,7 +401,7 @@ class AppiumDriver extends BaseDriver {
|
|
|
357
401
|
otherSessionsData = _.toPairs(this.sessions)
|
|
358
402
|
.filter(([key, value]) => value.constructor.name === curConstructorName && key !== sessionId)
|
|
359
403
|
.map(([, value]) => value.driverData);
|
|
360
|
-
dstSession = this.sessions[sessionId];
|
|
404
|
+
const dstSession = this.sessions[sessionId];
|
|
361
405
|
protocol = dstSession.protocol;
|
|
362
406
|
this.log.info(`Removing session ${sessionId} from our master session list`);
|
|
363
407
|
// regardless of whether the deleteSession completes successfully or not
|
|
@@ -365,7 +409,13 @@ class AppiumDriver extends BaseDriver {
|
|
|
365
409
|
// be in otherwise
|
|
366
410
|
delete this.sessions[sessionId];
|
|
367
411
|
delete this.sessionPlugins[sessionId];
|
|
412
|
+
return dstSession;
|
|
368
413
|
});
|
|
414
|
+
// this may not be correct, but if `dstSession` was falsy, the call to `deleteSession()` would
|
|
415
|
+
// throw anyway.
|
|
416
|
+
if (!dstSession) {
|
|
417
|
+
throw new Error('Session not found');
|
|
418
|
+
}
|
|
369
419
|
return {
|
|
370
420
|
protocol,
|
|
371
421
|
value: await dstSession.deleteSession(sessionId, otherSessionsData),
|
|
@@ -449,6 +499,12 @@ class AppiumDriver extends BaseDriver {
|
|
|
449
499
|
});
|
|
450
500
|
}
|
|
451
501
|
|
|
502
|
+
/**
|
|
503
|
+
*
|
|
504
|
+
* @param {string} cmd
|
|
505
|
+
* @param {...any} args
|
|
506
|
+
* @returns {Promise<{value: any, error?: Error, protocol: string} | import('type-fest').AsyncReturnType<import('@appium/types').Driver['executeCommand']>>}
|
|
507
|
+
*/
|
|
452
508
|
async executeCommand (cmd, ...args) {
|
|
453
509
|
// We have basically three cases for how to handle commands:
|
|
454
510
|
// 1. handle getStatus (we do this as a special out of band case so it doesn't get added to an
|
|
@@ -460,9 +516,8 @@ class AppiumDriver extends BaseDriver {
|
|
|
460
516
|
// cases with plugin handling.
|
|
461
517
|
|
|
462
518
|
const isGetStatus = cmd === GET_STATUS_COMMAND;
|
|
463
|
-
const
|
|
464
|
-
const
|
|
465
|
-
const isSessionCmd = !isUmbrellaCmd || isDeleteSession;
|
|
519
|
+
const isUmbrellaCmd = isAppiumDriverCommand(cmd);
|
|
520
|
+
const isSessionCmd = isSessionCommand(cmd);
|
|
466
521
|
|
|
467
522
|
// if a plugin override proxying for this command and that is why we are here instead of just
|
|
468
523
|
// letting the protocol proxy the command entirely, determine that, get the request object for
|
|
@@ -478,10 +533,11 @@ class AppiumDriver extends BaseDriver {
|
|
|
478
533
|
let sessionId = null;
|
|
479
534
|
let dstSession = null;
|
|
480
535
|
let protocol = null;
|
|
536
|
+
/** @type {this | ExternalDriver} */
|
|
481
537
|
let driver = this;
|
|
482
538
|
if (isSessionCmd) {
|
|
483
539
|
sessionId = _.last(args);
|
|
484
|
-
dstSession =
|
|
540
|
+
dstSession = this.sessions[sessionId];
|
|
485
541
|
if (!dstSession) {
|
|
486
542
|
throw new Error(`The session with id '${sessionId}' does not exist`);
|
|
487
543
|
}
|
|
@@ -535,7 +591,7 @@ class AppiumDriver extends BaseDriver {
|
|
|
535
591
|
if (isUmbrellaCmd) {
|
|
536
592
|
// some commands, like deleteSession, we want to make sure to handle on *this* driver,
|
|
537
593
|
// not the platform driver
|
|
538
|
-
return await
|
|
594
|
+
return await BaseDriver.prototype.executeCommand.call(this, cmd, ...args);
|
|
539
595
|
}
|
|
540
596
|
|
|
541
597
|
// here we know that we are executing a session command, and have a valid session driver
|
|
@@ -654,7 +710,7 @@ class AppiumDriver extends BaseDriver {
|
|
|
654
710
|
// help decide which commands should be proxied to sub-drivers and which
|
|
655
711
|
// should be handled by this, our umbrella driver
|
|
656
712
|
function isAppiumDriverCommand (cmd) {
|
|
657
|
-
return !isSessionCommand(cmd) || cmd ===
|
|
713
|
+
return !isSessionCommand(cmd) || cmd === DELETE_SESSION_COMMAND;
|
|
658
714
|
}
|
|
659
715
|
|
|
660
716
|
/**
|
|
@@ -676,3 +732,29 @@ export class NoDriverProxyCommandError extends Error {
|
|
|
676
732
|
}
|
|
677
733
|
|
|
678
734
|
export { AppiumDriver };
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* @typedef {import('@appium/types').ExternalDriver} ExternalDriver
|
|
738
|
+
* @typedef {import('@appium/types').W3CCapabilities} W3CCapabilities
|
|
739
|
+
* @typedef {import('@appium/types').DriverData} DriverData
|
|
740
|
+
* @typedef {import('@appium/types').DriverOpts} DriverOpts
|
|
741
|
+
* @typedef {import('@appium/types').Constraints} Constraints
|
|
742
|
+
* @typedef {import('@appium/types').AppiumServer} AppiumServer
|
|
743
|
+
* @typedef {import('../types').ExtensionType} ExtensionType
|
|
744
|
+
* @typedef {import('../types/extension').PluginClass} PluginClass
|
|
745
|
+
* @typedef {import('./extension/driver-config').DriverConfig} DriverConfig
|
|
746
|
+
*/
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Used by {@linkcode AppiumDriver.createSession} and {@linkcode AppiumDriver.deleteSession} to describe
|
|
750
|
+
* result.
|
|
751
|
+
* @template V
|
|
752
|
+
* @typedef SessionHandlerResult
|
|
753
|
+
* @property {V} [value]
|
|
754
|
+
* @property {Error} [error]
|
|
755
|
+
* @property {string} [protocol]
|
|
756
|
+
*/
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* @typedef {import('@appium/types').SessionHandler<SessionHandlerResult<any[]>,SessionHandlerResult<void>>} SessionHandler
|
|
760
|
+
*/
|
package/lib/cli/args.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
|
|
3
2
|
// @ts-ignore
|
|
4
3
|
import _ from 'lodash';
|
|
@@ -43,7 +42,7 @@ const getExtensionArgs = _.memoize(function getExtensionArgs () {
|
|
|
43
42
|
[EXT_SUBCOMMAND_RUN]: makeRunArgs(type),
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
|
-
return /** @type {Record<ExtensionType, Record<import('../../types/
|
|
45
|
+
return /** @type {Record<ExtensionType, Record<import('../../types/cli').CliExtensionSubcommand,ArgumentDefinitions>>} */(extensionArgs);
|
|
47
46
|
});
|
|
48
47
|
|
|
49
48
|
/**
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import ExtensionCommand from './extension-command';
|
|
3
|
-
import {
|
|
3
|
+
import { KNOWN_DRIVERS } from '../constants';
|
|
4
|
+
import '@colors/colors';
|
|
4
5
|
|
|
5
6
|
const REQ_DRIVER_FIELDS = ['driverName', 'automationName', 'platformNames', 'mainClass'];
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @extends {ExtensionCommand<import('../extension/manifest').DriverType>}
|
|
9
|
+
*/
|
|
7
10
|
export default class DriverCommand extends ExtensionCommand {
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* @param {DriverCommandOptions} opts
|
|
11
14
|
*/
|
|
12
15
|
constructor ({config, json}) {
|
|
13
|
-
super({config, json
|
|
16
|
+
super({config, json});
|
|
14
17
|
this.knownExtensions = KNOWN_DRIVERS;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
async install ({driver, installType, packageName}) {
|
|
18
|
-
return await super.
|
|
21
|
+
return await super._install({ext: driver, installType, packageName});
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
async uninstall ({driver}) {
|
|
22
|
-
return await super.
|
|
25
|
+
return await super._uninstall({ext: driver});
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
async update ({driver, unsafe}) {
|
|
26
|
-
return await super.
|
|
29
|
+
return await super._update({ext: driver, unsafe});
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
async run ({driver, scriptName}) {
|
|
30
|
-
return await super.
|
|
33
|
+
return await super._run({ext: driver, scriptName});
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
getPostInstallText ({extName, extData}) {
|
|
@@ -52,6 +55,6 @@ export default class DriverCommand extends ExtensionCommand {
|
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
57
|
* @typedef DriverCommandOptions
|
|
55
|
-
* @property {import('../extension/
|
|
58
|
+
* @property {import('../extension/extension-config').ExtensionConfig<import('../extension/manifest').DriverType>} config
|
|
56
59
|
* @property {boolean} json
|
|
57
60
|
*/
|