appium-xcuitest-driver 7.21.2 → 7.22.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/lib/commands/context.js +2 -2
  3. package/build/lib/commands/context.js.map +1 -1
  4. package/build/lib/commands/log.d.ts.map +1 -1
  5. package/build/lib/commands/log.js +27 -14
  6. package/build/lib/commands/log.js.map +1 -1
  7. package/build/lib/device-log/helpers.d.ts +4 -1
  8. package/build/lib/device-log/helpers.d.ts.map +1 -1
  9. package/build/lib/device-log/helpers.js +6 -2
  10. package/build/lib/device-log/helpers.js.map +1 -1
  11. package/build/lib/device-log/ios-crash-log.d.ts +0 -4
  12. package/build/lib/device-log/ios-crash-log.d.ts.map +1 -1
  13. package/build/lib/device-log/ios-crash-log.js +0 -8
  14. package/build/lib/device-log/ios-crash-log.js.map +1 -1
  15. package/build/lib/device-log/ios-device-log.d.ts +3 -3
  16. package/build/lib/device-log/ios-device-log.d.ts.map +1 -1
  17. package/build/lib/device-log/ios-log.d.ts +1 -3
  18. package/build/lib/device-log/ios-log.d.ts.map +1 -1
  19. package/build/lib/device-log/ios-log.js +12 -27
  20. package/build/lib/device-log/ios-log.js.map +1 -1
  21. package/build/lib/device-log/ios-performance-log.d.ts +4 -8
  22. package/build/lib/device-log/ios-performance-log.d.ts.map +1 -1
  23. package/build/lib/device-log/ios-performance-log.js +9 -16
  24. package/build/lib/device-log/ios-performance-log.js.map +1 -1
  25. package/build/lib/device-log/ios-simulator-log.d.ts +4 -4
  26. package/build/lib/device-log/ios-simulator-log.d.ts.map +1 -1
  27. package/build/lib/device-log/ios-simulator-log.js +4 -6
  28. package/build/lib/device-log/ios-simulator-log.js.map +1 -1
  29. package/build/lib/device-log/safari-console-log.d.ts +65 -6
  30. package/build/lib/device-log/safari-console-log.d.ts.map +1 -1
  31. package/build/lib/device-log/safari-console-log.js +61 -81
  32. package/build/lib/device-log/safari-console-log.js.map +1 -1
  33. package/build/lib/device-log/safari-network-log.d.ts +36 -8
  34. package/build/lib/device-log/safari-network-log.d.ts.map +1 -1
  35. package/build/lib/device-log/safari-network-log.js +28 -151
  36. package/build/lib/device-log/safari-network-log.js.map +1 -1
  37. package/lib/commands/context.js +2 -2
  38. package/lib/commands/log.js +32 -14
  39. package/lib/device-log/helpers.ts +6 -2
  40. package/lib/device-log/ios-crash-log.js +0 -9
  41. package/lib/device-log/ios-device-log.ts +3 -3
  42. package/lib/device-log/ios-log.ts +16 -33
  43. package/lib/device-log/ios-performance-log.ts +11 -22
  44. package/lib/device-log/ios-simulator-log.ts +9 -11
  45. package/lib/device-log/safari-console-log.ts +112 -0
  46. package/lib/device-log/safari-network-log.ts +80 -0
  47. package/npm-shrinkwrap.json +69 -24
  48. package/package.json +2 -2
  49. package/build/lib/device-log/rotating-log.d.ts +0 -21
  50. package/build/lib/device-log/rotating-log.d.ts.map +0 -1
  51. package/build/lib/device-log/rotating-log.js +0 -61
  52. package/build/lib/device-log/rotating-log.js.map +0 -1
  53. package/lib/device-log/rotating-log.js +0 -65
  54. package/lib/device-log/safari-console-log.js +0 -96
  55. package/lib/device-log/safari-network-log.js +0 -193
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MAX_LOG_ENTRIES_COUNT = exports.RotatingLog = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
8
- const support_1 = require("appium/support");
9
- const MAX_LOG_ENTRIES_COUNT = 10000;
10
- exports.MAX_LOG_ENTRIES_COUNT = MAX_LOG_ENTRIES_COUNT;
11
- class RotatingLog {
12
- constructor(showLogs = false, label = 'Log Label') {
13
- this.log = support_1.logger.getLogger(label);
14
- this.showLogs = showLogs;
15
- this.logs = [];
16
- this.logIdxSinceLastRequest = 0;
17
- this.isCapturing = false;
18
- }
19
- // eslint-disable-next-line require-await
20
- async startCapture() {
21
- this.isCapturing = true;
22
- }
23
- // eslint-disable-next-line require-await
24
- async stopCapture() {
25
- this.isCapturing = false;
26
- }
27
- /**
28
- * @privateRemarks Subclasses must implement this.
29
- */
30
- addLogLine() {
31
- throw new Error('Not implemented');
32
- }
33
- // eslint-disable-next-line require-await
34
- async getLogs() {
35
- if (this.logs.length && this.logIdxSinceLastRequest < this.logs.length) {
36
- let result = this.logs;
37
- if (this.logIdxSinceLastRequest > 0) {
38
- result = result.slice(this.logIdxSinceLastRequest);
39
- }
40
- this.logIdxSinceLastRequest = this.logs.length;
41
- return result;
42
- }
43
- return [];
44
- }
45
- // eslint-disable-next-line require-await
46
- async getAllLogs() {
47
- return lodash_1.default.clone(this.logs);
48
- }
49
- get logs() {
50
- if (!this._logs) {
51
- this.logs = [];
52
- }
53
- return this._logs;
54
- }
55
- set logs(logs) {
56
- this._logs = logs;
57
- }
58
- }
59
- exports.RotatingLog = RotatingLog;
60
- exports.default = RotatingLog;
61
- //# sourceMappingURL=rotating-log.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rotating-log.js","sourceRoot":"","sources":["../../../lib/device-log/rotating-log.js"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,4CAAsC;AAEtC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AA4Df,sDAAqB;AA1D1C,MAAM,WAAW;IACf,YAAY,QAAQ,GAAG,KAAK,EAAE,KAAK,GAAG,WAAW;QAC/C,IAAI,CAAC,GAAG,GAAG,gBAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,sBAAsB,GAAG,CAAC,CAAC;QAEhC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,yCAAyC;IACzC,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,yCAAyC;IACzC,KAAK,CAAC,WAAW;QACf,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,UAAU;QACR,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,yCAAyC;IACzC,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACvE,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC;YACvB,IAAI,IAAI,CAAC,sBAAsB,GAAG,CAAC,EAAE,CAAC;gBACpC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YACrD,CAAC;YACD,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAC/C,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,yCAAyC;IACzC,KAAK,CAAC,UAAU;QACd,OAAO,gBAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,IAAI;QACN,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACjB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,IAAI,CAAC,IAAI;QACX,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;CACF;AAEO,kCAAW;AACnB,kBAAe,WAAW,CAAC"}
@@ -1,65 +0,0 @@
1
- import _ from 'lodash';
2
- import {logger} from 'appium/support';
3
-
4
- const MAX_LOG_ENTRIES_COUNT = 10000;
5
-
6
- class RotatingLog {
7
- constructor(showLogs = false, label = 'Log Label') {
8
- this.log = logger.getLogger(label);
9
-
10
- this.showLogs = showLogs;
11
- this.logs = [];
12
- this.logIdxSinceLastRequest = 0;
13
-
14
- this.isCapturing = false;
15
- }
16
-
17
- // eslint-disable-next-line require-await
18
- async startCapture() {
19
- this.isCapturing = true;
20
- }
21
-
22
- // eslint-disable-next-line require-await
23
- async stopCapture() {
24
- this.isCapturing = false;
25
- }
26
-
27
- /**
28
- * @privateRemarks Subclasses must implement this.
29
- */
30
- addLogLine() {
31
- throw new Error('Not implemented');
32
- }
33
-
34
- // eslint-disable-next-line require-await
35
- async getLogs() {
36
- if (this.logs.length && this.logIdxSinceLastRequest < this.logs.length) {
37
- let result = this.logs;
38
- if (this.logIdxSinceLastRequest > 0) {
39
- result = result.slice(this.logIdxSinceLastRequest);
40
- }
41
- this.logIdxSinceLastRequest = this.logs.length;
42
- return result;
43
- }
44
- return [];
45
- }
46
-
47
- // eslint-disable-next-line require-await
48
- async getAllLogs() {
49
- return _.clone(this.logs);
50
- }
51
-
52
- get logs() {
53
- if (!this._logs) {
54
- this.logs = [];
55
- }
56
- return this._logs;
57
- }
58
-
59
- set logs(logs) {
60
- this._logs = logs;
61
- }
62
- }
63
-
64
- export {RotatingLog, MAX_LOG_ENTRIES_COUNT};
65
- export default RotatingLog;
@@ -1,96 +0,0 @@
1
- import {RotatingLog, MAX_LOG_ENTRIES_COUNT} from './rotating-log';
2
- import _ from 'lodash';
3
- import {util} from 'appium/support';
4
-
5
- class SafariConsoleLog extends RotatingLog {
6
- constructor(showLogs) {
7
- super(showLogs, 'SafariConsole');
8
-
9
- // js console has `warning` level, so map to `warn`
10
- this.log = new Proxy(this.log, {
11
- get(target, prop, receiver) {
12
- return Reflect.get(target, prop === 'warning' ? 'warn' : prop, receiver);
13
- },
14
- });
15
- }
16
-
17
- addLogLine(err, out) {
18
- if (this.isCapturing) {
19
- this.logs = this.logs || [];
20
- while (this.logs.length >= MAX_LOG_ENTRIES_COUNT) {
21
- this.logs.shift();
22
- if (this.logIdxSinceLastRequest > 0) {
23
- this.logIdxSinceLastRequest--;
24
- }
25
- }
26
-
27
- /*
28
- * The output will be like:
29
- * {
30
- * "source": "javascript",
31
- * "level":"error",
32
- * "text":"ReferenceError: Can't find variable: s_account",
33
- * "type":"log",
34
- * "line":2,
35
- * "column":21,
36
- * "url":"https://assets.adobedtm.com/b46e318d845250834eda10c5a20827c045a4d76f/scripts/satellite-57866f8b64746d53a8000104-staging.js",
37
- * "repeatCount":1,
38
- * "stackTrace":[{
39
- * "functionName":"global code",
40
- * "url":"https://assets.adobedtm.com/b46e318d845250834eda10c5a20827c045a4d76f/scripts/satellite-57866f8b64746d53a8000104-staging.js",
41
- * "scriptId":"6",
42
- * "lineNumber":2,
43
- * "columnNumber":21
44
- * }]
45
- * }
46
- *
47
- * we need, at least, `level` (in accordance with Java levels
48
- * (https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html)),
49
- * `timestamp`, and `message` to satisfy the java client. In order to
50
- * provide all the information to the client, `message` is the full
51
- * object, stringified.
52
- */
53
- const entry = {
54
- level:
55
- {
56
- error: 'SEVERE',
57
- warning: 'WARNING',
58
- log: 'FINE',
59
- }[out.level] || 'INFO',
60
- timestamp: Date.now(),
61
- message: JSON.stringify(out),
62
- };
63
- this.logs.push(entry);
64
- }
65
-
66
- if (_.has(out, 'count')) {
67
- // this is a notification of the previous message being repeated
68
- // this should _never_ be the first message, so the previous one ought to
69
- // be populated. If it is not, nothing will break, it will just look odd
70
- // in the output below (no url or line numbers)
71
- const count = out.count;
72
- out = this._previousOutput || {};
73
- out.text = `Previous message repeated ${util.pluralize('time', count, true)}`;
74
- } else {
75
- // save the most recent output
76
- this._previousOutput = out;
77
- }
78
-
79
- // format output like
80
- // SafariConsole [WARNING][http://appium.io 2:13] Log something to warn
81
- if (this.showLogs) {
82
- let level = 'debug';
83
- if (out.level === 'warning' || out.level === 'error') {
84
- level = out.level;
85
- }
86
- for (const line of out.text.split('\n')) {
87
- // url is optional, so get formatting here
88
- const url = out.url ? `${out.url} ` : '';
89
- this.log[level](`[${level.toUpperCase()}][${url}${out.line}:${out.column}] ${line}`);
90
- }
91
- }
92
- }
93
- }
94
-
95
- export {SafariConsoleLog};
96
- export default SafariConsoleLog;
@@ -1,193 +0,0 @@
1
- import _ from 'lodash';
2
- import URL from 'url';
3
- import {util} from 'appium/support';
4
- import {RotatingLog, MAX_LOG_ENTRIES_COUNT} from './rotating-log';
5
-
6
- class SafariNetworkLog extends RotatingLog {
7
- constructor(showLogs) {
8
- super(showLogs, 'SafariNetwork');
9
- }
10
-
11
- getEntry(requestId) {
12
- let outputEntry;
13
- while (this.logs.length >= MAX_LOG_ENTRIES_COUNT) {
14
- // pull the first entry, which is the oldest
15
- const entry = this.logs.shift();
16
- if (entry && entry.requestId === requestId) {
17
- // we are adding to an existing entry, and it was almost removed
18
- // add to the end of the list and try again
19
- outputEntry = entry;
20
- this.logs.push(outputEntry);
21
- continue;
22
- }
23
- // we've removed an element, so the count is down one
24
- if (this.logIdxSinceLastRequest > 0) {
25
- this.logIdxSinceLastRequest--;
26
- }
27
- }
28
-
29
- if (!outputEntry) {
30
- // we do not yes have an entry to associate this bit of output with
31
- // most likely the entry will be at the end of the list, so start there
32
- for (let i = this.logs.length - 1; i >= 0; i--) {
33
- if (this.logs[i].requestId === requestId) {
34
- // found it!
35
- outputEntry = this.logs[i];
36
- // this is now the most current entry, so remove it from the list
37
- // to be added to the end below
38
- this.logs.splice(i, 1);
39
- break;
40
- }
41
- }
42
-
43
- // nothing has been found, so create a new entry
44
- if (!outputEntry) {
45
- outputEntry = {
46
- requestId,
47
- logs: [],
48
- };
49
- }
50
-
51
- // finally, add the entry to the end of the list
52
- this.logs.push(outputEntry);
53
- }
54
-
55
- return outputEntry;
56
- }
57
-
58
- addLogLine(method, out) {
59
- if (!this.isCapturing && !this.showLogs) {
60
- // neither capturing nor displaying, so do nothing
61
- return;
62
- }
63
-
64
- if (['Network.dataReceived'].includes(method)) {
65
- // status update, no need to handle
66
- return;
67
- }
68
-
69
- // events we care about:
70
- // Network.requestWillBeSent
71
- // Network.responseReceived
72
- // Network.loadingFinished
73
- // Network.loadingFailed
74
-
75
- const outputEntry = this.getEntry(out.requestId);
76
- if (this.isCapturing) {
77
- // now add the output we just received to the logs for this particular entry
78
- outputEntry.logs = outputEntry.logs || [];
79
-
80
- outputEntry.logs.push(out);
81
- }
82
-
83
- // if we are not displaying the logs,
84
- // or we are not finished getting events for this network call,
85
- // we are done
86
- if (!this.showLogs) {
87
- return;
88
- }
89
-
90
- if (method === 'Network.loadingFinished' || method === 'Network.loadingFailed') {
91
- this.printLogLine(outputEntry);
92
- }
93
- }
94
-
95
- getLogDetails(outputEntry) {
96
- // extract the data
97
- const record = outputEntry.logs.reduce(function getRecord(record, entry) {
98
- record.requestId = entry.requestId;
99
- if (entry.response) {
100
- const url = URL.parse(entry.response.url);
101
- // get the last part of the url, along with the query string, if possible
102
- record.name =
103
- `${_.last(String(url.pathname).split('/'))}${url.search ? `?${url.search}` : ''}` ||
104
- url.host;
105
- record.status = entry.response.status;
106
- if (entry.response.timing) {
107
- record.time =
108
- entry.response.timing.receiveHeadersEnd || entry.response.timing.responseStart || 0;
109
- }
110
- record.source = entry.response.source;
111
- }
112
- if (entry.type) {
113
- record.type = entry.type;
114
- }
115
- if (entry.initiator) {
116
- record.initiator = entry.initiator;
117
- }
118
- if (entry.metrics) {
119
- // Safari has a `metrics` object on it's `Network.loadingFinished` event
120
- record.size = entry.metrics.responseBodyBytesReceived || 0;
121
- }
122
- if (entry.errorText) {
123
- record.errorText = entry.errorText;
124
- // When a network call is cancelled, Safari returns `cancelled` as error text
125
- // but has a boolean `canceled`. Normalize the two spellings in favor of
126
- // the text, which will also be displayed
127
- record.cancelled = entry.canceled;
128
- }
129
- return record;
130
- }, {});
131
-
132
- return record;
133
- }
134
-
135
- printLogLine(outputEntry) {
136
- const {
137
- requestId,
138
- name,
139
- status,
140
- type,
141
- initiator = {},
142
- size = 0,
143
- time = 0,
144
- source,
145
- errorText,
146
- cancelled = false,
147
- } = this.getLogDetails(outputEntry);
148
-
149
- // print out the record, formatted appropriately
150
- this.log.debug(`Network event:`);
151
- this.log.debug(` Id: ${requestId}`);
152
- this.log.debug(` Name: ${name}`);
153
- this.log.debug(` Status: ${status}`);
154
- this.log.debug(` Type: ${type}`);
155
- this.log.debug(` Initiator: ${initiator.type}`);
156
- for (const line of initiator.stackTrace || []) {
157
- const functionName = line.functionName || '(anonymous)';
158
-
159
- const url =
160
- !line.url || line.url === '[native code]'
161
- ? ''
162
- : `@${_.last((URL.parse(line.url).pathname || '').split('/'))}:${line.lineNumber}`;
163
- this.log.debug(` ${_.padEnd(_.truncate(functionName, {length: 20}), 21)} ${url}`);
164
- }
165
- // get `memory-cache` or `disk-cache`, etc., right
166
- const sizeStr = source.includes('cache') ? ` (from ${source.replace('-', ' ')})` : `${size}B`;
167
- this.log.debug(` Size: ${sizeStr}`);
168
- this.log.debug(` Time: ${Math.round(time)}ms`);
169
- if (errorText) {
170
- this.log.debug(` Error: ${errorText}`);
171
- }
172
- if (util.hasValue(cancelled)) {
173
- this.log.debug(` Cancelled: ${cancelled}`);
174
- }
175
- }
176
-
177
- async getLogs() {
178
- const logs = await super.getLogs();
179
- // in order to satisfy certain clients, we need to have a basic structure
180
- // to the results, with `level`, `timestamp`, and `message`, which is
181
- // all the information stringified
182
- return logs.map(function adjustEntry(entry) {
183
- return Object.assign({}, entry, {
184
- level: 'INFO',
185
- timestamp: Date.now(),
186
- message: JSON.stringify(entry),
187
- });
188
- });
189
- }
190
- }
191
-
192
- export {SafariNetworkLog};
193
- export default SafariNetworkLog;