@appium/base-driver 8.2.2 → 8.3.0
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.js +3 -1
- package/build/lib/basedriver/commands/find.js +4 -11
- package/build/lib/basedriver/commands/log.js +3 -6
- package/build/lib/basedriver/commands/session.js +18 -27
- package/build/lib/basedriver/commands/settings.js +4 -8
- package/build/lib/basedriver/commands/timeout.js +10 -15
- package/build/lib/basedriver/device-settings.js +14 -2
- package/build/lib/basedriver/driver.js +25 -23
- package/build/lib/basedriver/helpers.js +140 -84
- package/build/lib/express/express-logging.js +2 -2
- package/build/lib/express/idempotency.js +2 -2
- package/build/lib/helpers/capabilities.js +39 -0
- package/build/lib/index.js +7 -7
- package/build/lib/jsonwp-proxy/protocol-converter.js +19 -16
- package/build/lib/jsonwp-proxy/proxy.js +20 -16
- package/build/lib/protocol/errors.js +4 -2
- package/build/lib/protocol/helpers.js +3 -20
- package/build/lib/protocol/protocol.js +44 -45
- package/build/lib/protocol/routes.js +67 -1
- package/build/test/basedriver/capabilities-specs.js +43 -1
- package/build/test/basedriver/capability-specs.js +126 -167
- package/build/test/basedriver/commands/log-specs.js +12 -5
- package/build/test/basedriver/driver-tests.js +11 -14
- package/build/test/basedriver/helpers-specs.js +5 -1
- package/build/test/basedriver/timeout-specs.js +7 -9
- package/build/test/express/server-e2e-specs.js +10 -5
- package/build/test/express/server-specs.js +22 -16
- package/build/test/express/static-specs.js +10 -5
- package/build/test/jsonwp-proxy/proxy-e2e-specs.js +1 -2
- package/build/test/jsonwp-proxy/proxy-specs.js +1 -6
- package/build/test/protocol/fake-driver.js +12 -15
- package/build/test/protocol/protocol-e2e-specs.js +49 -103
- package/build/test/protocol/routes-specs.js +2 -2
- package/lib/basedriver/capabilities.js +3 -0
- package/lib/basedriver/commands/find.js +3 -6
- package/lib/basedriver/commands/log.js +2 -4
- package/lib/basedriver/commands/session.js +21 -22
- package/lib/basedriver/commands/settings.js +3 -5
- package/lib/basedriver/commands/timeout.js +9 -10
- package/lib/basedriver/device-settings.js +10 -1
- package/lib/basedriver/driver.js +29 -16
- package/lib/basedriver/helpers.js +201 -83
- package/lib/express/express-logging.js +1 -1
- package/lib/express/idempotency.js +1 -1
- package/lib/helpers/capabilities.js +25 -0
- package/lib/index.js +6 -4
- package/lib/jsonwp-proxy/protocol-converter.js +15 -18
- package/lib/jsonwp-proxy/proxy.js +17 -15
- package/lib/protocol/errors.js +1 -1
- package/lib/protocol/helpers.js +5 -25
- package/lib/protocol/protocol.js +43 -54
- package/lib/protocol/routes.js +60 -1
- package/package.json +29 -22
- package/test/basedriver/capabilities-specs.js +34 -2
- package/test/basedriver/capability-specs.js +120 -146
- package/test/basedriver/commands/log-specs.js +12 -3
- package/test/basedriver/driver-tests.js +12 -7
- package/test/basedriver/helpers-specs.js +4 -0
- package/test/basedriver/timeout-specs.js +6 -11
- package/build/lib/protocol/sessions-cache.js +0 -88
- package/lib/protocol/sessions-cache.js +0 -74
|
@@ -45,7 +45,7 @@ describe('Protocol', function () {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
let hash = shasum.digest('hex').substring(0, 8);
|
|
48
|
-
hash.should.equal('
|
|
48
|
+
hash.should.equal('262ca3c4');
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
describe('check route to command name conversion', function () {
|
|
@@ -79,4 +79,4 @@ describe('Protocol', function () {
|
|
|
79
79
|
});require('source-map-support').install();
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
//# sourceMappingURL=data:application/json;charset=utf8;base64,
|
|
82
|
+
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QvcHJvdG9jb2wvcm91dGVzLXNwZWNzLmpzIl0sIm5hbWVzIjpbImRlc2NyaWJlIiwiaXQiLCJzaGFzdW0iLCJjcnlwdG8iLCJjcmVhdGVIYXNoIiwidXJsIiwidXJsTWFwcGlu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TVCddXSkge1xuICAgICAgICBjb25zdCBjbWROYW1lID0gcm91dGVUb0NvbW1hbmROYW1lKHJvdXRlLCBtZXRob2QpO1xuICAgICAgICBjaGFpLnNob3VsZCgpLmVxdWFsKGNtZE5hbWUsIHVuZGVmaW5lZCk7XG4gICAgICB9XG4gICAgfSk7XG4gIH0pO1xuXG59KTtcbiJdLCJmaWxlIjoidGVzdC9wcm90b2NvbC9yb3V0ZXMtc3BlY3MuanMiLCJzb3VyY2VSb290IjoiLi4vLi4vLi4ifQ==
|
|
@@ -145,7 +145,10 @@ function parseCaps (caps, constraints = {}, shouldValidateCaps = true) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// If an empty array as provided, we'll be forgiving and make it an array of one empty object
|
|
148
|
+
// In the future, reject 'firstMatch' argument if its array did not have one or more entries (#3.2)
|
|
148
149
|
if (allFirstMatchCaps.length === 0) {
|
|
150
|
+
log.warn(`The firstMatch array in the given capabilities has no entries. Adding an empty entry fo rnow, ` +
|
|
151
|
+
`but it will require one or more entries as W3C spec.`);
|
|
149
152
|
allFirstMatchCaps.push({});
|
|
150
153
|
}
|
|
151
154
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import log from '../logger';
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
const commands = {}, helpers = {}, extensions = {};
|
|
5
2
|
|
|
6
3
|
|
|
@@ -23,9 +20,9 @@ helpers.findElOrElsWithProcessing = async function findElOrElsWithProcessing (st
|
|
|
23
20
|
} catch (err) {
|
|
24
21
|
if (this.opts.printPageSourceOnFindFailure) {
|
|
25
22
|
const src = await this.getPageSource();
|
|
26
|
-
log.debug(`Error finding element${mult ? 's' : ''}: ${err.message}`);
|
|
27
|
-
log.debug(`Page source requested through 'printPageSourceOnFindFailure':`);
|
|
28
|
-
log.debug(src);
|
|
23
|
+
this.log.debug(`Error finding element${mult ? 's' : ''}: ${err.message}`);
|
|
24
|
+
this.log.debug(`Page source requested through 'printPageSourceOnFindFailure':`);
|
|
25
|
+
this.log.debug(src);
|
|
29
26
|
}
|
|
30
27
|
// still want the error to occur
|
|
31
28
|
throw err;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import log from '../logger';
|
|
2
1
|
import _ from 'lodash';
|
|
3
2
|
|
|
4
|
-
|
|
5
3
|
const commands = {}, helpers = {}, extensions = {};
|
|
6
4
|
|
|
7
5
|
// override in sub-classes, with appropriate logs
|
|
@@ -16,12 +14,12 @@ extensions.supportedLogTypes = {};
|
|
|
16
14
|
|
|
17
15
|
// eslint-disable-next-line require-await
|
|
18
16
|
commands.getLogTypes = async function getLogTypes () {
|
|
19
|
-
log.debug('Retrieving supported log types');
|
|
17
|
+
this.log.debug('Retrieving supported log types');
|
|
20
18
|
return _.keys(this.supportedLogTypes);
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
commands.getLog = async function getLog (logType) {
|
|
24
|
-
log.debug(`Retrieving '${logType}' logs`);
|
|
22
|
+
this.log.debug(`Retrieving '${logType}' logs`);
|
|
25
23
|
|
|
26
24
|
if (!(await this.getLogTypes()).includes(logType)) {
|
|
27
25
|
const logsTypesWithDescriptions = _.reduce(this.supportedLogTypes, (acc, value, key) => {
|
|
@@ -1,45 +1,44 @@
|
|
|
1
1
|
/* eslint-disable require-await */
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
-
import log from '../logger';
|
|
4
3
|
import { errors } from '../../protocol';
|
|
5
4
|
import { util } from '@appium/support';
|
|
6
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
processCapabilities, promoteAppiumOptions, APPIUM_OPTS_CAP, PREFIXED_APPIUM_OPTS_CAP,
|
|
7
|
+
} from '../capabilities';
|
|
8
|
+
import { isW3cCaps } from '../../helpers/capabilities';
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
const commands = {};
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
// since Appium 2.0 no longer supports them.
|
|
12
|
-
commands.createSession = async function createSession (jsonwpDesiredCapabilities, jsonwpRequiredCaps, w3cCapabilities) {
|
|
12
|
+
commands.createSession = async function createSession (w3cCapabilities1, w3cCapabilities2, w3cCapabilities) {
|
|
13
13
|
if (this.sessionId !== null) {
|
|
14
|
-
throw new errors.SessionNotCreatedError('Cannot create a new session '
|
|
15
|
-
'while one is in progress');
|
|
14
|
+
throw new errors.SessionNotCreatedError('Cannot create a new session while one is in progress');
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
log.debug();
|
|
17
|
+
this.log.debug();
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
// Historically the first two arguments were reserved for JSONWP capabilities.
|
|
20
|
+
// Appium 2 has dropped the support of these, so now we only accept capability
|
|
21
|
+
// objects in W3C format and thus allow any of the three arguments to represent
|
|
22
|
+
// the latter.
|
|
23
|
+
const originalCaps = [w3cCapabilities, w3cCapabilities1, w3cCapabilities2].find(isW3cCaps);
|
|
24
|
+
if (!originalCaps) {
|
|
21
25
|
throw new errors.SessionNotCreatedError('Appium only supports W3C-style capability objects. ' +
|
|
22
26
|
'Your client is sending an older capabilities format. Please update your client library.');
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
if (jsonwpDesiredCapabilities) {
|
|
26
|
-
log.warn('Appium received (M)JSONWP desired capabilities in alongside the W3C capabilities; they will be ignored');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
29
|
this.setProtocolW3C();
|
|
30
30
|
|
|
31
|
-
this.originalCaps = _.cloneDeep(
|
|
32
|
-
log.debug(`Creating session with W3C capabilities: ${JSON.stringify(
|
|
33
|
-
|
|
31
|
+
this.originalCaps = _.cloneDeep(originalCaps);
|
|
32
|
+
this.log.debug(`Creating session with W3C capabilities: ${JSON.stringify(originalCaps, null, 2)}`);
|
|
34
33
|
|
|
35
34
|
let caps;
|
|
36
35
|
try {
|
|
37
|
-
caps = processCapabilities(
|
|
36
|
+
caps = processCapabilities(originalCaps, this.desiredCapConstraints, this.shouldValidateCaps);
|
|
38
37
|
if (caps[APPIUM_OPTS_CAP]) {
|
|
39
|
-
log.debug(`Found ${PREFIXED_APPIUM_OPTS_CAP} capability present; will promote items inside to caps`);
|
|
38
|
+
this.log.debug(`Found ${PREFIXED_APPIUM_OPTS_CAP} capability present; will promote items inside to caps`);
|
|
40
39
|
caps = promoteAppiumOptions(caps);
|
|
41
40
|
}
|
|
42
|
-
caps = fixCaps(caps, this.desiredCapConstraints);
|
|
41
|
+
caps = fixCaps(caps, this.desiredCapConstraints, this.log);
|
|
43
42
|
} catch (e) {
|
|
44
43
|
throw new errors.SessionNotCreatedError(e.message);
|
|
45
44
|
}
|
|
@@ -79,7 +78,7 @@ commands.createSession = async function createSession (jsonwpDesiredCapabilities
|
|
|
79
78
|
this.newCommandTimeoutMs = (this.caps.newCommandTimeout * 1000);
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
log.info(`Session created with session id: ${this.sessionId}`);
|
|
81
|
+
this.log.info(`Session created with session id: ${this.sessionId}`);
|
|
83
82
|
|
|
84
83
|
return [this.sessionId, caps];
|
|
85
84
|
};
|
|
@@ -115,7 +114,7 @@ commands.deleteSession = async function deleteSession (/* sessionId */) {
|
|
|
115
114
|
this.sessionId = null;
|
|
116
115
|
};
|
|
117
116
|
|
|
118
|
-
function fixCaps (originalCaps, desiredCapConstraints = {}) {
|
|
117
|
+
function fixCaps (originalCaps, desiredCapConstraints = {}, log) {
|
|
119
118
|
let caps = _.clone(originalCaps);
|
|
120
119
|
|
|
121
120
|
// boolean capabilities can be passed in as strings 'false' and 'true'
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let commands = {};
|
|
1
|
+
const commands = {};
|
|
4
2
|
|
|
5
3
|
commands.updateSettings = async function updateSettings (newSettings) {
|
|
6
4
|
if (!this.settings) {
|
|
7
|
-
log.errorAndThrow('Cannot update settings; settings object not found');
|
|
5
|
+
this.log.errorAndThrow('Cannot update settings; settings object not found');
|
|
8
6
|
}
|
|
9
7
|
return await this.settings.update(newSettings);
|
|
10
8
|
};
|
|
11
9
|
|
|
12
10
|
commands.getSettings = async function getSettings () {
|
|
13
11
|
if (!this.settings) {
|
|
14
|
-
log.errorAndThrow('Cannot get settings; settings object not found');
|
|
12
|
+
this.log.errorAndThrow('Cannot get settings; settings object not found');
|
|
15
13
|
}
|
|
16
14
|
return await this.settings.getSettings();
|
|
17
15
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import log from '../logger';
|
|
2
1
|
import { waitForCondition } from 'asyncbox';
|
|
3
2
|
import _ from 'lodash';
|
|
4
3
|
import { util } from '@appium/support';
|
|
@@ -11,7 +10,7 @@ const MIN_TIMEOUT = 0;
|
|
|
11
10
|
|
|
12
11
|
commands.timeouts = async function timeouts (type, ms, script, pageLoad, implicit) {
|
|
13
12
|
if (util.hasValue(type) && util.hasValue(ms)) {
|
|
14
|
-
log.debug(`MJSONWP timeout arguments: ${JSON.stringify({type, ms})}}`);
|
|
13
|
+
this.log.debug(`MJSONWP timeout arguments: ${JSON.stringify({type, ms})}}`);
|
|
15
14
|
|
|
16
15
|
switch (type) {
|
|
17
16
|
case 'command':
|
|
@@ -32,7 +31,7 @@ commands.timeouts = async function timeouts (type, ms, script, pageLoad, implici
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
// Otherwise assume it is W3C protocol
|
|
35
|
-
log.debug(`W3C timeout argument: ${JSON.stringify({script, pageLoad, implicit})}}`);
|
|
34
|
+
this.log.debug(`W3C timeout argument: ${JSON.stringify({script, pageLoad, implicit})}}`);
|
|
36
35
|
if (util.hasValue(script)) {
|
|
37
36
|
await this.scriptTimeoutW3C(script);
|
|
38
37
|
}
|
|
@@ -66,9 +65,9 @@ commands.implicitWait = async function implicitWait (ms) {
|
|
|
66
65
|
|
|
67
66
|
helpers.setImplicitWait = function setImplicitWait (ms) { // eslint-disable-line require-await
|
|
68
67
|
this.implicitWaitMs = ms;
|
|
69
|
-
log.debug(`Set implicit wait to ${ms}ms`);
|
|
68
|
+
this.log.debug(`Set implicit wait to ${ms}ms`);
|
|
70
69
|
if (this.managedDrivers && this.managedDrivers.length) {
|
|
71
|
-
log.debug('Setting implicit wait on managed drivers');
|
|
70
|
+
this.log.debug('Setting implicit wait on managed drivers');
|
|
72
71
|
for (let driver of this.managedDrivers) {
|
|
73
72
|
if (_.isFunction(driver.setImplicitWait)) {
|
|
74
73
|
driver.setImplicitWait(ms);
|
|
@@ -106,9 +105,9 @@ commands.newCommandTimeout = async function newCommandTimeout (ms) { // eslint-d
|
|
|
106
105
|
|
|
107
106
|
helpers.setNewCommandTimeout = function setNewCommandTimeout (ms) {
|
|
108
107
|
this.newCommandTimeoutMs = ms;
|
|
109
|
-
log.debug(`Set new command timeout to ${ms}ms`);
|
|
108
|
+
this.log.debug(`Set new command timeout to ${ms}ms`);
|
|
110
109
|
if (this.managedDrivers && this.managedDrivers.length) {
|
|
111
|
-
log.debug('Setting new command timeout on managed drivers');
|
|
110
|
+
this.log.debug('Setting new command timeout on managed drivers');
|
|
112
111
|
for (let driver of this.managedDrivers) {
|
|
113
112
|
if (_.isFunction(driver.setNewCommandTimeout)) {
|
|
114
113
|
driver.setNewCommandTimeout(ms);
|
|
@@ -132,7 +131,7 @@ helpers.startNewCommandTimeout = function startNewCommandTimeout () {
|
|
|
132
131
|
if (!this.newCommandTimeoutMs) return; // eslint-disable-line curly
|
|
133
132
|
|
|
134
133
|
this.noCommandTimer = setTimeout(async () => {
|
|
135
|
-
log.warn(`Shutting down because we waited ` +
|
|
134
|
+
this.log.warn(`Shutting down because we waited ` +
|
|
136
135
|
`${this.newCommandTimeoutMs / 1000.0} seconds for a command`);
|
|
137
136
|
const errorMessage = `New Command Timeout of ` +
|
|
138
137
|
`${this.newCommandTimeoutMs / 1000.0} seconds ` +
|
|
@@ -143,7 +142,7 @@ helpers.startNewCommandTimeout = function startNewCommandTimeout () {
|
|
|
143
142
|
};
|
|
144
143
|
|
|
145
144
|
helpers.implicitWaitForCondition = async function implicitWaitForCondition (condFn) {
|
|
146
|
-
log.debug(`Waiting up to ${this.implicitWaitMs} ms for condition`);
|
|
145
|
+
this.log.debug(`Waiting up to ${this.implicitWaitMs} ms for condition`);
|
|
147
146
|
let wrappedCondFn = async (...args) => {
|
|
148
147
|
// reset command timeout
|
|
149
148
|
this.clearNewCommandTimeout();
|
|
@@ -151,7 +150,7 @@ helpers.implicitWaitForCondition = async function implicitWaitForCondition (cond
|
|
|
151
150
|
return await condFn(...args);
|
|
152
151
|
};
|
|
153
152
|
return await waitForCondition(wrappedCondFn, {
|
|
154
|
-
waitMs: this.implicitWaitMs, intervalMs: 500, logger: log
|
|
153
|
+
waitMs: this.implicitWaitMs, intervalMs: 500, logger: this.log
|
|
155
154
|
});
|
|
156
155
|
};
|
|
157
156
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import log from './logger';
|
|
3
|
+
import { node, util } from '@appium/support';
|
|
4
|
+
import { errors } from '../protocol/errors';
|
|
5
|
+
|
|
6
|
+
const MAX_SETTINGS_SIZE = 20 * 1024 * 1024; // 20 MB
|
|
3
7
|
|
|
4
8
|
class DeviceSettings {
|
|
5
9
|
|
|
@@ -11,9 +15,14 @@ class DeviceSettings {
|
|
|
11
15
|
// calls updateSettings from implementing driver every time a setting is changed.
|
|
12
16
|
async update (newSettings) {
|
|
13
17
|
if (!_.isPlainObject(newSettings)) {
|
|
14
|
-
throw new
|
|
18
|
+
throw new errors.InvalidArgumentError(`Settings update should be called with valid JSON. Got ` +
|
|
15
19
|
`${JSON.stringify(newSettings)} instead`);
|
|
16
20
|
}
|
|
21
|
+
if (node.getObjectSize({...this._settings, ...newSettings}) >= MAX_SETTINGS_SIZE) {
|
|
22
|
+
throw new errors.InvalidArgumentError(`New settings cannot be applied, because the overall ` +
|
|
23
|
+
`object size exceeds the allowed limit of ${util.toReadableSizeString(MAX_SETTINGS_SIZE)}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
17
26
|
for (const prop of _.keys(newSettings)) {
|
|
18
27
|
if (!_.isUndefined(this._settings[prop])) {
|
|
19
28
|
if (this._settings[prop] === newSettings[prop]) {
|
package/lib/basedriver/driver.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Protocol, errors, determineProtocol
|
|
2
|
+
Protocol, errors, determineProtocol, DELETE_SESSION_COMMAND,
|
|
3
3
|
} from '../protocol';
|
|
4
|
-
import { fs } from '@appium/support';
|
|
4
|
+
import { fs, logger, node } from '@appium/support';
|
|
5
5
|
import { PROTOCOLS, DEFAULT_BASE_PATH } from '../constants';
|
|
6
6
|
import os from 'os';
|
|
7
7
|
import commands from './commands';
|
|
8
8
|
import * as helpers from './helpers';
|
|
9
|
-
import log from './logger';
|
|
10
9
|
import DeviceSettings from './device-settings';
|
|
11
10
|
import { desiredCapabilityConstraints } from './desired-caps';
|
|
12
11
|
import { validateCaps } from './capabilities';
|
|
@@ -30,6 +29,7 @@ const EVENT_SESSION_QUIT_START = 'quitSessionRequested';
|
|
|
30
29
|
const EVENT_SESSION_QUIT_DONE = 'quitSessionFinished';
|
|
31
30
|
const ON_UNEXPECTED_SHUTDOWN_EVENT = 'onUnexpectedShutdown';
|
|
32
31
|
|
|
32
|
+
|
|
33
33
|
class BaseDriver extends Protocol {
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -48,6 +48,8 @@ class BaseDriver extends Protocol {
|
|
|
48
48
|
this.originalCaps = null; // To give the original capabilities to reset
|
|
49
49
|
this.helpers = helpers;
|
|
50
50
|
|
|
51
|
+
this._log = null;
|
|
52
|
+
|
|
51
53
|
// basePath is used for several purposes, for example in setting up
|
|
52
54
|
// proxying to other drivers, since we need to know what the base path
|
|
53
55
|
// of any incoming request might look like. We set it to the default
|
|
@@ -104,6 +106,17 @@ class BaseDriver extends Protocol {
|
|
|
104
106
|
this.protocol = null;
|
|
105
107
|
}
|
|
106
108
|
|
|
109
|
+
get log () {
|
|
110
|
+
if (!this._log) {
|
|
111
|
+
const instanceName = `${this.constructor.name}@${node.getObjectId(this).substring(0, 8)}`;
|
|
112
|
+
this._log = logger.getLogger(() =>
|
|
113
|
+
this.sessionId ? `${instanceName} (${this.sessionId.substring(0, 8)})` : instanceName
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return this._log;
|
|
118
|
+
}
|
|
119
|
+
|
|
107
120
|
/**
|
|
108
121
|
* Set a callback handler if needed to execute a custom piece of code
|
|
109
122
|
* when the driver is shut down unexpectedly. Multiple calls to this method
|
|
@@ -168,7 +181,7 @@ class BaseDriver extends Protocol {
|
|
|
168
181
|
const ts = Date.now();
|
|
169
182
|
const logTime = (new Date(ts)).toTimeString();
|
|
170
183
|
this._eventHistory[eventName].push(ts);
|
|
171
|
-
log.debug(`Event '${eventName}' logged at ${ts} (${logTime})`);
|
|
184
|
+
this.log.debug(`Event '${eventName}' logged at ${ts} (${logTime})`);
|
|
172
185
|
}
|
|
173
186
|
|
|
174
187
|
/*
|
|
@@ -214,10 +227,10 @@ class BaseDriver extends Protocol {
|
|
|
214
227
|
let extraCaps = _.difference(_.keys(caps),
|
|
215
228
|
_.keys(this._constraints));
|
|
216
229
|
if (extraCaps.length) {
|
|
217
|
-
log.warn(`The following capabilities were provided, but are not ` +
|
|
230
|
+
this.log.warn(`The following capabilities were provided, but are not ` +
|
|
218
231
|
`recognized by Appium:`);
|
|
219
232
|
for (const cap of extraCaps) {
|
|
220
|
-
log.warn(` ${cap}`);
|
|
233
|
+
this.log.warn(` ${cap}`);
|
|
221
234
|
}
|
|
222
235
|
}
|
|
223
236
|
}
|
|
@@ -230,8 +243,8 @@ class BaseDriver extends Protocol {
|
|
|
230
243
|
try {
|
|
231
244
|
validateCaps(caps, this._constraints);
|
|
232
245
|
} catch (e) {
|
|
233
|
-
log.errorAndThrow(new errors.SessionNotCreatedError(`The desiredCapabilities object was not valid for the ` +
|
|
234
|
-
|
|
246
|
+
this.log.errorAndThrow(new errors.SessionNotCreatedError(`The desiredCapabilities object was not valid for the ` +
|
|
247
|
+
`following reason(s): ${e.message}`));
|
|
235
248
|
}
|
|
236
249
|
|
|
237
250
|
this.logExtraCaps(caps);
|
|
@@ -309,9 +322,9 @@ class BaseDriver extends Protocol {
|
|
|
309
322
|
|
|
310
323
|
if (cmd === 'createSession') {
|
|
311
324
|
// If creating a session determine if W3C or MJSONWP protocol was requested and remember the choice
|
|
312
|
-
this.protocol = determineProtocol(
|
|
325
|
+
this.protocol = determineProtocol(args);
|
|
313
326
|
this.logEvent(EVENT_SESSION_INIT);
|
|
314
|
-
} else if (cmd ===
|
|
327
|
+
} else if (cmd === DELETE_SESSION_COMMAND) {
|
|
315
328
|
this.logEvent(EVENT_SESSION_QUIT_START);
|
|
316
329
|
}
|
|
317
330
|
|
|
@@ -352,7 +365,7 @@ class BaseDriver extends Protocol {
|
|
|
352
365
|
// automatic session deletion in this.onCommandTimeout. Of course we don't
|
|
353
366
|
// want to trigger the timer when the user is shutting down the session
|
|
354
367
|
// intentionally
|
|
355
|
-
if (this.isCommandsQueueEnabled && cmd !==
|
|
368
|
+
if (this.isCommandsQueueEnabled && cmd !== DELETE_SESSION_COMMAND) {
|
|
356
369
|
// resetting existing timeout
|
|
357
370
|
this.startNewCommandTimeout();
|
|
358
371
|
}
|
|
@@ -362,7 +375,7 @@ class BaseDriver extends Protocol {
|
|
|
362
375
|
this._eventHistory.commands.push({cmd, startTime, endTime});
|
|
363
376
|
if (cmd === 'createSession') {
|
|
364
377
|
this.logEvent(EVENT_SESSION_START);
|
|
365
|
-
} else if (cmd ===
|
|
378
|
+
} else if (cmd === DELETE_SESSION_COMMAND) {
|
|
366
379
|
this.logEvent(EVENT_SESSION_QUIT_DONE);
|
|
367
380
|
}
|
|
368
381
|
|
|
@@ -381,7 +394,7 @@ class BaseDriver extends Protocol {
|
|
|
381
394
|
|
|
382
395
|
validateLocatorStrategy (strategy, webContext = false) {
|
|
383
396
|
let validStrategies = this.locatorStrategies;
|
|
384
|
-
log.debug(`Valid locator strategies for this request: ${validStrategies.join(', ')}`);
|
|
397
|
+
this.log.debug(`Valid locator strategies for this request: ${validStrategies.join(', ')}`);
|
|
385
398
|
|
|
386
399
|
if (webContext) {
|
|
387
400
|
validStrategies = validStrategies.concat(this.webLocatorStrategies);
|
|
@@ -397,8 +410,8 @@ class BaseDriver extends Protocol {
|
|
|
397
410
|
* preserving the timeout config.
|
|
398
411
|
*/
|
|
399
412
|
async reset () {
|
|
400
|
-
log.debug('Resetting app mid-session');
|
|
401
|
-
log.debug('Running generic full reset');
|
|
413
|
+
this.log.debug('Resetting app mid-session');
|
|
414
|
+
this.log.debug('Running generic full reset');
|
|
402
415
|
|
|
403
416
|
// preserving state
|
|
404
417
|
let currentConfig = {};
|
|
@@ -411,7 +424,7 @@ class BaseDriver extends Protocol {
|
|
|
411
424
|
|
|
412
425
|
try {
|
|
413
426
|
await this.deleteSession(this.sessionId);
|
|
414
|
-
log.debug('Restarting app');
|
|
427
|
+
this.log.debug('Restarting app');
|
|
415
428
|
await this.createSession(undefined, undefined, this.originalCaps);
|
|
416
429
|
} finally {
|
|
417
430
|
// always restore state.
|