@appium/base-driver 8.2.3 → 8.3.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.
- package/build/lib/basedriver/capabilities.js +2 -4
- package/build/lib/basedriver/commands/event.js +2 -4
- package/build/lib/basedriver/commands/find.js +5 -14
- package/build/lib/basedriver/commands/index.js +2 -4
- package/build/lib/basedriver/commands/log.js +4 -9
- package/build/lib/basedriver/commands/session.js +19 -30
- package/build/lib/basedriver/commands/settings.js +5 -11
- package/build/lib/basedriver/commands/timeout.js +11 -18
- package/build/lib/basedriver/desired-caps.js +2 -4
- package/build/lib/basedriver/device-settings.js +15 -5
- package/build/lib/basedriver/driver.js +36 -23
- package/build/lib/basedriver/helpers.js +10 -12
- package/build/lib/basedriver/logger.js +2 -4
- package/build/lib/constants.js +2 -4
- package/build/lib/express/crash.js +2 -4
- package/build/lib/express/express-logging.js +3 -5
- package/build/lib/express/idempotency.js +3 -5
- package/build/lib/express/logger.js +2 -4
- package/build/lib/express/middleware.js +2 -4
- package/build/lib/express/server.js +2 -4
- package/build/lib/express/static.js +2 -4
- package/build/lib/express/websocket.js +2 -4
- package/build/lib/helpers/capabilities.js +37 -0
- package/build/lib/index.js +4 -8
- package/build/lib/jsonwp-proxy/protocol-converter.js +19 -15
- package/build/lib/jsonwp-proxy/proxy.js +20 -15
- package/build/lib/jsonwp-status/status.js +2 -4
- package/build/lib/protocol/errors.js +2 -4
- package/build/lib/protocol/helpers.js +2 -4
- package/build/lib/protocol/index.js +2 -4
- package/build/lib/protocol/protocol.js +37 -30
- package/build/lib/protocol/routes.js +68 -4
- package/build/lib/protocol/validators.js +2 -4
- package/build/test/basedriver/README.md +5 -0
- package/build/test/basedriver/driver-e2e-tests.js +2 -4
- package/build/test/basedriver/driver-tests.js +12 -17
- package/build/test/basedriver/index.js +2 -4
- package/build/test/e2e/basedriver/driver.e2e.spec.js +15 -0
- package/build/test/e2e/basedriver/helpers.e2e.spec.js +192 -0
- package/build/test/e2e/basedriver/websockets.e2e.spec.js +82 -0
- package/build/test/e2e/express/server.e2e.spec.js +159 -0
- package/build/test/e2e/jsonwp-proxy/proxy.e2e.spec.js +59 -0
- package/build/test/e2e/protocol/fake-driver.js +163 -0
- package/build/test/e2e/protocol/helpers.js +25 -0
- package/build/test/e2e/protocol/protocol.e2e.spec.js +1186 -0
- package/build/test/helpers.js +2 -4
- package/build/test/unit/basedriver/capabilities.spec.js +672 -0
- package/build/test/unit/basedriver/capability.spec.js +353 -0
- package/build/test/unit/basedriver/commands/event.spec.js +110 -0
- package/build/test/unit/basedriver/commands/log.spec.js +85 -0
- package/build/test/unit/basedriver/driver.spec.js +15 -0
- package/build/test/unit/basedriver/helpers.spec.js +151 -0
- package/build/test/unit/basedriver/timeout.spec.js +135 -0
- package/build/test/unit/express/server.spec.js +155 -0
- package/build/test/unit/express/static.spec.js +26 -0
- package/build/test/unit/jsonwp-proxy/mock-request.js +91 -0
- package/build/test/unit/jsonwp-proxy/protocol-converter.spec.js +171 -0
- package/build/test/unit/jsonwp-proxy/proxy.spec.js +292 -0
- package/build/test/unit/jsonwp-proxy/url.spec.js +165 -0
- package/build/test/unit/jsonwp-status/status.spec.js +34 -0
- package/build/test/unit/protocol/errors.spec.js +390 -0
- package/build/test/unit/protocol/routes.spec.js +80 -0
- package/build/test/unit/protocol/validator.spec.js +149 -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 +36 -12
- package/lib/basedriver/helpers.js +13 -11
- 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 +2 -2
- package/lib/jsonwp-proxy/protocol-converter.js +14 -13
- package/lib/jsonwp-proxy/proxy.js +16 -12
- package/lib/protocol/protocol.js +34 -29
- package/lib/protocol/routes.js +60 -1
- package/package.json +36 -24
- package/test/basedriver/README.md +5 -0
- package/test/basedriver/driver-e2e-tests.js +1 -1
- package/test/basedriver/driver-tests.js +12 -7
- package/build/lib/protocol/sessions-cache.js +0 -88
- package/build/test/basedriver/capabilities-specs.js +0 -632
- package/build/test/basedriver/capability-specs.js +0 -396
- package/build/test/basedriver/commands/event-specs.js +0 -112
- package/build/test/basedriver/commands/log-specs.js +0 -80
- package/build/test/basedriver/driver-e2e-specs.js +0 -17
- package/build/test/basedriver/driver-specs.js +0 -17
- package/build/test/basedriver/helpers-e2e-specs.js +0 -194
- package/build/test/basedriver/helpers-specs.js +0 -153
- package/build/test/basedriver/timeout-specs.js +0 -139
- package/build/test/basedriver/websockets-e2e-specs.js +0 -84
- package/build/test/express/server-e2e-specs.js +0 -156
- package/build/test/express/server-specs.js +0 -151
- package/build/test/express/static-specs.js +0 -23
- package/build/test/jsonwp-proxy/mock-request.js +0 -93
- package/build/test/jsonwp-proxy/protocol-converter-specs.js +0 -173
- package/build/test/jsonwp-proxy/proxy-e2e-specs.js +0 -61
- package/build/test/jsonwp-proxy/proxy-specs.js +0 -294
- package/build/test/jsonwp-proxy/url-specs.js +0 -167
- package/build/test/jsonwp-status/status-specs.js +0 -36
- package/build/test/protocol/errors-specs.js +0 -388
- package/build/test/protocol/fake-driver.js +0 -168
- package/build/test/protocol/helpers.js +0 -27
- package/build/test/protocol/protocol-e2e-specs.js +0 -1182
- package/build/test/protocol/routes-specs.js +0 -82
- package/build/test/protocol/validator-specs.js +0 -151
- package/lib/protocol/sessions-cache.js +0 -74
- package/test/basedriver/capabilities-specs.js +0 -505
- package/test/basedriver/capability-specs.js +0 -409
- package/test/basedriver/commands/event-specs.js +0 -74
- package/test/basedriver/commands/log-specs.js +0 -70
- package/test/basedriver/driver-e2e-specs.js +0 -8
- package/test/basedriver/driver-specs.js +0 -8
- package/test/basedriver/fixtures/BadZippedApp.zip +0 -1
- package/test/basedriver/fixtures/FakeAndroidApp.apk +0 -1
- package/test/basedriver/fixtures/FakeAndroidApp.asd +0 -0
- package/test/basedriver/fixtures/FakeIOSApp.app +0 -1
- package/test/basedriver/fixtures/FakeIOSApp.app.zip +0 -0
- package/test/basedriver/fixtures/FakeIOSApp.ipa +0 -0
- package/test/basedriver/fixtures/custom-element-finder-bad.js +0 -5
- package/test/basedriver/fixtures/custom-element-finder.js +0 -29
- package/test/basedriver/helpers-e2e-specs.js +0 -187
- package/test/basedriver/helpers-specs.js +0 -137
- package/test/basedriver/timeout-specs.js +0 -133
- package/test/basedriver/websockets-e2e-specs.js +0 -75
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("source-map-support/register");
|
|
4
|
+
|
|
5
|
+
var _validators = require("../../../lib/protocol/validators");
|
|
6
|
+
|
|
7
|
+
describe('Protocol', function () {
|
|
8
|
+
describe('direct to driver', function () {
|
|
9
|
+
describe('setUrl', function () {
|
|
10
|
+
it('should fail when no url passed', function () {
|
|
11
|
+
(() => {
|
|
12
|
+
_validators.validators.setUrl();
|
|
13
|
+
}).should.throw(/url/i);
|
|
14
|
+
});
|
|
15
|
+
it('should fail when given invalid url', function () {
|
|
16
|
+
(() => {
|
|
17
|
+
_validators.validators.setUrl('foo');
|
|
18
|
+
}).should.throw(/url/i);
|
|
19
|
+
});
|
|
20
|
+
it('should succeed when given url starting with http', function () {
|
|
21
|
+
(() => {
|
|
22
|
+
_validators.validators.setUrl('http://appium.io');
|
|
23
|
+
}).should.not.throw();
|
|
24
|
+
});
|
|
25
|
+
it('should succeed when given an android-like scheme', function () {
|
|
26
|
+
(() => {
|
|
27
|
+
_validators.validators.setUrl('content://contacts/people/1');
|
|
28
|
+
}).should.not.throw();
|
|
29
|
+
});
|
|
30
|
+
it('should succeed with hyphens dots and plus chars in the scheme', function () {
|
|
31
|
+
(() => {
|
|
32
|
+
_validators.validators.setUrl('my-app.a+b://login');
|
|
33
|
+
}).should.not.throw();
|
|
34
|
+
});
|
|
35
|
+
it('should succeed when given an about scheme', function () {
|
|
36
|
+
(() => {
|
|
37
|
+
_validators.validators.setUrl('about:blank');
|
|
38
|
+
}).should.not.throw();
|
|
39
|
+
});
|
|
40
|
+
it('should succeed when given a data scheme', function () {
|
|
41
|
+
(() => {
|
|
42
|
+
_validators.validators.setUrl('data:text/html,<html></html>');
|
|
43
|
+
}).should.not.throw();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('implicitWait', function () {
|
|
47
|
+
it('should fail when given no ms', function () {
|
|
48
|
+
(() => {
|
|
49
|
+
_validators.validators.implicitWait();
|
|
50
|
+
}).should.throw(/ms/i);
|
|
51
|
+
});
|
|
52
|
+
it('should fail when given a non-numeric ms', function () {
|
|
53
|
+
(() => {
|
|
54
|
+
_validators.validators.implicitWait('five');
|
|
55
|
+
}).should.throw(/ms/i);
|
|
56
|
+
});
|
|
57
|
+
it('should fail when given a negative ms', function () {
|
|
58
|
+
(() => {
|
|
59
|
+
_validators.validators.implicitWait(-1);
|
|
60
|
+
}).should.throw(/ms/i);
|
|
61
|
+
});
|
|
62
|
+
it('should succeed when given an ms of 0', function () {
|
|
63
|
+
(() => {
|
|
64
|
+
_validators.validators.implicitWait(0);
|
|
65
|
+
}).should.not.throw();
|
|
66
|
+
});
|
|
67
|
+
it('should succeed when given an ms greater than 0', function () {
|
|
68
|
+
(() => {
|
|
69
|
+
_validators.validators.implicitWait(100);
|
|
70
|
+
}).should.not.throw();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('asyncScriptTimeout', function () {
|
|
74
|
+
it('should fail when given no ms', function () {
|
|
75
|
+
(() => {
|
|
76
|
+
_validators.validators.asyncScriptTimeout();
|
|
77
|
+
}).should.throw(/ms/i);
|
|
78
|
+
});
|
|
79
|
+
it('should fail when given a non-numeric ms', function () {
|
|
80
|
+
(() => {
|
|
81
|
+
_validators.validators.asyncScriptTimeout('five');
|
|
82
|
+
}).should.throw(/ms/i);
|
|
83
|
+
});
|
|
84
|
+
it('should fail when given a negative ms', function () {
|
|
85
|
+
(() => {
|
|
86
|
+
_validators.validators.asyncScriptTimeout(-1);
|
|
87
|
+
}).should.throw(/ms/i);
|
|
88
|
+
});
|
|
89
|
+
it('should succeed when given an ms of 0', function () {
|
|
90
|
+
(() => {
|
|
91
|
+
_validators.validators.asyncScriptTimeout(0);
|
|
92
|
+
}).should.not.throw();
|
|
93
|
+
});
|
|
94
|
+
it('should succeed when given an ms greater than 0', function () {
|
|
95
|
+
(() => {
|
|
96
|
+
_validators.validators.asyncScriptTimeout(100);
|
|
97
|
+
}).should.not.throw();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
describe('clickCurrent', function () {
|
|
101
|
+
it('should fail when given an invalid button', function () {
|
|
102
|
+
(() => {
|
|
103
|
+
_validators.validators.clickCurrent(4);
|
|
104
|
+
}).should.throw(/0, 1, or 2/i);
|
|
105
|
+
});
|
|
106
|
+
it('should succeed when given a valid button', function () {
|
|
107
|
+
(() => {
|
|
108
|
+
_validators.validators.clickCurrent(0);
|
|
109
|
+
}).should.not.throw();
|
|
110
|
+
(() => {
|
|
111
|
+
_validators.validators.clickCurrent(1);
|
|
112
|
+
}).should.not.throw();
|
|
113
|
+
(() => {
|
|
114
|
+
_validators.validators.clickCurrent(2);
|
|
115
|
+
}).should.not.throw();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe('setNetworkConnection', function () {
|
|
119
|
+
it('should fail when given no type', function () {
|
|
120
|
+
(() => {
|
|
121
|
+
_validators.validators.setNetworkConnection();
|
|
122
|
+
}).should.throw(/0, 1, 2, 4, 6/i);
|
|
123
|
+
});
|
|
124
|
+
it('should fail when given an invalid type', function () {
|
|
125
|
+
(() => {
|
|
126
|
+
_validators.validators.setNetworkConnection(8);
|
|
127
|
+
}).should.throw(/0, 1, 2, 4, 6/i);
|
|
128
|
+
});
|
|
129
|
+
it('should succeed when given a valid type', function () {
|
|
130
|
+
(() => {
|
|
131
|
+
_validators.validators.setNetworkConnection(0);
|
|
132
|
+
}).should.not.throw();
|
|
133
|
+
(() => {
|
|
134
|
+
_validators.validators.setNetworkConnection(1);
|
|
135
|
+
}).should.not.throw();
|
|
136
|
+
(() => {
|
|
137
|
+
_validators.validators.setNetworkConnection(2);
|
|
138
|
+
}).should.not.throw();
|
|
139
|
+
(() => {
|
|
140
|
+
_validators.validators.setNetworkConnection(4);
|
|
141
|
+
}).should.not.throw();
|
|
142
|
+
(() => {
|
|
143
|
+
_validators.validators.setNetworkConnection(6);
|
|
144
|
+
}).should.not.throw();
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Rlc3QvdW5pdC9wcm90b2NvbC92YWxpZGF0b3Iuc3BlYy5qcyJdLCJuYW1lcyI6WyJkZXNjcmliZSIsIml0IiwidmFsaWRhdG9ycyIsInNldFVybCIsInNob3VsZCIsInRocm93Iiwibm90IiwiaW1wbGljaXRXYWl0IiwiYXN5bmNTY3JpcHRUaW1lb3V0IiwiY2xpY2tDdXJyZW50Iiwic2V0TmV0d29ya0Nvbm5lY3Rpb24iXSwibWFwcGluZ3MiOiI7Ozs7QUFFQTs7QUFJQUEsUUFBUSxDQUFDLFVBQUQsRUFBYSxZQUFZO0FBQy9CQSxFQUFBQSxRQUFRLENBQUMsa0JBQUQsRUFBcUIsWUFBWTtBQUV2Q0EsSUFBQUEsUUFBUSxDQUFDLFFBQUQsRUFBVyxZQUFZO0FBQzdCQyxNQUFBQSxFQUFFLENBQUMsZ0NBQUQsRUFBbUMsWUFBWTtBQUMvQyxTQUFDLE1BQU07QUFBQ0MsaUNBQVdDLE1BQVg7QUFBcUIsU0FBN0IsRUFBK0JDLE1BQS9CLENBQXNDQyxLQUF0QyxDQUE0QyxNQUE1QztBQUNELE9B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KTtcbiAgICAgICAgKCgpID0+IHt2YWxpZGF0b3JzLnNldE5ldHdvcmtDb25uZWN0aW9uKDEpO30pLnNob3VsZC5ub3QudGhyb3coKTtcbiAgICAgICAgKCgpID0+IHt2YWxpZGF0b3JzLnNldE5ldHdvcmtDb25uZWN0aW9uKDIpO30pLnNob3VsZC5ub3QudGhyb3coKTtcbiAgICAgICAgKCgpID0+IHt2YWxpZGF0b3JzLnNldE5ldHdvcmtDb25uZWN0aW9uKDQpO30pLnNob3VsZC5ub3QudGhyb3coKTtcbiAgICAgICAgKCgpID0+IHt2YWxpZGF0b3JzLnNldE5ldHdvcmtDb25uZWN0aW9uKDYpO30pLnNob3VsZC5ub3QudGhyb3coKTtcbiAgICAgIH0pO1xuICAgIH0pO1xuICB9KTtcbn0pO1xuIl19
|
|
@@ -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
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,28 @@ 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, 4)}`;
|
|
112
|
+
// We don't want the self reference to be captured inside the below closure
|
|
113
|
+
// to avoid possible memory leaks,
|
|
114
|
+
// but NodeJS started supporting WeakRef only since v. 14.6
|
|
115
|
+
const self = global.WeakRef ? new global.WeakRef(this) : this;
|
|
116
|
+
this._log = logger.getLogger(() => {
|
|
117
|
+
let sessionId = self?.sessionId;
|
|
118
|
+
if (!sessionId && _.isFunction(self.deref)) {
|
|
119
|
+
const ref = self.deref();
|
|
120
|
+
if (ref?.sessionId) {
|
|
121
|
+
sessionId = ref.sessionId;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return sessionId ? `${instanceName} (${sessionId.substring(0, 8)})` : instanceName;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return this._log;
|
|
129
|
+
}
|
|
130
|
+
|
|
107
131
|
/**
|
|
108
132
|
* Set a callback handler if needed to execute a custom piece of code
|
|
109
133
|
* when the driver is shut down unexpectedly. Multiple calls to this method
|
|
@@ -168,7 +192,7 @@ class BaseDriver extends Protocol {
|
|
|
168
192
|
const ts = Date.now();
|
|
169
193
|
const logTime = (new Date(ts)).toTimeString();
|
|
170
194
|
this._eventHistory[eventName].push(ts);
|
|
171
|
-
log.debug(`Event '${eventName}' logged at ${ts} (${logTime})`);
|
|
195
|
+
this.log.debug(`Event '${eventName}' logged at ${ts} (${logTime})`);
|
|
172
196
|
}
|
|
173
197
|
|
|
174
198
|
/*
|
|
@@ -214,10 +238,10 @@ class BaseDriver extends Protocol {
|
|
|
214
238
|
let extraCaps = _.difference(_.keys(caps),
|
|
215
239
|
_.keys(this._constraints));
|
|
216
240
|
if (extraCaps.length) {
|
|
217
|
-
log.warn(`The following capabilities were provided, but are not ` +
|
|
241
|
+
this.log.warn(`The following capabilities were provided, but are not ` +
|
|
218
242
|
`recognized by Appium:`);
|
|
219
243
|
for (const cap of extraCaps) {
|
|
220
|
-
log.warn(` ${cap}`);
|
|
244
|
+
this.log.warn(` ${cap}`);
|
|
221
245
|
}
|
|
222
246
|
}
|
|
223
247
|
}
|
|
@@ -230,8 +254,8 @@ class BaseDriver extends Protocol {
|
|
|
230
254
|
try {
|
|
231
255
|
validateCaps(caps, this._constraints);
|
|
232
256
|
} catch (e) {
|
|
233
|
-
log.errorAndThrow(new errors.SessionNotCreatedError(`The desiredCapabilities object was not valid for the ` +
|
|
234
|
-
|
|
257
|
+
this.log.errorAndThrow(new errors.SessionNotCreatedError(`The desiredCapabilities object was not valid for the ` +
|
|
258
|
+
`following reason(s): ${e.message}`));
|
|
235
259
|
}
|
|
236
260
|
|
|
237
261
|
this.logExtraCaps(caps);
|
|
@@ -309,7 +333,7 @@ class BaseDriver extends Protocol {
|
|
|
309
333
|
|
|
310
334
|
if (cmd === 'createSession') {
|
|
311
335
|
// If creating a session determine if W3C or MJSONWP protocol was requested and remember the choice
|
|
312
|
-
this.protocol = determineProtocol(
|
|
336
|
+
this.protocol = determineProtocol(args);
|
|
313
337
|
this.logEvent(EVENT_SESSION_INIT);
|
|
314
338
|
} else if (cmd === DELETE_SESSION_COMMAND) {
|
|
315
339
|
this.logEvent(EVENT_SESSION_QUIT_START);
|
|
@@ -381,7 +405,7 @@ class BaseDriver extends Protocol {
|
|
|
381
405
|
|
|
382
406
|
validateLocatorStrategy (strategy, webContext = false) {
|
|
383
407
|
let validStrategies = this.locatorStrategies;
|
|
384
|
-
log.debug(`Valid locator strategies for this request: ${validStrategies.join(', ')}`);
|
|
408
|
+
this.log.debug(`Valid locator strategies for this request: ${validStrategies.join(', ')}`);
|
|
385
409
|
|
|
386
410
|
if (webContext) {
|
|
387
411
|
validStrategies = validStrategies.concat(this.webLocatorStrategies);
|
|
@@ -397,8 +421,8 @@ class BaseDriver extends Protocol {
|
|
|
397
421
|
* preserving the timeout config.
|
|
398
422
|
*/
|
|
399
423
|
async reset () {
|
|
400
|
-
log.debug('Resetting app mid-session');
|
|
401
|
-
log.debug('Running generic full reset');
|
|
424
|
+
this.log.debug('Resetting app mid-session');
|
|
425
|
+
this.log.debug('Running generic full reset');
|
|
402
426
|
|
|
403
427
|
// preserving state
|
|
404
428
|
let currentConfig = {};
|
|
@@ -411,7 +435,7 @@ class BaseDriver extends Protocol {
|
|
|
411
435
|
|
|
412
436
|
try {
|
|
413
437
|
await this.deleteSession(this.sessionId);
|
|
414
|
-
log.debug('Restarting app');
|
|
438
|
+
this.log.debug('Restarting app');
|
|
415
439
|
await this.createSession(undefined, undefined, this.originalCaps);
|
|
416
440
|
} finally {
|
|
417
441
|
// always restore state.
|
|
@@ -15,17 +15,17 @@ const ZIP_MIME_TYPES = [
|
|
|
15
15
|
'multipart/x-zip',
|
|
16
16
|
];
|
|
17
17
|
const CACHED_APPS_MAX_AGE = 1000 * 60 * 60 * 24; // ms
|
|
18
|
+
const MAX_CACHED_APPS = 1024;
|
|
18
19
|
const APPLICATIONS_CACHE = new LRU({
|
|
19
|
-
|
|
20
|
+
max: MAX_CACHED_APPS,
|
|
21
|
+
ttl: CACHED_APPS_MAX_AGE, // expire after 24 hours
|
|
20
22
|
updateAgeOnGet: true,
|
|
21
23
|
dispose: (app, {fullPath}) => {
|
|
22
24
|
logger.info(`The application '${app}' cached at '${fullPath}' has ` +
|
|
23
25
|
`expired after ${CACHED_APPS_MAX_AGE}ms`);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
});
|
|
26
|
+
if (fullPath) {
|
|
27
|
+
fs.rimraf(fullPath);
|
|
28
|
+
}
|
|
29
29
|
},
|
|
30
30
|
noDisposeOnSet: true,
|
|
31
31
|
});
|
|
@@ -35,11 +35,11 @@ const DEFAULT_BASENAME = 'appium-app';
|
|
|
35
35
|
const APP_DOWNLOAD_TIMEOUT_MS = 120 * 1000;
|
|
36
36
|
|
|
37
37
|
process.on('exit', () => {
|
|
38
|
-
if (APPLICATIONS_CACHE.
|
|
38
|
+
if (APPLICATIONS_CACHE.size === 0) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const appPaths = APPLICATIONS_CACHE.values()
|
|
42
|
+
const appPaths = [...APPLICATIONS_CACHE.values()]
|
|
43
43
|
.map(({fullPath}) => fullPath);
|
|
44
44
|
logger.debug(`Performing cleanup of ${appPaths.length} cached ` +
|
|
45
45
|
util.pluralize('application', appPaths.length));
|
|
@@ -151,7 +151,7 @@ async function isAppIntegrityOk (currentPath, expectedIntegrity = {}) {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
* @typedef
|
|
154
|
+
* @typedef PostProcessOptions
|
|
155
155
|
* @property {?Object} cachedAppInfo The information about the previously cached app instance (if exists):
|
|
156
156
|
* - packageHash: SHA1 hash of the package if it is a file and not a folder
|
|
157
157
|
* - lastModified: Optional Date instance, the value of file's `Last-Modified` header
|
|
@@ -171,13 +171,13 @@ async function isAppIntegrityOk (currentPath, expectedIntegrity = {}) {
|
|
|
171
171
|
*/
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
* @typedef
|
|
174
|
+
* @typedef PostProcessResult
|
|
175
175
|
* @property {string} appPath The full past to the post-processed application package on the
|
|
176
176
|
* local file system (might be a file or a folder path)
|
|
177
177
|
*/
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
|
-
* @typedef
|
|
180
|
+
* @typedef ConfigureAppOptions
|
|
181
181
|
* @property {(obj: PostProcessOptions) => (Promise<PostProcessResult|undefined>|PostProcessResult|undefined)} onPostProcess
|
|
182
182
|
* Optional function, which should be applied
|
|
183
183
|
* to the application after it is downloaded/preprocessed. This function may be async
|
|
@@ -193,6 +193,8 @@ async function isAppIntegrityOk (currentPath, expectedIntegrity = {}) {
|
|
|
193
193
|
/**
|
|
194
194
|
* Prepares an app to be used in an automated test. The app gets cached automatically
|
|
195
195
|
* if it is an archive or if it is downloaded from an URL.
|
|
196
|
+
* If the downloaded app has `.zip` extension, this method will unzip it.
|
|
197
|
+
* The unzip does not work when `onPostProcess` is provided.
|
|
196
198
|
*
|
|
197
199
|
* @param {string} app Either a full path to the app or a remote URL
|
|
198
200
|
* @param {string|string[]|ConfigureAppOptions} options
|
|
@@ -20,7 +20,7 @@ const MONITORED_METHODS = ['POST', 'PATCH'];
|
|
|
20
20
|
const IDEMPOTENCY_KEY_HEADER = 'x-idempotency-key';
|
|
21
21
|
|
|
22
22
|
process.on('exit', () => {
|
|
23
|
-
const resPaths = IDEMPOTENT_RESPONSES.values()
|
|
23
|
+
const resPaths = [...IDEMPOTENT_RESPONSES.values()]
|
|
24
24
|
.map(({response}) => response)
|
|
25
25
|
.filter(Boolean);
|
|
26
26
|
for (const resPath of resPaths) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
|
|
3
|
+
function isW3cCaps (caps) {
|
|
4
|
+
if (!_.isPlainObject(caps)) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const isFirstMatchValid = () => _.isArray(caps.firstMatch)
|
|
9
|
+
&& !_.isEmpty(caps.firstMatch) && _.every(caps.firstMatch, _.isPlainObject);
|
|
10
|
+
const isAlwaysMatchValid = () => _.isPlainObject(caps.alwaysMatch);
|
|
11
|
+
if (_.has(caps, 'firstMatch') && _.has(caps, 'alwaysMatch')) {
|
|
12
|
+
return isFirstMatchValid() && isAlwaysMatchValid();
|
|
13
|
+
}
|
|
14
|
+
if (_.has(caps, 'firstMatch')) {
|
|
15
|
+
return isFirstMatchValid();
|
|
16
|
+
}
|
|
17
|
+
if (_.has(caps, 'alwaysMatch')) {
|
|
18
|
+
return isAlwaysMatchValid();
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
isW3cCaps,
|
|
25
|
+
};
|