appium-xcuitest-driver 7.21.2 → 7.22.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/CHANGELOG.md +12 -0
- package/build/lib/commands/context.js +2 -2
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +27 -14
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/pcap.d.ts.map +1 -1
- package/build/lib/commands/pcap.js +1 -5
- package/build/lib/commands/pcap.js.map +1 -1
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +3 -5
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +8 -9
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/device-log/helpers.d.ts +4 -1
- package/build/lib/device-log/helpers.d.ts.map +1 -1
- package/build/lib/device-log/helpers.js +6 -2
- package/build/lib/device-log/helpers.js.map +1 -1
- package/build/lib/device-log/ios-crash-log.d.ts +0 -4
- package/build/lib/device-log/ios-crash-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-crash-log.js +0 -8
- package/build/lib/device-log/ios-crash-log.js.map +1 -1
- package/build/lib/device-log/ios-device-log.d.ts +3 -3
- package/build/lib/device-log/ios-device-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-log.d.ts +1 -3
- package/build/lib/device-log/ios-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-log.js +12 -27
- package/build/lib/device-log/ios-log.js.map +1 -1
- package/build/lib/device-log/ios-performance-log.d.ts +4 -8
- package/build/lib/device-log/ios-performance-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-performance-log.js +9 -16
- package/build/lib/device-log/ios-performance-log.js.map +1 -1
- package/build/lib/device-log/ios-simulator-log.d.ts +4 -4
- package/build/lib/device-log/ios-simulator-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-simulator-log.js +4 -6
- package/build/lib/device-log/ios-simulator-log.js.map +1 -1
- package/build/lib/device-log/safari-console-log.d.ts +65 -6
- package/build/lib/device-log/safari-console-log.d.ts.map +1 -1
- package/build/lib/device-log/safari-console-log.js +61 -81
- package/build/lib/device-log/safari-console-log.js.map +1 -1
- package/build/lib/device-log/safari-network-log.d.ts +36 -8
- package/build/lib/device-log/safari-network-log.d.ts.map +1 -1
- package/build/lib/device-log/safari-network-log.js +28 -151
- package/build/lib/device-log/safari-network-log.js.map +1 -1
- package/build/lib/driver.d.ts.map +1 -1
- package/lib/commands/context.js +2 -2
- package/lib/commands/log.js +32 -14
- package/lib/commands/pcap.js +1 -5
- package/lib/commands/performance.js +3 -5
- package/lib/commands/recordscreen.js +7 -8
- package/lib/device-log/helpers.ts +6 -2
- package/lib/device-log/ios-crash-log.js +0 -9
- package/lib/device-log/ios-device-log.ts +3 -3
- package/lib/device-log/ios-log.ts +16 -33
- package/lib/device-log/ios-performance-log.ts +11 -22
- package/lib/device-log/ios-simulator-log.ts +9 -11
- package/lib/device-log/safari-console-log.ts +112 -0
- package/lib/device-log/safari-network-log.ts +80 -0
- package/npm-shrinkwrap.json +69 -24
- package/package.json +2 -2
- package/build/lib/device-log/rotating-log.d.ts +0 -21
- package/build/lib/device-log/rotating-log.d.ts.map +0 -1
- package/build/lib/device-log/rotating-log.js +0 -61
- package/build/lib/device-log/rotating-log.js.map +0 -1
- package/lib/device-log/rotating-log.js +0 -65
- package/lib/device-log/safari-console-log.js +0 -96
- package/lib/device-log/safari-network-log.js +0 -193
|
@@ -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;
|