appium-remote-debugger 11.5.7 → 11.5.9
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/mixins/connect.d.ts +27 -32
- package/build/lib/mixins/connect.d.ts.map +1 -1
- package/build/lib/mixins/connect.js +60 -29
- package/build/lib/mixins/connect.js.map +1 -1
- package/build/lib/mixins/cookies.d.ts +4 -3
- package/build/lib/mixins/cookies.d.ts.map +1 -1
- package/build/lib/mixins/cookies.js +6 -3
- package/build/lib/mixins/cookies.js.map +1 -1
- package/build/lib/mixins/events.d.ts +3 -2
- package/build/lib/mixins/events.d.ts.map +1 -1
- package/build/lib/mixins/events.js +5 -2
- package/build/lib/mixins/events.js.map +1 -1
- package/build/lib/mixins/execute.d.ts +7 -4
- package/build/lib/mixins/execute.d.ts.map +1 -1
- package/build/lib/mixins/execute.js +8 -3
- package/build/lib/mixins/execute.js.map +1 -1
- package/build/lib/mixins/message-handlers.d.ts +21 -11
- package/build/lib/mixins/message-handlers.d.ts.map +1 -1
- package/build/lib/mixins/message-handlers.js +49 -10
- package/build/lib/mixins/message-handlers.js.map +1 -1
- package/build/lib/mixins/misc.d.ts +10 -9
- package/build/lib/mixins/misc.d.ts.map +1 -1
- package/build/lib/mixins/misc.js +12 -9
- package/build/lib/mixins/misc.js.map +1 -1
- package/build/lib/mixins/navigate.d.ts +10 -8
- package/build/lib/mixins/navigate.d.ts.map +1 -1
- package/build/lib/mixins/navigate.js +10 -6
- package/build/lib/mixins/navigate.js.map +1 -1
- package/build/lib/mixins/screenshot.d.ts +2 -1
- package/build/lib/mixins/screenshot.d.ts.map +1 -1
- package/build/lib/mixins/screenshot.js +4 -1
- package/build/lib/mixins/screenshot.js.map +1 -1
- package/build/lib/remote-debugger.d.ts +4 -4
- package/build/lib/remote-debugger.d.ts.map +1 -1
- package/build/lib/types.d.ts +34 -0
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/types.js +3 -0
- package/build/lib/types.js.map +1 -0
- package/build/lib/utils.d.ts +25 -52
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +31 -113
- package/build/lib/utils.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/mixins/connect.js +64 -30
- package/lib/mixins/cookies.js +7 -3
- package/lib/mixins/events.js +6 -2
- package/lib/mixins/execute.js +9 -3
- package/lib/mixins/message-handlers.js +51 -11
- package/lib/mixins/misc.js +13 -9
- package/lib/mixins/navigate.js +11 -6
- package/lib/mixins/screenshot.js +5 -1
- package/lib/remote-debugger.js +2 -2
- package/lib/types.ts +39 -0
- package/lib/utils.js +30 -122
- package/package.json +1 -2
- package/scripts/common.js +3 -1
package/lib/mixins/connect.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pageArrayFromDict,
|
|
3
|
-
|
|
3
|
+
WEB_CONTENT_BUNDLE_ID,
|
|
4
|
+
appIdsForBundle,
|
|
4
5
|
} from '../utils';
|
|
5
6
|
import events from './events';
|
|
6
7
|
import { timing, util } from '@appium/support';
|
|
@@ -13,10 +14,14 @@ const SELECT_APP_RETRIES = 20;
|
|
|
13
14
|
const SELECT_APP_RETRY_SLEEP_MS = 500;
|
|
14
15
|
const SAFARI_BUNDLE_ID = 'com.apple.mobilesafari';
|
|
15
16
|
const BLANK_PAGE_URL = 'about:blank';
|
|
17
|
+
const WEB_CONTENT_PROCESS_BUNDLE_ID = 'process-com.apple.WebKit.WebContent';
|
|
18
|
+
const SAFARI_VIEW_PROCESS_BUNDLE_ID = 'process-SafariViewService';
|
|
19
|
+
const SAFARI_VIEW_BUNDLE_ID = 'com.apple.SafariViewService';
|
|
20
|
+
const WILDCARD_BUNDLE_ID = '*';
|
|
16
21
|
|
|
17
22
|
/**
|
|
18
23
|
*
|
|
19
|
-
* @this {
|
|
24
|
+
* @this {RemoteDebugger}
|
|
20
25
|
* @returns {Promise<void>}
|
|
21
26
|
*/
|
|
22
27
|
export async function setConnectionKey () {
|
|
@@ -29,7 +34,7 @@ export async function setConnectionKey () {
|
|
|
29
34
|
|
|
30
35
|
/**
|
|
31
36
|
*
|
|
32
|
-
* @this {
|
|
37
|
+
* @this {RemoteDebugger}
|
|
33
38
|
* @param {number} [timeout=APP_CONNECT_TIMEOUT_MS]
|
|
34
39
|
* @returns {Promise<import('@appium/types').StringRecord>}
|
|
35
40
|
*/
|
|
@@ -83,7 +88,7 @@ export async function connect (timeout = APP_CONNECT_TIMEOUT_MS) {
|
|
|
83
88
|
|
|
84
89
|
/**
|
|
85
90
|
*
|
|
86
|
-
* @this {
|
|
91
|
+
* @this {RemoteDebugger}
|
|
87
92
|
* @returns {Promise<void>}
|
|
88
93
|
*/
|
|
89
94
|
export async function disconnect () {
|
|
@@ -96,11 +101,11 @@ export async function disconnect () {
|
|
|
96
101
|
|
|
97
102
|
/**
|
|
98
103
|
*
|
|
99
|
-
* @this {
|
|
104
|
+
* @this {RemoteDebugger}
|
|
100
105
|
* @param {string?} [currentUrl=null]
|
|
101
106
|
* @param {number} [maxTries=SELECT_APP_RETRIES]
|
|
102
107
|
* @param {boolean} [ignoreAboutBlankUrl=false]
|
|
103
|
-
* @returns {Promise<Page[]>}
|
|
108
|
+
* @returns {Promise<import('../types').Page[]>}
|
|
104
109
|
*/
|
|
105
110
|
export async function selectApp (currentUrl = null, maxTries = SELECT_APP_RETRIES, ignoreAboutBlankUrl = false) {
|
|
106
111
|
this.log.debug('Selecting application');
|
|
@@ -124,7 +129,7 @@ export async function selectApp (currentUrl = null, maxTries = SELECT_APP_RETRIE
|
|
|
124
129
|
// translate the dictionary into a useful form, and return to sender
|
|
125
130
|
this.log.debug(`Finally selecting app ${this.appIdKey}`);
|
|
126
131
|
|
|
127
|
-
/** @type {Page[]} */
|
|
132
|
+
/** @type {import('../types').Page[]} */
|
|
128
133
|
const fullPageArray = [];
|
|
129
134
|
for (const [app, info] of _.toPairs(this.appDict)) {
|
|
130
135
|
if (!_.isArray(info.pageArray) || !info.isActive) {
|
|
@@ -150,20 +155,20 @@ export async function selectApp (currentUrl = null, maxTries = SELECT_APP_RETRIE
|
|
|
150
155
|
|
|
151
156
|
/**
|
|
152
157
|
*
|
|
153
|
-
* @this {
|
|
158
|
+
* @this {RemoteDebugger}
|
|
154
159
|
* @param {string?} currentUrl
|
|
155
160
|
* @param {number} maxTries
|
|
156
161
|
* @param {boolean} ignoreAboutBlankUrl
|
|
157
|
-
* @returns {Promise<AppPage>}
|
|
162
|
+
* @returns {Promise<import('../types').AppPage>}
|
|
158
163
|
*/
|
|
159
164
|
export async function searchForApp (currentUrl, maxTries, ignoreAboutBlankUrl) {
|
|
160
165
|
const bundleIds = this.includeSafari && !this.isSafari
|
|
161
166
|
? [this.bundleId, ...this.additionalBundleIds, SAFARI_BUNDLE_ID]
|
|
162
167
|
: [this.bundleId, ...this.additionalBundleIds];
|
|
163
168
|
let retryCount = 0;
|
|
164
|
-
return /** @type {AppPage} */ (await retryInterval(maxTries, SELECT_APP_RETRY_SLEEP_MS, async () => {
|
|
169
|
+
return /** @type {import('../types').AppPage} */ (await retryInterval(maxTries, SELECT_APP_RETRY_SLEEP_MS, async () => {
|
|
165
170
|
logApplicationDictionary.bind(this)();
|
|
166
|
-
const possibleAppIds = getPossibleDebuggerAppKeys(/** @type {string[]} */ (bundleIds)
|
|
171
|
+
const possibleAppIds = getPossibleDebuggerAppKeys.bind(this)(/** @type {string[]} */ (bundleIds));
|
|
167
172
|
this.log.debug(`Trying out the possible app ids: ${possibleAppIds.join(', ')} (try #${retryCount + 1} of ${maxTries})`);
|
|
168
173
|
for (const attemptedAppIdKey of possibleAppIds) {
|
|
169
174
|
try {
|
|
@@ -214,11 +219,11 @@ export async function searchForApp (currentUrl, maxTries, ignoreAboutBlankUrl) {
|
|
|
214
219
|
|
|
215
220
|
/**
|
|
216
221
|
*
|
|
217
|
-
* @this {
|
|
218
|
-
* @param {Record<string, import('../
|
|
222
|
+
* @this {RemoteDebugger}
|
|
223
|
+
* @param {Record<string, import('../types').AppInfo>} appsDict
|
|
219
224
|
* @param {string?} currentUrl
|
|
220
225
|
* @param {boolean} [ignoreAboutBlankUrl]
|
|
221
|
-
* @returns {AppPage?}
|
|
226
|
+
* @returns {import('../types').AppPage?}
|
|
222
227
|
*/
|
|
223
228
|
export function searchForPage (appsDict, currentUrl = null, ignoreAboutBlankUrl = false) {
|
|
224
229
|
for (const appDict of _.values(appsDict)) {
|
|
@@ -241,7 +246,7 @@ export function searchForPage (appsDict, currentUrl = null, ignoreAboutBlankUrl
|
|
|
241
246
|
|
|
242
247
|
/**
|
|
243
248
|
*
|
|
244
|
-
* @this {
|
|
249
|
+
* @this {RemoteDebugger}
|
|
245
250
|
* @param {string|number} appIdKey
|
|
246
251
|
* @param {string|number} pageIdKey
|
|
247
252
|
* @param {boolean} [skipReadyCheck]
|
|
@@ -266,7 +271,7 @@ export async function selectPage (appIdKey, pageIdKey, skipReadyCheck = false) {
|
|
|
266
271
|
}
|
|
267
272
|
|
|
268
273
|
/**
|
|
269
|
-
* @this {
|
|
274
|
+
* @this {RemoteDebugger}
|
|
270
275
|
* @returns {void}
|
|
271
276
|
*/
|
|
272
277
|
function logApplicationDictionary () {
|
|
@@ -292,22 +297,51 @@ function logApplicationDictionary () {
|
|
|
292
297
|
}
|
|
293
298
|
|
|
294
299
|
/**
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
300
|
+
* Find app keys based on assigned bundleIds from appDict
|
|
301
|
+
* When bundleIds includes a wildcard ('*'), returns all appKeys in appDict.
|
|
302
|
+
*
|
|
303
|
+
* @this {RemoteDebugger}
|
|
304
|
+
* @param {string[]} bundleIds
|
|
305
|
+
* @returns {string[]}
|
|
298
306
|
*/
|
|
307
|
+
export function getPossibleDebuggerAppKeys(bundleIds) {
|
|
308
|
+
if (bundleIds.includes(WILDCARD_BUNDLE_ID)) {
|
|
309
|
+
this.log.debug('Skip checking bundle identifiers because the bundleIds includes a wildcard');
|
|
310
|
+
return _.uniq(Object.keys(this.appDict));
|
|
311
|
+
}
|
|
299
312
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
313
|
+
// go through the possible bundle identifiers
|
|
314
|
+
const possibleBundleIds = _.uniq([
|
|
315
|
+
WEB_CONTENT_BUNDLE_ID,
|
|
316
|
+
WEB_CONTENT_PROCESS_BUNDLE_ID,
|
|
317
|
+
SAFARI_VIEW_PROCESS_BUNDLE_ID,
|
|
318
|
+
SAFARI_VIEW_BUNDLE_ID,
|
|
319
|
+
WILDCARD_BUNDLE_ID,
|
|
320
|
+
...bundleIds,
|
|
321
|
+
]);
|
|
322
|
+
this.log.debug(`Checking for bundle identifiers: ${possibleBundleIds.join(', ')}`);
|
|
323
|
+
/** @type {Set<string>} */
|
|
324
|
+
const proxiedAppIds = new Set();
|
|
325
|
+
for (const bundleId of possibleBundleIds) {
|
|
326
|
+
// now we need to determine if we should pick a proxy for this instead
|
|
327
|
+
for (const appId of appIdsForBundle(bundleId, this.appDict)) {
|
|
328
|
+
proxiedAppIds.add(appId);
|
|
329
|
+
this.log.debug(`Found app id key '${appId}' for bundle '${bundleId}'`);
|
|
330
|
+
for (const [key, data] of _.toPairs(this.appDict)) {
|
|
331
|
+
if (data.isProxy && data.hostId === appId) {
|
|
332
|
+
this.log.debug(
|
|
333
|
+
`Found separate bundleId '${data.bundleId}' ` +
|
|
334
|
+
`acting as proxy for '${bundleId}', with app id '${key}'`
|
|
335
|
+
);
|
|
336
|
+
proxiedAppIds.add(key);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return Array.from(proxiedAppIds);
|
|
343
|
+
}
|
|
305
344
|
|
|
306
345
|
/**
|
|
307
|
-
* @typedef {
|
|
308
|
-
* @property {string} url
|
|
309
|
-
* @property {string} title
|
|
310
|
-
* @property {number} id
|
|
311
|
-
* @property {boolean} isKey
|
|
312
|
-
* @property {string} [bundleId]
|
|
346
|
+
* @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
|
|
313
347
|
*/
|
package/lib/mixins/cookies.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
|
-
* @this {
|
|
4
|
+
* @this {RemoteDebugger}
|
|
5
5
|
* @returns {Promise<import('@appium/types').StringRecord>}
|
|
6
6
|
*/
|
|
7
7
|
export async function getCookies () {
|
|
@@ -14,7 +14,7 @@ export async function getCookies () {
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
|
-
* @this {
|
|
17
|
+
* @this {RemoteDebugger}
|
|
18
18
|
* @param {import('@appium/types').StringRecord} cookie
|
|
19
19
|
* @returns {Promise<any>}
|
|
20
20
|
*/
|
|
@@ -29,7 +29,7 @@ export async function setCookie (cookie) {
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
*
|
|
32
|
-
* @this {
|
|
32
|
+
* @this {RemoteDebugger}
|
|
33
33
|
* @param {string} cookieName
|
|
34
34
|
* @param {string} url
|
|
35
35
|
* @returns {Promise<any>}
|
|
@@ -43,3 +43,7 @@ export async function deleteCookie (cookieName, url) {
|
|
|
43
43
|
url,
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
|
|
49
|
+
*/
|
package/lib/mixins/events.js
CHANGED
|
@@ -8,7 +8,7 @@ export const events = {
|
|
|
8
8
|
/**
|
|
9
9
|
* Keep track of the client event listeners so they can be removed
|
|
10
10
|
*
|
|
11
|
-
* @this {
|
|
11
|
+
* @this {RemoteDebugger}
|
|
12
12
|
* @param {string} eventName
|
|
13
13
|
* @param {(event: import('@appium/types').StringRecord) => any} listener
|
|
14
14
|
* @returns {void}
|
|
@@ -20,7 +20,7 @@ export function addClientEventListener (eventName, listener) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* @this {
|
|
23
|
+
* @this {RemoteDebugger}
|
|
24
24
|
* @param {string} eventName
|
|
25
25
|
* @returns {void}
|
|
26
26
|
*/
|
|
@@ -31,3 +31,7 @@ export function removeClientEventListener (eventName) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export default events;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
|
|
37
|
+
*/
|
package/lib/mixins/execute.js
CHANGED
|
@@ -11,6 +11,8 @@ const RPC_RESPONSE_TIMEOUT_MS = 5000;
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Execute a Selenium atom in Safari
|
|
14
|
+
*
|
|
15
|
+
* @this {RemoteDebugger}
|
|
14
16
|
* @param {string} atom Name of Selenium atom (see atoms/ directory)
|
|
15
17
|
* @param {any[]} args Arguments passed to the atom
|
|
16
18
|
* @param {string[]} frames
|
|
@@ -25,7 +27,7 @@ export async function executeAtom (atom, args = [], frames = []) {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
|
-
* @this {
|
|
30
|
+
* @this {RemoteDebugger}
|
|
29
31
|
* @param {string} atom
|
|
30
32
|
* @param {any[]} [args]
|
|
31
33
|
* @param {string[]} [frames]
|
|
@@ -116,7 +118,7 @@ export async function executeAtomAsync (atom, args = [], frames = []) {
|
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
/**
|
|
119
|
-
* @this {
|
|
121
|
+
* @this {RemoteDebugger}
|
|
120
122
|
* @param {string} command
|
|
121
123
|
* @param {boolean} [override]
|
|
122
124
|
* @returns {Promise<any>}
|
|
@@ -150,7 +152,7 @@ export async function execute (command, override) {
|
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
/**
|
|
153
|
-
* @this {
|
|
155
|
+
* @this {RemoteDebugger}
|
|
154
156
|
* @param {string} objectId
|
|
155
157
|
* @param {any} fn
|
|
156
158
|
* @param {any[]} [args]
|
|
@@ -174,3 +176,7 @@ export async function callFunction (objectId, fn, args) {
|
|
|
174
176
|
|
|
175
177
|
return convertResult(res);
|
|
176
178
|
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
|
|
182
|
+
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import events from './events';
|
|
2
2
|
import {
|
|
3
3
|
pageArrayFromDict,
|
|
4
|
-
getDebuggerAppKey,
|
|
5
4
|
appInfoFromDict,
|
|
6
5
|
} from '../utils';
|
|
7
6
|
import _ from 'lodash';
|
|
@@ -13,7 +12,7 @@ import _ from 'lodash';
|
|
|
13
12
|
*/
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
|
-
* @this {
|
|
15
|
+
* @this {RemoteDebugger}
|
|
17
16
|
* @param {Error?} err
|
|
18
17
|
* @param {string} appIdKey
|
|
19
18
|
* @param {Record<string, any>} pageDict
|
|
@@ -56,7 +55,7 @@ export async function onPageChange (err, appIdKey, pageDict) {
|
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
/**
|
|
59
|
-
* @this {
|
|
58
|
+
* @this {RemoteDebugger}
|
|
60
59
|
* @param {Error?} err
|
|
61
60
|
* @param {Record<string, any>} dict
|
|
62
61
|
* @returns {Promise<void>}
|
|
@@ -69,7 +68,7 @@ export async function onAppConnect (err, dict) {
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
/**
|
|
72
|
-
* @this {
|
|
71
|
+
* @this {RemoteDebugger}
|
|
73
72
|
* @param {Error?} err
|
|
74
73
|
* @param {import('@appium/types').StringRecord} dict
|
|
75
74
|
* @returns {void}
|
|
@@ -86,7 +85,7 @@ export function onAppDisconnect (err, dict) {
|
|
|
86
85
|
// if the disconnected app is the one we are connected to, try to find another
|
|
87
86
|
if (this.appIdKey === appIdKey) {
|
|
88
87
|
this.log.debug(`No longer have app id. Attempting to find new one.`);
|
|
89
|
-
this.appIdKey = getDebuggerAppKey(/** @type {string} */ (this.bundleId)
|
|
88
|
+
this.appIdKey = getDebuggerAppKey.bind(this)(/** @type {string} */ (this.bundleId));
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
if (!this.appDict) {
|
|
@@ -98,7 +97,7 @@ export function onAppDisconnect (err, dict) {
|
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
/**
|
|
101
|
-
* @this {
|
|
100
|
+
* @this {RemoteDebugger}
|
|
102
101
|
* @param {Error?} err
|
|
103
102
|
* @param {Record<string, any>} dict
|
|
104
103
|
* @returns {Promise<void>}
|
|
@@ -110,7 +109,7 @@ export async function onAppUpdate (err, dict) {
|
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
/**
|
|
113
|
-
* @this {
|
|
112
|
+
* @this {RemoteDebugger}
|
|
114
113
|
* @param {Error?} err
|
|
115
114
|
* @param {Record<string, any>} drivers
|
|
116
115
|
* @returns {void}
|
|
@@ -121,7 +120,7 @@ export function onConnectedDriverList (err, drivers) {
|
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
/**
|
|
124
|
-
* @this {
|
|
123
|
+
* @this {RemoteDebugger}
|
|
125
124
|
* @param {Error?} err
|
|
126
125
|
* @param {Record<string, any>} state
|
|
127
126
|
* @returns {void}
|
|
@@ -134,7 +133,7 @@ export function onCurrentState (err, state) {
|
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
/**
|
|
137
|
-
* @this {
|
|
136
|
+
* @this {RemoteDebugger}
|
|
138
137
|
* @param {Error?} err
|
|
139
138
|
* @param {Record<string, any>} apps
|
|
140
139
|
* @returns {Promise<void>}
|
|
@@ -159,7 +158,7 @@ export async function onConnectedApplicationList (err, apps) {
|
|
|
159
158
|
|
|
160
159
|
/**
|
|
161
160
|
*
|
|
162
|
-
* @this {
|
|
161
|
+
* @this {RemoteDebugger}
|
|
163
162
|
* @param {import('@appium/types').StringRecord} dict
|
|
164
163
|
* @returns {void}
|
|
165
164
|
*/
|
|
@@ -176,6 +175,47 @@ function updateAppsWithDict (dict) {
|
|
|
176
175
|
|
|
177
176
|
// try to get the app id from our connected apps
|
|
178
177
|
if (!this.appIdKey) {
|
|
179
|
-
this.appIdKey = getDebuggerAppKey(/** @type {string} */ (this.bundleId)
|
|
178
|
+
this.appIdKey = getDebuggerAppKey.bind(this)(/** @type {string} */ (this.bundleId));
|
|
180
179
|
}
|
|
181
180
|
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Given a bundle id, finds the correct remote debugger app that is
|
|
184
|
+
* connected.
|
|
185
|
+
*
|
|
186
|
+
* @this {RemoteDebugger}
|
|
187
|
+
* @param {string} bundleId
|
|
188
|
+
* @returns {string|undefined}
|
|
189
|
+
*/
|
|
190
|
+
export function getDebuggerAppKey (bundleId) {
|
|
191
|
+
let appId;
|
|
192
|
+
for (const [key, data] of _.toPairs(this.appDict)) {
|
|
193
|
+
if (data.bundleId === bundleId) {
|
|
194
|
+
appId = key;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// now we need to determine if we should pick a proxy for this instead
|
|
199
|
+
if (appId) {
|
|
200
|
+
this.log.debug(`Found app id key '${appId}' for bundle '${bundleId}'`);
|
|
201
|
+
let proxyAppId;
|
|
202
|
+
for (const [key, data] of _.toPairs(this.appDict)) {
|
|
203
|
+
if (data.isProxy && data.hostId === appId) {
|
|
204
|
+
this.log.debug(`Found separate bundleId '${data.bundleId}' ` +
|
|
205
|
+
`acting as proxy for '${bundleId}', with app id '${key}'`);
|
|
206
|
+
// set the app id... the last one will be used, so just keep re-assigning
|
|
207
|
+
proxyAppId = key;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (proxyAppId) {
|
|
211
|
+
appId = proxyAppId;
|
|
212
|
+
this.log.debug(`Using proxied app id '${appId}'`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return appId;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
|
|
221
|
+
*/
|
package/lib/mixins/misc.js
CHANGED
|
@@ -5,7 +5,7 @@ const SAFARI_BUNDLE_ID = 'com.apple.mobilesafari';
|
|
|
5
5
|
const GARBAGE_COLLECT_TIMEOUT_MS = 5000;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @this {
|
|
8
|
+
* @this {RemoteDebugger}
|
|
9
9
|
* @returns {Promise<void>}
|
|
10
10
|
*/
|
|
11
11
|
export async function launchSafari () {
|
|
@@ -15,7 +15,7 @@ export async function launchSafari () {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @this {
|
|
18
|
+
* @this {RemoteDebugger}
|
|
19
19
|
* @param {(event: import('@appium/types').StringRecord) => any} fn
|
|
20
20
|
* @returns {Promise<any>}
|
|
21
21
|
*/
|
|
@@ -29,7 +29,7 @@ export async function startTimeline (fn) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @this {
|
|
32
|
+
* @this {RemoteDebugger}
|
|
33
33
|
* @returns {Promise<any>}
|
|
34
34
|
*/
|
|
35
35
|
export async function stopTimeline () {
|
|
@@ -41,7 +41,7 @@ export async function stopTimeline () {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* @this {
|
|
44
|
+
* @this {RemoteDebugger}
|
|
45
45
|
* @param {(event: import('@appium/types').StringRecord) => any} listener
|
|
46
46
|
* @returns {void}
|
|
47
47
|
*/
|
|
@@ -52,7 +52,7 @@ export function startConsole (listener) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* @this {
|
|
55
|
+
* @this {RemoteDebugger}
|
|
56
56
|
* @returns {void}
|
|
57
57
|
*/
|
|
58
58
|
export function stopConsole () {
|
|
@@ -62,7 +62,7 @@ export function stopConsole () {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* @this {
|
|
65
|
+
* @this {RemoteDebugger}
|
|
66
66
|
* @param {(event: import('@appium/types').StringRecord) => any} listener
|
|
67
67
|
* @returns {void}
|
|
68
68
|
*/
|
|
@@ -72,7 +72,7 @@ export function startNetwork (listener) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
* @this {
|
|
75
|
+
* @this {RemoteDebugger}
|
|
76
76
|
* @returns {void}
|
|
77
77
|
*/
|
|
78
78
|
export function stopNetwork () {
|
|
@@ -82,7 +82,7 @@ export function stopNetwork () {
|
|
|
82
82
|
|
|
83
83
|
// Potentially this does not work for mobile safari
|
|
84
84
|
/**
|
|
85
|
-
* @this {
|
|
85
|
+
* @this {RemoteDebugger}
|
|
86
86
|
* @param {string} value
|
|
87
87
|
* @returns {Promise<any>}
|
|
88
88
|
*/
|
|
@@ -96,7 +96,7 @@ export async function overrideUserAgent (value) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
* @this {
|
|
99
|
+
* @this {RemoteDebugger}
|
|
100
100
|
* @param {number} [timeoutMs=GARBAGE_COLLECT_TIMEOUT_MS]
|
|
101
101
|
* @returns {Promise<void>}
|
|
102
102
|
*/
|
|
@@ -126,3 +126,7 @@ export async function garbageCollect (timeoutMs = GARBAGE_COLLECT_TIMEOUT_MS) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
|
|
132
|
+
*/
|
package/lib/mixins/navigate.js
CHANGED
|
@@ -21,7 +21,7 @@ const PAGE_LOAD_STRATEGY = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* @this {
|
|
24
|
+
* @this {RemoteDebugger}
|
|
25
25
|
* @returns {void}
|
|
26
26
|
*/
|
|
27
27
|
export function frameDetached () {
|
|
@@ -29,7 +29,7 @@ export function frameDetached () {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @this {
|
|
32
|
+
* @this {RemoteDebugger}
|
|
33
33
|
* @returns {void}
|
|
34
34
|
*/
|
|
35
35
|
export function cancelPageLoad () {
|
|
@@ -43,7 +43,8 @@ export function cancelPageLoad () {
|
|
|
43
43
|
/**
|
|
44
44
|
* Return if current readState can be handles as page load completes
|
|
45
45
|
* for the given page load strategy.
|
|
46
|
-
*
|
|
46
|
+
*
|
|
47
|
+
* @this {RemoteDebugger}
|
|
47
48
|
* @param {string} readyState
|
|
48
49
|
* @returns {boolean}
|
|
49
50
|
*/
|
|
@@ -63,7 +64,7 @@ export function isPageLoadingCompleted (readyState) {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
|
-
* @this {
|
|
67
|
+
* @this {RemoteDebugger}
|
|
67
68
|
* @param {timing.Timer?} [startPageLoadTimer]
|
|
68
69
|
* @returns {Promise<void>}
|
|
69
70
|
*/
|
|
@@ -132,7 +133,7 @@ export async function waitForDom (startPageLoadTimer) {
|
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
/**
|
|
135
|
-
* @this {
|
|
136
|
+
* @this {RemoteDebugger}
|
|
136
137
|
* @param {number} [timeoutMs]
|
|
137
138
|
* @returns {Promise<boolean>}
|
|
138
139
|
*/
|
|
@@ -156,7 +157,7 @@ export async function checkPageIsReady (timeoutMs) {
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
/**
|
|
159
|
-
* @this {
|
|
160
|
+
* @this {RemoteDebugger}
|
|
160
161
|
* @param {string} url
|
|
161
162
|
* @returns {Promise<void>}
|
|
162
163
|
*/
|
|
@@ -280,3 +281,7 @@ export async function navToUrl (url) {
|
|
|
280
281
|
throw err;
|
|
281
282
|
}
|
|
282
283
|
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
|
|
287
|
+
*/
|
package/lib/mixins/screenshot.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Capture a rect of the page or by default the viewport
|
|
3
|
-
* @this {
|
|
3
|
+
* @this {RemoteDebugger}
|
|
4
4
|
* @param {ScreenshotCaptureOptions} [opts={}] if rect is null capture the whole
|
|
5
5
|
* coordinate system else capture the rect in the given coordinateSystem
|
|
6
6
|
* @returns {Promise<string>} a base64 encoded string of the screenshot
|
|
@@ -32,3 +32,7 @@ export async function captureScreenshot(opts = {}) {
|
|
|
32
32
|
* @property {import('@appium/types').Rect | null} [rect=null]
|
|
33
33
|
* @property {"Viewport" | "Page"} [coordinateSystem="Viewport"]
|
|
34
34
|
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
|
|
38
|
+
*/
|
package/lib/remote-debugger.js
CHANGED
|
@@ -24,9 +24,9 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
24
24
|
// properties
|
|
25
25
|
/** @type {string[]|undefined} */
|
|
26
26
|
_skippedApps;
|
|
27
|
-
/** @type {
|
|
27
|
+
/** @type {import('@appium/types').StringRecord<Function[]>} */
|
|
28
28
|
_clientEventListeners;
|
|
29
|
-
/** @type {
|
|
29
|
+
/** @type {import('./types').AppDict} */
|
|
30
30
|
appDict;
|
|
31
31
|
/** @type {string|null|undefined} */
|
|
32
32
|
appIdKey;
|
package/lib/types.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { StringRecord } from '@appium/types';
|
|
2
|
+
import type B from 'bluebird';
|
|
3
|
+
|
|
4
|
+
export interface DeferredPromise {
|
|
5
|
+
promise: B<any>;
|
|
6
|
+
resolve: (...args: any[]) => void;
|
|
7
|
+
reject: (err?: Error) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface AppInfo {
|
|
11
|
+
id: string;
|
|
12
|
+
isProxy: boolean;
|
|
13
|
+
name: string;
|
|
14
|
+
bundleId: string;
|
|
15
|
+
hostId?: string;
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
isAutomationEnabled: boolean | string;
|
|
18
|
+
pageArray?: Page[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AppPage {
|
|
22
|
+
appIdKey: string;
|
|
23
|
+
pageDict: Page;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface App {
|
|
27
|
+
id: string;
|
|
28
|
+
bundleId: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Page {
|
|
32
|
+
url: string;
|
|
33
|
+
title: string;
|
|
34
|
+
id: number | string;
|
|
35
|
+
isKey: boolean;
|
|
36
|
+
bundleId?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type AppDict = StringRecord<AppInfo>;
|