appium-android-driver 5.14.7 → 6.0.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 +7 -0
- package/build/lib/commands/actions.d.ts +6 -224
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +306 -405
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/alert.d.ts +7 -9
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +24 -18
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +7 -313
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +135 -293
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/context.d.ts +8 -92
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +381 -439
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/element.d.ts +8 -35
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +153 -136
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/emu-console.d.ts +6 -48
- package/build/lib/commands/emu-console.d.ts.map +1 -1
- package/build/lib/commands/emu-console.js +19 -34
- package/build/lib/commands/emu-console.js.map +1 -1
- package/build/lib/commands/execute.d.ts +6 -5
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +77 -66
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts +7 -128
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js +183 -219
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/find.d.ts +8 -12
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +19 -23
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +9 -132
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +281 -312
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/ime.d.ts +7 -10
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js +47 -35
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/index.d.ts +27 -2
- package/build/lib/commands/index.d.ts.map +1 -1
- package/build/lib/commands/index.js +41 -19
- package/build/lib/commands/index.js.map +1 -1
- package/build/lib/commands/intent.d.ts +7 -417
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +104 -216
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +6 -5
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +16 -8
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/log.d.ts +7 -44
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +146 -108
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/media-projection.d.ts +7 -143
- package/build/lib/commands/media-projection.d.ts.map +1 -1
- package/build/lib/commands/media-projection.js +113 -140
- package/build/lib/commands/media-projection.js.map +1 -1
- package/build/lib/commands/mixins.d.ts +740 -0
- package/build/lib/commands/mixins.d.ts.map +1 -0
- package/build/lib/commands/mixins.js +19 -0
- package/build/lib/commands/mixins.js.map +1 -0
- package/build/lib/commands/network.d.ts +7 -138
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +212 -254
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/performance.d.ts +24 -70
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +144 -100
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +8 -92
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +75 -87
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +7 -193
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +151 -182
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/shell.d.ts +7 -7
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/shell.js +40 -33
- package/build/lib/commands/shell.js.map +1 -1
- package/build/lib/commands/streamscreen.d.ts +9 -103
- package/build/lib/commands/streamscreen.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js +261 -218
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts +22 -90
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +76 -74
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/touch.d.ts +10 -29
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +301 -285
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/commands/types.d.ts +978 -0
- package/build/lib/commands/types.d.ts.map +1 -0
- package/build/lib/commands/types.js +3 -0
- package/build/lib/commands/types.js.map +1 -0
- package/build/lib/constraints.d.ts +291 -0
- package/build/lib/constraints.d.ts.map +1 -0
- package/build/lib/{desired-caps.js → constraints.js} +103 -102
- package/build/lib/constraints.js.map +1 -0
- package/build/lib/driver.d.ts +68 -37
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +123 -80
- package/build/lib/driver.js.map +1 -1
- package/build/lib/helpers/android.d.ts +164 -0
- package/build/lib/helpers/android.d.ts.map +1 -0
- package/build/lib/helpers/android.js +819 -0
- package/build/lib/helpers/android.js.map +1 -0
- package/build/lib/helpers/index.d.ts +7 -0
- package/build/lib/helpers/index.d.ts.map +1 -0
- package/build/lib/helpers/index.js +29 -0
- package/build/lib/helpers/index.js.map +1 -0
- package/build/lib/helpers/types.d.ts +121 -0
- package/build/lib/helpers/types.d.ts.map +1 -0
- package/build/lib/helpers/types.js +3 -0
- package/build/lib/helpers/types.js.map +1 -0
- package/build/lib/helpers/unlock.d.ts +32 -0
- package/build/lib/helpers/unlock.d.ts.map +1 -0
- package/build/lib/helpers/unlock.js +273 -0
- package/build/lib/helpers/unlock.js.map +1 -0
- package/build/lib/helpers/webview.d.ts +74 -0
- package/build/lib/helpers/webview.d.ts.map +1 -0
- package/build/lib/helpers/webview.js +421 -0
- package/build/lib/helpers/webview.js.map +1 -0
- package/build/lib/index.d.ts +9 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +37 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/method-map.d.ts +0 -8
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/method-map.js +63 -74
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/stubs.d.ts +0 -1
- package/build/lib/stubs.d.ts.map +1 -1
- package/build/lib/stubs.js +1 -0
- package/build/lib/stubs.js.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/lib/commands/actions.js +351 -464
- package/lib/commands/alert.js +27 -17
- package/lib/commands/app-management.js +156 -314
- package/lib/commands/context.js +457 -441
- package/lib/commands/element.js +201 -157
- package/lib/commands/emu-console.js +25 -45
- package/lib/commands/execute.js +106 -90
- package/lib/commands/file-actions.js +222 -240
- package/lib/commands/find.ts +103 -0
- package/lib/commands/general.js +327 -339
- package/lib/commands/ime.js +50 -34
- package/lib/commands/{index.js → index.ts} +20 -24
- package/lib/commands/intent.js +108 -249
- package/lib/commands/keyboard.js +20 -8
- package/lib/commands/log.js +172 -116
- package/lib/commands/media-projection.js +134 -161
- package/lib/commands/mixins.ts +966 -0
- package/lib/commands/network.js +252 -281
- package/lib/commands/performance.js +203 -132
- package/lib/commands/permissions.js +108 -109
- package/lib/commands/recordscreen.js +212 -209
- package/lib/commands/shell.js +51 -40
- package/lib/commands/streamscreen.js +355 -289
- package/lib/commands/system-bars.js +92 -83
- package/lib/commands/touch.js +357 -294
- package/lib/commands/types.ts +1097 -0
- package/lib/{desired-caps.js → constraints.ts} +106 -103
- package/lib/{driver.js → driver.ts} +278 -132
- package/lib/helpers/android.ts +1143 -0
- package/lib/helpers/index.ts +6 -0
- package/lib/helpers/types.ts +134 -0
- package/lib/helpers/unlock.ts +329 -0
- package/lib/helpers/webview.ts +582 -0
- package/lib/index.ts +18 -0
- package/lib/method-map.js +87 -98
- package/lib/stubs.ts +0 -1
- package/package.json +26 -19
- package/build/index.js +0 -51
- package/build/lib/android-helpers.d.ts +0 -136
- package/build/lib/android-helpers.d.ts.map +0 -1
- package/build/lib/android-helpers.js +0 -855
- package/build/lib/android-helpers.js.map +0 -1
- package/build/lib/commands/coverage.d.ts +0 -5
- package/build/lib/commands/coverage.d.ts.map +0 -1
- package/build/lib/commands/coverage.js +0 -19
- package/build/lib/commands/coverage.js.map +0 -1
- package/build/lib/desired-caps.d.ts +0 -353
- package/build/lib/desired-caps.d.ts.map +0 -1
- package/build/lib/desired-caps.js.map +0 -1
- package/build/lib/unlock-helpers.d.ts +0 -38
- package/build/lib/unlock-helpers.d.ts.map +0 -1
- package/build/lib/unlock-helpers.js +0 -266
- package/build/lib/unlock-helpers.js.map +0 -1
- package/build/lib/webview-helpers.d.ts +0 -224
- package/build/lib/webview-helpers.d.ts.map +0 -1
- package/build/lib/webview-helpers.js +0 -528
- package/build/lib/webview-helpers.js.map +0 -1
- package/index.js +0 -24
- package/lib/android-helpers.js +0 -983
- package/lib/commands/coverage.js +0 -18
- package/lib/commands/find.js +0 -82
- package/lib/unlock-helpers.js +0 -278
- package/lib/webview-helpers.js +0 -602
|
@@ -1,266 +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.FINGERPRINT_UNLOCK = exports.PATTERN_UNLOCK = exports.PASSWORD_UNLOCK = exports.PIN_UNLOCK_KEY_EVENT = exports.PIN_UNLOCK = exports.helpers = void 0;
|
|
7
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
8
|
-
const asyncbox_1 = require("asyncbox");
|
|
9
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
-
const support_1 = require("@appium/support");
|
|
11
|
-
const PIN_UNLOCK = 'pin';
|
|
12
|
-
exports.PIN_UNLOCK = PIN_UNLOCK;
|
|
13
|
-
const PIN_UNLOCK_KEY_EVENT = 'pinWithKeyEvent';
|
|
14
|
-
exports.PIN_UNLOCK_KEY_EVENT = PIN_UNLOCK_KEY_EVENT;
|
|
15
|
-
const PASSWORD_UNLOCK = 'password';
|
|
16
|
-
exports.PASSWORD_UNLOCK = PASSWORD_UNLOCK;
|
|
17
|
-
const PATTERN_UNLOCK = 'pattern';
|
|
18
|
-
exports.PATTERN_UNLOCK = PATTERN_UNLOCK;
|
|
19
|
-
const FINGERPRINT_UNLOCK = 'fingerprint';
|
|
20
|
-
exports.FINGERPRINT_UNLOCK = FINGERPRINT_UNLOCK;
|
|
21
|
-
const UNLOCK_TYPES = [
|
|
22
|
-
PIN_UNLOCK, PIN_UNLOCK_KEY_EVENT, PASSWORD_UNLOCK,
|
|
23
|
-
PATTERN_UNLOCK, FINGERPRINT_UNLOCK
|
|
24
|
-
];
|
|
25
|
-
const KEYCODE_NUMPAD_ENTER = 66;
|
|
26
|
-
const UNLOCK_WAIT_TIME = 100;
|
|
27
|
-
const INPUT_KEYS_WAIT_TIME = 100;
|
|
28
|
-
const NUMBER_ZERO_KEYCODE = 7;
|
|
29
|
-
exports.helpers = {};
|
|
30
|
-
exports.helpers.validateUnlockCapabilities = function validateUnlockCapabilities(caps = {}) {
|
|
31
|
-
const { unlockKey, unlockType, } = caps;
|
|
32
|
-
if (lodash_1.default.isNil(unlockKey) || unlockKey === '') {
|
|
33
|
-
throw new Error('A non-empty unlock key value must be provided');
|
|
34
|
-
}
|
|
35
|
-
if ([PIN_UNLOCK, PIN_UNLOCK_KEY_EVENT, FINGERPRINT_UNLOCK].includes(unlockType)) {
|
|
36
|
-
if (!/^[0-9]+$/.test(lodash_1.default.trim(unlockKey))) {
|
|
37
|
-
throw new Error(`Unlock key value '${unlockKey}' must only consist of digits`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else if (unlockType === PATTERN_UNLOCK) {
|
|
41
|
-
if (!/^[1-9]{2,9}$/.test(lodash_1.default.trim(unlockKey))) {
|
|
42
|
-
throw new Error(`Unlock key value '${unlockKey}' must only include from two to nine digits in range 1..9`);
|
|
43
|
-
}
|
|
44
|
-
if (/([1-9]).*?\1/.test(lodash_1.default.trim(unlockKey))) {
|
|
45
|
-
throw new Error(`Unlock key value '${unlockKey}' must define a valid pattern where repeats are not allowed`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else if (unlockType === PASSWORD_UNLOCK) {
|
|
49
|
-
// Dont trim password key, you can use blank spaces in your android password
|
|
50
|
-
// ¯\_(ツ)_/¯
|
|
51
|
-
if (!/.{4,}/g.test(unlockKey)) {
|
|
52
|
-
throw new Error(`The minimum allowed length of unlock key value '${unlockKey}' is 4 characters`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
throw new Error(`Invalid unlock type '${unlockType}'. ` +
|
|
57
|
-
`Only the following unlock types are supported: ${UNLOCK_TYPES}`);
|
|
58
|
-
}
|
|
59
|
-
return caps;
|
|
60
|
-
};
|
|
61
|
-
exports.helpers.fastUnlock = async function fastUnlock(adb, opts = {}) {
|
|
62
|
-
const { credential, credentialType, } = opts;
|
|
63
|
-
logger_1.default.info(`Unlocking the device via ADB using ${credentialType} credential '${credential}'`);
|
|
64
|
-
const wasLockEnabled = await adb.isLockEnabled();
|
|
65
|
-
if (wasLockEnabled) {
|
|
66
|
-
await adb.clearLockCredential(credential);
|
|
67
|
-
// not sure why, but the device's screen still remains locked
|
|
68
|
-
// if a preliminary wake up cycle has not been performed
|
|
69
|
-
await adb.cycleWakeUp();
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
logger_1.default.info('No active lock has been detected. Proceeding to the keyguard dismissal');
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
await adb.dismissKeyguard();
|
|
76
|
-
}
|
|
77
|
-
finally {
|
|
78
|
-
if (wasLockEnabled) {
|
|
79
|
-
await adb.setLockCredential(credentialType, credential);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
exports.helpers.encodePassword = function encodePassword(key) {
|
|
84
|
-
return `${key}`.replace(/\s/ig, '%s');
|
|
85
|
-
};
|
|
86
|
-
exports.helpers.stringKeyToArr = function stringKeyToArr(key) {
|
|
87
|
-
return `${key}`.trim().replace(/\s+/g, '').split(/\s*/);
|
|
88
|
-
};
|
|
89
|
-
exports.helpers.fingerprintUnlock = async function fingerprintUnlock(adb, driver, capabilities) {
|
|
90
|
-
if (await adb.getApiLevel() < 23) {
|
|
91
|
-
throw new Error('Fingerprint unlock only works for Android 6+ emulators');
|
|
92
|
-
}
|
|
93
|
-
await adb.fingerprint(capabilities.unlockKey);
|
|
94
|
-
await (0, asyncbox_1.sleep)(UNLOCK_WAIT_TIME);
|
|
95
|
-
};
|
|
96
|
-
exports.helpers.pinUnlock = async function pinUnlock(adb, driver, capabilities) {
|
|
97
|
-
logger_1.default.info(`Trying to unlock device using pin ${capabilities.unlockKey}`);
|
|
98
|
-
await adb.dismissKeyguard();
|
|
99
|
-
const keys = exports.helpers.stringKeyToArr(capabilities.unlockKey);
|
|
100
|
-
if (await adb.getApiLevel() >= 21) {
|
|
101
|
-
const els = await driver.findElOrEls('id', 'com.android.systemui:id/digit_text', true);
|
|
102
|
-
if (lodash_1.default.isEmpty(els)) {
|
|
103
|
-
// fallback to pin with key event
|
|
104
|
-
return await exports.helpers.pinUnlockWithKeyEvent(adb, driver, capabilities);
|
|
105
|
-
}
|
|
106
|
-
const pins = {};
|
|
107
|
-
for (const el of els) {
|
|
108
|
-
const text = await driver.getAttribute('text', support_1.util.unwrapElement(el));
|
|
109
|
-
pins[text] = el;
|
|
110
|
-
}
|
|
111
|
-
for (const pin of keys) {
|
|
112
|
-
const el = pins[pin];
|
|
113
|
-
await driver.click(support_1.util.unwrapElement(el));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
for (const pin of keys) {
|
|
118
|
-
const el = await driver.findElOrEls('id', `com.android.keyguard:id/key${pin}`, false);
|
|
119
|
-
if (el === null) {
|
|
120
|
-
// fallback to pin with key event
|
|
121
|
-
return await exports.helpers.pinUnlockWithKeyEvent(adb, driver, capabilities);
|
|
122
|
-
}
|
|
123
|
-
await driver.click(support_1.util.unwrapElement(el));
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
await waitForUnlock(adb);
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Wait for the display to be unlocked.
|
|
130
|
-
* Some devices automatically accept typed 'pin' and 'password' code
|
|
131
|
-
* without pressing the Enter key. But some devices need it.
|
|
132
|
-
* This method waits a few seconds first for such automatic acceptance case.
|
|
133
|
-
* If the device is still locked, then this method will try to send
|
|
134
|
-
* the enter key code.
|
|
135
|
-
*
|
|
136
|
-
* @param {ADB} adb The instance of ADB
|
|
137
|
-
*/
|
|
138
|
-
async function waitForUnlock(adb) {
|
|
139
|
-
await (0, asyncbox_1.sleep)(UNLOCK_WAIT_TIME);
|
|
140
|
-
if (!await adb.isScreenLocked()) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
await adb.keyevent(KEYCODE_NUMPAD_ENTER);
|
|
144
|
-
await (0, asyncbox_1.sleep)(UNLOCK_WAIT_TIME);
|
|
145
|
-
}
|
|
146
|
-
exports.helpers.pinUnlockWithKeyEvent = async function pinUnlockWithKeyEvent(adb, driver, capabilities) {
|
|
147
|
-
logger_1.default.info(`Trying to unlock device using pin with keycode ${capabilities.unlockKey}`);
|
|
148
|
-
await adb.dismissKeyguard();
|
|
149
|
-
const keys = exports.helpers.stringKeyToArr(capabilities.unlockKey);
|
|
150
|
-
// Some device does not have system key ids like 'com.android.keyguard:id/key'
|
|
151
|
-
// Then, sending keyevents are more reliable to unlock the screen.
|
|
152
|
-
for (const pin of keys) {
|
|
153
|
-
// 'pin' is number (0-9) in string.
|
|
154
|
-
// Number '0' is keycode '7'. number '9' is keycode '16'.
|
|
155
|
-
await adb.shell(['input', 'keyevent', parseInt(pin, 10) + NUMBER_ZERO_KEYCODE]);
|
|
156
|
-
}
|
|
157
|
-
await waitForUnlock(adb, driver);
|
|
158
|
-
};
|
|
159
|
-
exports.helpers.passwordUnlock = async function passwordUnlock(adb, driver, capabilities) {
|
|
160
|
-
const { unlockKey } = capabilities;
|
|
161
|
-
logger_1.default.info(`Trying to unlock device using password ${unlockKey}`);
|
|
162
|
-
await adb.dismissKeyguard();
|
|
163
|
-
// Replace blank spaces with %s
|
|
164
|
-
const key = exports.helpers.encodePassword(unlockKey);
|
|
165
|
-
// Why adb ? It was less flaky
|
|
166
|
-
await adb.shell(['input', 'text', key]);
|
|
167
|
-
// Why sleeps ? Avoid some flakyness waiting for the input to receive the keys
|
|
168
|
-
await (0, asyncbox_1.sleep)(INPUT_KEYS_WAIT_TIME);
|
|
169
|
-
await adb.shell(['input', 'keyevent', KEYCODE_NUMPAD_ENTER]);
|
|
170
|
-
// Waits a bit for the device to be unlocked
|
|
171
|
-
await waitForUnlock(adb, driver);
|
|
172
|
-
};
|
|
173
|
-
exports.helpers.getPatternKeyPosition = function getPatternKeyPosition(key, initPos, piece) {
|
|
174
|
-
/*
|
|
175
|
-
How the math works:
|
|
176
|
-
We have 9 buttons divided in 3 columns and 3 rows inside the lockPatternView,
|
|
177
|
-
every button has a position on the screen corresponding to the lockPatternView since
|
|
178
|
-
it is the parent view right at the middle of each column or row.
|
|
179
|
-
*/
|
|
180
|
-
const cols = 3;
|
|
181
|
-
const pins = 9;
|
|
182
|
-
const xPos = (key, x, piece) => Math.round(x + ((key % cols) || cols) * piece - piece / 2);
|
|
183
|
-
const yPos = (key, y, piece) => Math.round(y + (Math.ceil(((key % pins) || pins) / cols) * piece - piece / 2));
|
|
184
|
-
return {
|
|
185
|
-
x: xPos(key, initPos.x, piece),
|
|
186
|
-
y: yPos(key, initPos.y, piece)
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
exports.helpers.getPatternActions = function getPatternActions(keys, initPos, piece) {
|
|
190
|
-
const actions = [];
|
|
191
|
-
let lastPos;
|
|
192
|
-
for (let key of keys) {
|
|
193
|
-
const keyPos = exports.helpers.getPatternKeyPosition(key, initPos, piece);
|
|
194
|
-
if (key === keys[0]) {
|
|
195
|
-
actions.push({ action: 'press', options: { element: null, x: keyPos.x, y: keyPos.y } });
|
|
196
|
-
lastPos = keyPos;
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
const moveTo = { x: 0, y: 0 };
|
|
200
|
-
const diffX = keyPos.x - lastPos.x;
|
|
201
|
-
if (diffX > 0) {
|
|
202
|
-
moveTo.x = piece;
|
|
203
|
-
if (Math.abs(diffX) > piece) {
|
|
204
|
-
moveTo.x += piece;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
else if (diffX < 0) {
|
|
208
|
-
moveTo.x = -1 * piece;
|
|
209
|
-
if (Math.abs(diffX) > piece) {
|
|
210
|
-
moveTo.x -= piece;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
const diffY = keyPos.y - lastPos.y;
|
|
214
|
-
if (diffY > 0) {
|
|
215
|
-
moveTo.y = piece;
|
|
216
|
-
if (Math.abs(diffY) > piece) {
|
|
217
|
-
moveTo.y += piece;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
else if (diffY < 0) {
|
|
221
|
-
moveTo.y = -1 * piece;
|
|
222
|
-
if (Math.abs(diffY) > piece) {
|
|
223
|
-
moveTo.y -= piece;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
actions.push({
|
|
227
|
-
action: 'moveTo',
|
|
228
|
-
options: { element: null, x: moveTo.x + lastPos.x, y: moveTo.y + lastPos.y }
|
|
229
|
-
});
|
|
230
|
-
lastPos = keyPos;
|
|
231
|
-
}
|
|
232
|
-
actions.push({ action: 'release' });
|
|
233
|
-
return actions;
|
|
234
|
-
};
|
|
235
|
-
exports.helpers.patternUnlock = async function patternUnlock(adb, driver, capabilities) {
|
|
236
|
-
const { unlockKey } = capabilities;
|
|
237
|
-
logger_1.default.info(`Trying to unlock device using pattern ${unlockKey}`);
|
|
238
|
-
await adb.dismissKeyguard();
|
|
239
|
-
const keys = exports.helpers.stringKeyToArr(unlockKey);
|
|
240
|
-
/* We set the device pattern buttons as number of a regular phone
|
|
241
|
-
* | • • • | | 1 2 3 |
|
|
242
|
-
* | • • • | --> | 4 5 6 |
|
|
243
|
-
* | • • • | | 7 8 9 |
|
|
244
|
-
|
|
245
|
-
The pattern view buttons are not seeing by the uiautomator since they are
|
|
246
|
-
included inside a FrameLayout, so we are going to try clicking on the buttons
|
|
247
|
-
using the parent view bounds and math.
|
|
248
|
-
*/
|
|
249
|
-
const apiLevel = await adb.getApiLevel();
|
|
250
|
-
const el = await driver.findElOrEls('id', `com.android.${apiLevel >= 21 ? 'systemui' : 'keyguard'}:id/lockPatternView`, false);
|
|
251
|
-
const initPos = await driver.getLocation(support_1.util.unwrapElement(el));
|
|
252
|
-
const size = await driver.getSize(support_1.util.unwrapElement(el));
|
|
253
|
-
// Get actions to perform
|
|
254
|
-
const actions = exports.helpers.getPatternActions(keys, initPos, size.width / 3);
|
|
255
|
-
// Perform gesture
|
|
256
|
-
await driver.performTouch(actions);
|
|
257
|
-
// Waits a bit for the device to be unlocked
|
|
258
|
-
await (0, asyncbox_1.sleep)(UNLOCK_WAIT_TIME);
|
|
259
|
-
};
|
|
260
|
-
exports.helpers.PIN_UNLOCK = PIN_UNLOCK;
|
|
261
|
-
exports.helpers.PIN_UNLOCK_KEY_EVENT = PIN_UNLOCK_KEY_EVENT;
|
|
262
|
-
exports.helpers.PASSWORD_UNLOCK = PASSWORD_UNLOCK;
|
|
263
|
-
exports.helpers.PATTERN_UNLOCK = PATTERN_UNLOCK;
|
|
264
|
-
exports.helpers.FINGERPRINT_UNLOCK = FINGERPRINT_UNLOCK;
|
|
265
|
-
exports.default = exports.helpers;
|
|
266
|
-
//# sourceMappingURL=unlock-helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unlock-helpers.js","sourceRoot":"","sources":["../../lib/unlock-helpers.js"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,uCAAiC;AACjC,oDAAuB;AACvB,6CAAuC;AAEvC,MAAM,UAAU,GAAG,KAAK,CAAC;AA6QvB,gCAAU;AA5QZ,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AA4QjC,oDAAoB;AA3QlC,MAAM,eAAe,GAAG,UAAU,CAAC;AA2QC,0CAAe;AA1QnD,MAAM,cAAc,GAAG,SAAS,CAAC;AA0QoB,wCAAc;AAzQnE,MAAM,kBAAkB,GAAG,aAAa,CAAC;AA0QvC,gDAAkB;AAzQpB,MAAM,YAAY,GAAG;IACnB,UAAU,EAAE,oBAAoB,EAAE,eAAe;IACjD,cAAc,EAAE,kBAAkB;CACnC,CAAC;AACF,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAEjB,QAAA,OAAO,GAAG,EAAE,CAAC;AAE1B,eAAO,CAAC,0BAA0B,GAAG,SAAS,0BAA0B,CAAE,IAAI,GAAG,EAAE;IACjF,MAAM,EACJ,SAAS,EACT,UAAU,GACX,GAAG,IAAI,CAAC;IACT,IAAI,gBAAC,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,SAAS,KAAK,EAAE,EAAE;QAC1C,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAClE;IAED,IAAI,CAAC,UAAU,EAAE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AQ,GAAG,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC;IACzC,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,EACtC,eAAe,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,qBAAqB,EAC5E,KAAK,CACN,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,cAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;IACjE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,yBAAyB;IACzB,MAAM,OAAO,GAAG,eAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACzE,kBAAkB;IAClB,MAAM,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACnC,4CAA4C;IAC5C,MAAM,IAAA,gBAAK,EAAC,gBAAgB,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,eAAO,CAAC,UAAU,GAAG,UAAU,CAAC;AAChC,eAAO,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;AACpD,eAAO,CAAC,eAAe,GAAG,eAAe,CAAC;AAC1C,eAAO,CAAC,cAAc,GAAG,cAAc,CAAC;AACxC,eAAO,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAMhD,kBAAe,eAAO,CAAC"}
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
export default helpers;
|
|
2
|
-
export type WebviewProc = {
|
|
3
|
-
/**
|
|
4
|
-
* - The webview process name (as returned by
|
|
5
|
-
* getPotentialWebviewProcs
|
|
6
|
-
*/
|
|
7
|
-
proc: string;
|
|
8
|
-
/**
|
|
9
|
-
* - The actual webview context name
|
|
10
|
-
*/
|
|
11
|
-
webview: string;
|
|
12
|
-
};
|
|
13
|
-
export type WebviewProps = {
|
|
14
|
-
/**
|
|
15
|
-
* The name of the Devtools Unix socket
|
|
16
|
-
*/
|
|
17
|
-
proc: string;
|
|
18
|
-
/**
|
|
19
|
-
* The web view alias. Looks like `WEBVIEW_`
|
|
20
|
-
* prefix plus PID or package name
|
|
21
|
-
*/
|
|
22
|
-
webview: string;
|
|
23
|
-
/**
|
|
24
|
-
* Webview information as it is retrieved by
|
|
25
|
-
* /json/version CDP endpoint
|
|
26
|
-
*/
|
|
27
|
-
info: any | null;
|
|
28
|
-
/**
|
|
29
|
-
* Webview pages list as it is retrieved by
|
|
30
|
-
* /json/list CDP endpoint
|
|
31
|
-
*/
|
|
32
|
-
pages: Array<any> | null;
|
|
33
|
-
};
|
|
34
|
-
export type DetailCollectionOptions = {
|
|
35
|
-
/**
|
|
36
|
-
* The starting port to use for webview page
|
|
37
|
-
* presence check (if not the default of 9222).
|
|
38
|
-
*/
|
|
39
|
-
webviewDevtoolsPort: (string | number) | null;
|
|
40
|
-
/**
|
|
41
|
-
* Whether to check for webview
|
|
42
|
-
* pages presence
|
|
43
|
-
*/
|
|
44
|
-
ensureWebviewsHavePages: boolean | null;
|
|
45
|
-
/**
|
|
46
|
-
* Whether to collect
|
|
47
|
-
* web view details and send them to Chromedriver constructor, so it could
|
|
48
|
-
* select a binary more precisely based on this info.
|
|
49
|
-
*/
|
|
50
|
-
enableWebviewDetailsCollection: boolean;
|
|
51
|
-
};
|
|
52
|
-
export type GetWebviewsOpts = {
|
|
53
|
-
/**
|
|
54
|
-
* [null] - device socket name
|
|
55
|
-
*/
|
|
56
|
-
androidDeviceSocket: string;
|
|
57
|
-
/**
|
|
58
|
-
* [true] - whether to check for webview
|
|
59
|
-
* page presence
|
|
60
|
-
*/
|
|
61
|
-
ensureWebviewsHavePages: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* [9222] - port to use for webview page
|
|
64
|
-
* presence check.
|
|
65
|
-
*/
|
|
66
|
-
webviewDevtoolsPort: number;
|
|
67
|
-
/**
|
|
68
|
-
* [true] - whether to collect
|
|
69
|
-
* web view details and send them to Chromedriver constructor, so it could
|
|
70
|
-
* select a binary more precisely based on this info.
|
|
71
|
-
*/
|
|
72
|
-
enableWebviewDetailsCollection: boolean;
|
|
73
|
-
};
|
|
74
|
-
export type WebviewsMapping = {
|
|
75
|
-
/**
|
|
76
|
-
* See note on WebviewProps
|
|
77
|
-
*/
|
|
78
|
-
proc: string;
|
|
79
|
-
/**
|
|
80
|
-
* See note on WebviewProps
|
|
81
|
-
*/
|
|
82
|
-
webview: string;
|
|
83
|
-
/**
|
|
84
|
-
* See note on WebviewProps
|
|
85
|
-
*/
|
|
86
|
-
info: any | null;
|
|
87
|
-
/**
|
|
88
|
-
* See note on WebviewProps
|
|
89
|
-
*/
|
|
90
|
-
pages: Array<any> | null;
|
|
91
|
-
};
|
|
92
|
-
export type ProcessInfo = {
|
|
93
|
-
/**
|
|
94
|
-
* The process name
|
|
95
|
-
*/
|
|
96
|
-
name: string;
|
|
97
|
-
/**
|
|
98
|
-
* The process id (if could be retrieved)
|
|
99
|
-
*/
|
|
100
|
-
id: string | null;
|
|
101
|
-
};
|
|
102
|
-
export type WebViewDetails = {
|
|
103
|
-
/**
|
|
104
|
-
* - Web view process details
|
|
105
|
-
*/
|
|
106
|
-
process: ProcessInfo | null;
|
|
107
|
-
/**
|
|
108
|
-
* - Web view details as returned by /json/version CDP endpoint, for example:
|
|
109
|
-
* {
|
|
110
|
-
* "Browser": "Chrome/72.0.3601.0",
|
|
111
|
-
* "Protocol-Version": "1.3",
|
|
112
|
-
* "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3601.0 Safari/537.36",
|
|
113
|
-
* "V8-Version": "7.2.233",
|
|
114
|
-
* "WebKit-Version": "537.36 (@cfede9db1d154de0468cb0538479f34c0755a0f4)",
|
|
115
|
-
* "webSocketDebuggerUrl": "ws://localhost:9222/devtools/browser/b0b8a4fb-bb17-4359-9533-a8d9f3908bd8"
|
|
116
|
-
* }
|
|
117
|
-
*/
|
|
118
|
-
info: any;
|
|
119
|
-
};
|
|
120
|
-
export namespace helpers {
|
|
121
|
-
/**
|
|
122
|
-
* Take a webview name like WEBVIEW_4296 and use 'adb shell ps' to figure out
|
|
123
|
-
* which app package is associated with that webview. One of the reasons we
|
|
124
|
-
* want to do this is to make sure we're listing webviews for the actual AUT,
|
|
125
|
-
* not some other running app
|
|
126
|
-
*
|
|
127
|
-
* @param {object} adb - an ADB instance
|
|
128
|
-
* @param {string} webview - a webview process name
|
|
129
|
-
*
|
|
130
|
-
* @returns {string} - the package name of the app running the webview
|
|
131
|
-
* @throws {Error} If there was a failure while retrieving the process name
|
|
132
|
-
*/
|
|
133
|
-
function procFromWebview(adb: any, webview: string): string;
|
|
134
|
-
/**
|
|
135
|
-
* Parse webview names for getContexts
|
|
136
|
-
*
|
|
137
|
-
* @param {Array<WebviewsMapping>} webviewsMapping See note on getWebViewsMapping
|
|
138
|
-
* @param {GetWebviewsOpts} opts See note on getWebViewsMapping
|
|
139
|
-
* @return {Array.<string>} - a list of webview names
|
|
140
|
-
*/
|
|
141
|
-
function parseWebviewNames(webviewsMapping: WebviewsMapping[], { ensureWebviewsHavePages, isChromeSession }?: GetWebviewsOpts): string[];
|
|
142
|
-
/**
|
|
143
|
-
* @typedef {Object} GetWebviewsOpts
|
|
144
|
-
* @property {string} androidDeviceSocket [null] - device socket name
|
|
145
|
-
* @property {boolean} ensureWebviewsHavePages [true] - whether to check for webview
|
|
146
|
-
* page presence
|
|
147
|
-
* @property {number} webviewDevtoolsPort [9222] - port to use for webview page
|
|
148
|
-
* presence check.
|
|
149
|
-
* @property {boolean} enableWebviewDetailsCollection [true] - whether to collect
|
|
150
|
-
* web view details and send them to Chromedriver constructor, so it could
|
|
151
|
-
* select a binary more precisely based on this info.
|
|
152
|
-
*/
|
|
153
|
-
/**
|
|
154
|
-
* @typedef {Object} WebviewsMapping
|
|
155
|
-
* @property {string} proc See note on WebviewProps
|
|
156
|
-
* @property {string} webview See note on WebviewProps
|
|
157
|
-
* @property {?Object} info See note on WebviewProps
|
|
158
|
-
* @property {?Array<Object>} pages See note on WebviewProps
|
|
159
|
-
* @propery {?string} webviewName An actual webview name for switching context
|
|
160
|
-
*/
|
|
161
|
-
/**
|
|
162
|
-
* Get a list of available webviews mapping by introspecting processes with adb,
|
|
163
|
-
* where webviews are listed. It's possible to pass in a 'deviceSocket' arg, which
|
|
164
|
-
* limits the webview possibilities to the one running on the Chromium devtools
|
|
165
|
-
* socket we're interested in (see note on webviewsFromProcs). We can also
|
|
166
|
-
* direct this method to verify whether a particular webview process actually
|
|
167
|
-
* has any pages (if a process exists but no pages are found, Chromedriver will
|
|
168
|
-
* not actually be able to connect to it, so this serves as a guard for that
|
|
169
|
-
* strange failure mode). The strategy for checking whether any pages are
|
|
170
|
-
* active involves sending a request to the remote debug server on the device,
|
|
171
|
-
* hence it is also possible to specify the port on the host machine which
|
|
172
|
-
* should be used for this communication.
|
|
173
|
-
*
|
|
174
|
-
* @param {object} adb - an ADB instance
|
|
175
|
-
* @param {GetWebviewsOpts} opts
|
|
176
|
-
*
|
|
177
|
-
* @return {Array<WebviewsMapping>} webviewsMapping
|
|
178
|
-
*/
|
|
179
|
-
function getWebViewsMapping(adb: any, { androidDeviceSocket, ensureWebviewsHavePages, webviewDevtoolsPort, enableWebviewDetailsCollection, }?: GetWebviewsOpts): WebviewsMapping[];
|
|
180
|
-
/**
|
|
181
|
-
* @typedef {Object} ProcessInfo
|
|
182
|
-
* @property {string} name The process name
|
|
183
|
-
* @property {?string} id The process id (if could be retrieved)
|
|
184
|
-
*/
|
|
185
|
-
/**
|
|
186
|
-
* @typedef {Object} WebViewDetails
|
|
187
|
-
* @property {?ProcessInfo} process - Web view process details
|
|
188
|
-
* @property {Object} info - Web view details as returned by /json/version CDP endpoint, for example:
|
|
189
|
-
* {
|
|
190
|
-
* "Browser": "Chrome/72.0.3601.0",
|
|
191
|
-
* "Protocol-Version": "1.3",
|
|
192
|
-
* "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3601.0 Safari/537.36",
|
|
193
|
-
* "V8-Version": "7.2.233",
|
|
194
|
-
* "WebKit-Version": "537.36 (@cfede9db1d154de0468cb0538479f34c0755a0f4)",
|
|
195
|
-
* "webSocketDebuggerUrl": "ws://localhost:9222/devtools/browser/b0b8a4fb-bb17-4359-9533-a8d9f3908bd8"
|
|
196
|
-
* }
|
|
197
|
-
*/
|
|
198
|
-
/**
|
|
199
|
-
* Retrieves web view details previously cached by `getWebviews` call
|
|
200
|
-
*
|
|
201
|
-
* @param {ADB} adb ADB instance
|
|
202
|
-
* @param {string} webview The name of the web view
|
|
203
|
-
* @returns {?WebViewDetails} Either `undefined` or the recent web view details
|
|
204
|
-
*/
|
|
205
|
-
function getWebviewDetails(adb: ADB, webview: string): WebViewDetails | null;
|
|
206
|
-
/**
|
|
207
|
-
* Create Chrome driver capabilities based on the provided
|
|
208
|
-
* Appium capabilities
|
|
209
|
-
*
|
|
210
|
-
* @param {Object} opts User-provided capabilities object
|
|
211
|
-
* @param {string} deviceId The identifier of the Android device under test
|
|
212
|
-
* @param {?WebViewDetails} webViewDetails
|
|
213
|
-
* @returns {Object} The capabilities object.
|
|
214
|
-
* See https://chromedriver.chromium.org/capabilities for more details.
|
|
215
|
-
*/
|
|
216
|
-
function createChromedriverCaps(opts: any, deviceId: string, webViewDetails: WebViewDetails | null): any;
|
|
217
|
-
}
|
|
218
|
-
export const NATIVE_WIN: "NATIVE_APP";
|
|
219
|
-
export const WEBVIEW_WIN: "WEBVIEW";
|
|
220
|
-
export const WEBVIEW_BASE: "WEBVIEW_";
|
|
221
|
-
export const CHROMIUM_WIN: "CHROMIUM";
|
|
222
|
-
export const KNOWN_CHROME_PACKAGE_NAMES: string[];
|
|
223
|
-
export const DEVTOOLS_SOCKET_PATTERN: RegExp;
|
|
224
|
-
//# sourceMappingURL=webview-helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webview-helpers.d.ts","sourceRoot":"","sources":["../../lib/webview-helpers.js"],"names":[],"mappings":";;;;;;UA4Fc,MAAM;;;;aAEN,MAAM;;;;;;UA+FN,MAAM;;;;;aACN,MAAM;;;;;;;;;;WAIL,UAAa;;;;;;;0BAMb,MAAM,GAAC,MAAM;;;;;6BAEb,OAAO;;;;;;oCAER,OAAO;;;;;;yBAoKP,MAAM;;;;;6BACN,OAAO;;;;;yBAEP,MAAM;;;;;;oCAEN,OAAO;;;;;;UAOP,MAAM;;;;aACN,MAAM;;;;;;;;WAEL,UAAa;;;;;;UA6Ed,MAAM;;;;QACL,MAAM;;;;;;aAKN,WAAW;;;;;;;;;;;;;;;IAhK1B;;;;;;;;;;;OAWG;IACH,4DAYC;IAED;;;;;;OAMG;IACH,yIAyBC;IAED;;;;;;;;;;OAUG;IAEH;;;;;;;OAOG;IAEH;;;;;;;;;;;;;;;;;OAiBG;IACH,mLAmDC;IAED;;;;OAIG;IAEH;;;;;;;;;;;;OAYG;IAEH;;;;;;OAMG;IACH,6EAGC;IAED;;;;;;;;;OASG;IACH,yGA0FC;;AApkBD,sCAAgC;AAChC,oCAA8B;AAE9B,sCAAuC;AADvC,sCAAgC;AAQhC,kDAKE;AATF,6CAA8E"}
|