appium-android-driver 15.0.0-beta.2 → 15.0.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.
- package/CHANGELOG.md +38 -8
- package/build/lib/commands/app-management.d.ts +26 -0
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +4 -3
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/appearance.d.ts +7 -0
- package/build/lib/commands/appearance.d.ts.map +1 -1
- package/build/lib/commands/appearance.js.map +1 -1
- package/build/lib/commands/bluetooth.d.ts +6 -0
- package/build/lib/commands/bluetooth.d.ts.map +1 -1
- package/build/lib/commands/bluetooth.js +1 -1
- package/build/lib/commands/bluetooth.js.map +1 -1
- package/build/lib/commands/context/exports.d.ts +25 -0
- package/build/lib/commands/context/exports.d.ts.map +1 -1
- package/build/lib/commands/context/exports.js +10 -6
- package/build/lib/commands/context/exports.js.map +1 -1
- package/build/lib/commands/device/common.d.ts +9 -0
- package/build/lib/commands/device/common.d.ts.map +1 -1
- package/build/lib/commands/device/common.js +1 -1
- package/build/lib/commands/device/common.js.map +1 -1
- package/build/lib/commands/device/emulator-actions.d.ts +22 -0
- package/build/lib/commands/device/emulator-actions.d.ts.map +1 -1
- package/build/lib/commands/device/emulator-actions.js.map +1 -1
- package/build/lib/commands/device/emulator-console.d.ts +6 -0
- package/build/lib/commands/device/emulator-console.d.ts.map +1 -1
- package/build/lib/commands/device/emulator-console.js.map +1 -1
- package/build/lib/commands/device/utils.js +3 -3
- package/build/lib/commands/device/utils.js.map +1 -1
- package/build/lib/commands/deviceidle.d.ts +6 -0
- package/build/lib/commands/deviceidle.d.ts.map +1 -1
- package/build/lib/commands/deviceidle.js +1 -1
- package/build/lib/commands/deviceidle.js.map +1 -1
- package/build/lib/commands/element.d.ts +20 -0
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +0 -1
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/execute.d.ts +6 -0
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts +9 -0
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/find.d.ts +8 -0
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/geolocation.d.ts +13 -0
- package/build/lib/commands/geolocation.d.ts.map +1 -1
- package/build/lib/commands/geolocation.js +2 -2
- package/build/lib/commands/geolocation.js.map +1 -1
- package/build/lib/commands/gestures.d.ts +6 -0
- package/build/lib/commands/gestures.d.ts.map +1 -1
- package/build/lib/commands/gestures.js.map +1 -1
- package/build/lib/commands/image-injection.d.ts +6 -0
- package/build/lib/commands/image-injection.d.ts.map +1 -1
- package/build/lib/commands/image-injection.js.map +1 -1
- package/build/lib/commands/ime.d.ts +11 -0
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/intent.d.ts +10 -0
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +4 -4
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +12 -0
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/legacy.d.ts +8 -0
- package/build/lib/commands/legacy.d.ts.map +1 -1
- package/build/lib/commands/legacy.js.map +1 -1
- package/build/lib/commands/lock/exports.d.ts +9 -0
- package/build/lib/commands/lock/exports.d.ts.map +1 -1
- package/build/lib/commands/lock/exports.js.map +1 -1
- package/build/lib/commands/lock/helpers.js +1 -1
- package/build/lib/commands/lock/helpers.js.map +1 -1
- package/build/lib/commands/log.d.ts +8 -13
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +4 -32
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/media-projection.d.ts +8 -0
- package/build/lib/commands/media-projection.d.ts.map +1 -1
- package/build/lib/commands/media-projection.js.map +1 -1
- package/build/lib/commands/memory.d.ts +6 -0
- package/build/lib/commands/memory.d.ts.map +1 -1
- package/build/lib/commands/memory.js.map +1 -1
- package/build/lib/commands/misc.d.ts +12 -0
- package/build/lib/commands/misc.d.ts.map +1 -1
- package/build/lib/commands/misc.js.map +1 -1
- package/build/lib/commands/network.d.ts +15 -0
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +2 -2
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/nfc.d.ts +6 -0
- package/build/lib/commands/nfc.d.ts.map +1 -1
- package/build/lib/commands/nfc.js +1 -1
- package/build/lib/commands/nfc.js.map +1 -1
- package/build/lib/commands/performance.d.ts +8 -0
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +7 -0
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +3 -3
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +7 -0
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/resources.d.ts +7 -0
- package/build/lib/commands/resources.d.ts.map +1 -1
- package/build/lib/commands/resources.js +1 -1
- package/build/lib/commands/resources.js.map +1 -1
- package/build/lib/commands/shell.d.ts +9 -0
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/shell.js.map +1 -1
- package/build/lib/commands/streamscreen.d.ts +7 -0
- package/build/lib/commands/streamscreen.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts +7 -0
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +2 -2
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/time.d.ts +7 -0
- package/build/lib/commands/time.d.ts.map +1 -1
- package/build/lib/commands/time.js.map +1 -1
- package/build/lib/constraints.d.ts +16 -3
- package/build/lib/constraints.d.ts.map +1 -1
- package/build/lib/constraints.js +16 -3
- package/build/lib/constraints.js.map +1 -1
- package/build/lib/driver.d.ts +36 -201
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +253 -168
- package/build/lib/driver.js.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/lib/utils.js.map +1 -1
- package/lib/commands/app-management.ts +33 -3
- package/lib/commands/appearance.ts +8 -0
- package/lib/commands/bluetooth.ts +8 -1
- package/lib/commands/context/exports.ts +46 -6
- package/lib/commands/device/common.ts +11 -1
- package/lib/commands/device/emulator-actions.ts +23 -0
- package/lib/commands/device/emulator-console.ts +9 -0
- package/lib/commands/device/utils.ts +3 -3
- package/lib/commands/deviceidle.ts +8 -1
- package/lib/commands/element.ts +21 -0
- package/lib/commands/execute.ts +7 -0
- package/lib/commands/file-actions.ts +10 -0
- package/lib/commands/find.ts +9 -0
- package/lib/commands/geolocation.ts +22 -2
- package/lib/commands/gestures.ts +7 -0
- package/lib/commands/image-injection.ts +9 -0
- package/lib/commands/ime.ts +12 -0
- package/lib/commands/intent.ts +25 -4
- package/lib/commands/keyboard.ts +15 -0
- package/lib/commands/legacy.ts +9 -0
- package/lib/commands/lock/exports.ts +10 -0
- package/lib/commands/lock/helpers.ts +1 -1
- package/lib/commands/log.ts +20 -35
- package/lib/commands/media-projection.ts +15 -0
- package/lib/commands/memory.ts +7 -0
- package/lib/commands/misc.ts +15 -0
- package/lib/commands/network.ts +18 -2
- package/lib/commands/nfc.ts +8 -1
- package/lib/commands/performance.ts +13 -0
- package/lib/commands/permissions.ts +15 -3
- package/lib/commands/recordscreen.ts +8 -0
- package/lib/commands/resources.ts +9 -1
- package/lib/commands/shell.ts +12 -0
- package/lib/commands/streamscreen.ts +12 -0
- package/lib/commands/system-bars.ts +12 -2
- package/lib/commands/time.ts +8 -0
- package/lib/constraints.ts +16 -3
- package/lib/driver.ts +289 -212
- package/lib/utils.ts +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import type {StringRecord} from '@appium/types';
|
|
|
3
3
|
import {Chromedriver} from 'appium-chromedriver';
|
|
4
4
|
import {errors, PROTOCOLS} from 'appium/driver.js';
|
|
5
5
|
|
|
6
|
+
import type {AndroidDriverConstraints} from '../../constraints.js';
|
|
6
7
|
import type {AndroidDriver} from '../../driver.js';
|
|
7
8
|
import {APP_STATE} from '../app-management.js';
|
|
8
9
|
import {BIDI_EVENT_NAME} from '../bidi/constants.js';
|
|
@@ -22,6 +23,41 @@ import {
|
|
|
22
23
|
shouldDismissChromeWelcome,
|
|
23
24
|
} from './helpers.js';
|
|
24
25
|
|
|
26
|
+
declare module '../../driver.js' {
|
|
27
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
28
|
+
getContexts(...args: Parameters<typeof getContexts>): ReturnType<typeof getContexts>;
|
|
29
|
+
getCurrentContext(...args: Parameters<typeof getCurrentContext>): ReturnType<typeof getCurrentContext>;
|
|
30
|
+
defaultContextName(...args: Parameters<typeof defaultContextName>): ReturnType<typeof defaultContextName>;
|
|
31
|
+
assignContexts(...args: Parameters<typeof assignContexts>): ReturnType<typeof assignContexts>;
|
|
32
|
+
switchContext(...args: Parameters<typeof switchContext>): ReturnType<typeof switchContext>;
|
|
33
|
+
defaultWebviewName(...args: Parameters<typeof defaultWebviewName>): ReturnType<typeof defaultWebviewName>;
|
|
34
|
+
isChromedriverContext(...args: Parameters<typeof isChromedriverContext>): ReturnType<typeof isChromedriverContext>;
|
|
35
|
+
startChromedriverProxy(
|
|
36
|
+
...args: Parameters<typeof startChromedriverProxy>
|
|
37
|
+
): ReturnType<typeof startChromedriverProxy>;
|
|
38
|
+
stopChromedriverProxies(
|
|
39
|
+
...args: Parameters<typeof stopChromedriverProxies>
|
|
40
|
+
): ReturnType<typeof stopChromedriverProxies>;
|
|
41
|
+
suspendChromedriverProxy(
|
|
42
|
+
...args: Parameters<typeof suspendChromedriverProxy>
|
|
43
|
+
): ReturnType<typeof suspendChromedriverProxy>;
|
|
44
|
+
startChromeSession(...args: Parameters<typeof startChromeSession>): ReturnType<typeof startChromeSession>;
|
|
45
|
+
onChromedriverStop(...args: Parameters<typeof onChromedriverStop>): ReturnType<typeof onChromedriverStop>;
|
|
46
|
+
isWebContext(...args: Parameters<typeof isWebContext>): ReturnType<typeof isWebContext>;
|
|
47
|
+
mobileGetContexts(...args: Parameters<typeof mobileGetContexts>): ReturnType<typeof mobileGetContexts>;
|
|
48
|
+
mobileGetChromeCapabilities(
|
|
49
|
+
...args: Parameters<typeof mobileGetChromeCapabilities>
|
|
50
|
+
): ReturnType<typeof mobileGetChromeCapabilities>;
|
|
51
|
+
setContext(name?: string): Promise<void>;
|
|
52
|
+
setWindow(...args: Parameters<typeof setWindow>): ReturnType<typeof setWindow>;
|
|
53
|
+
getWindowHandle(...args: Parameters<typeof getWindowHandle>): ReturnType<typeof getWindowHandle>;
|
|
54
|
+
getWindowHandles(...args: Parameters<typeof getWindowHandles>): ReturnType<typeof getWindowHandles>;
|
|
55
|
+
notifyBiDiContextChange(
|
|
56
|
+
...args: Parameters<typeof notifyBiDiContextChange>
|
|
57
|
+
): ReturnType<typeof notifyBiDiContextChange>;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
25
61
|
// https://github.com/appium/appium/issues/20710
|
|
26
62
|
const DEFAULT_NATIVE_WINDOW_HANDLE = '1';
|
|
27
63
|
|
|
@@ -66,11 +102,15 @@ export async function setContext(this: AndroidDriver, name?: string | null): Pro
|
|
|
66
102
|
return;
|
|
67
103
|
}
|
|
68
104
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
105
|
+
let webviewsMapping: WebviewsMapping[] = [];
|
|
106
|
+
// the native context always exists, so do not wait for the webview scan to switch to it
|
|
107
|
+
if (newContext !== NATIVE_WIN) {
|
|
108
|
+
webviewsMapping = await getWebViewsMapping.bind(this)(this.opts);
|
|
109
|
+
const contexts = this.assignContexts(webviewsMapping);
|
|
110
|
+
// if the context we want doesn't exist, fail
|
|
111
|
+
if (!contexts?.includes(newContext)) {
|
|
112
|
+
throw new errors.NoSuchContextError();
|
|
113
|
+
}
|
|
74
114
|
}
|
|
75
115
|
|
|
76
116
|
await this.switchContext(newContext, webviewsMapping);
|
|
@@ -429,7 +469,7 @@ export async function startChromeSession(this: AndroidDriver): Promise<void> {
|
|
|
429
469
|
} else {
|
|
430
470
|
opts.chromeAndroidActivity = this.opts.appActivity;
|
|
431
471
|
}
|
|
432
|
-
const chromedriver = await setupNewChromedriver.bind(this)(opts, this.adb.curDeviceId as string);
|
|
472
|
+
const chromedriver = await setupNewChromedriver.bind(this)(opts, this.adb.curDeviceId as string, CHROMIUM_WIN);
|
|
433
473
|
this.chromedriver = chromedriver;
|
|
434
474
|
chromedriver.on(Chromedriver.EVENT_CHANGED, async (msg) => {
|
|
435
475
|
if (msg.state === Chromedriver.STATE_STOPPED) {
|
|
@@ -5,6 +5,7 @@ import {retryInterval} from 'asyncbox';
|
|
|
5
5
|
import {SETTINGS_HELPER_ID} from 'io.appium.settings';
|
|
6
6
|
import * as semver from 'semver';
|
|
7
7
|
|
|
8
|
+
import type {AndroidDriverConstraints} from '../../constraints.js';
|
|
8
9
|
import type {AndroidDriver} from '../../driver.js';
|
|
9
10
|
import {GET_SERVER_LOGS_FEATURE, nativeLogEntryToSeleniumEntry} from '../../utils.js';
|
|
10
11
|
import {setMockLocationApp} from '../geolocation.js';
|
|
@@ -13,6 +14,15 @@ import {adjustTimeZone} from '../time.js';
|
|
|
13
14
|
import type {ADBDeviceInfo, ADBLaunchInfo} from '../types.js';
|
|
14
15
|
import {createBaseADB, prepareEmulator, pushSettingsApp} from './utils.js';
|
|
15
16
|
|
|
17
|
+
declare module '../../driver.js' {
|
|
18
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
19
|
+
getDeviceInfoFromCaps(...args: Parameters<typeof getDeviceInfoFromCaps>): ReturnType<typeof getDeviceInfoFromCaps>;
|
|
20
|
+
createADB(...args: Parameters<typeof createADB>): ReturnType<typeof createADB>;
|
|
21
|
+
getLaunchInfo(...args: Parameters<typeof getLaunchInfo>): ReturnType<typeof getLaunchInfo>;
|
|
22
|
+
initDevice(...args: Parameters<typeof initDevice>): ReturnType<typeof initDevice>;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
/**
|
|
17
27
|
* Gets device information from capabilities, including UDID and emulator port.
|
|
18
28
|
*
|
|
@@ -48,7 +58,7 @@ export async function getDeviceInfoFromCaps(this: AndroidDriver): Promise<ADBDev
|
|
|
48
58
|
|
|
49
59
|
// a platform version was given. lets try to find a device with the same os
|
|
50
60
|
const platformVersion = semver.coerce(this.opts.platformVersion) || this.opts.platformVersion;
|
|
51
|
-
this.log.info(`Looking for a device with Android '${platformVersion}'`);
|
|
61
|
+
this.log.info(`Looking for a device with Android '${String(platformVersion)}'`);
|
|
52
62
|
|
|
53
63
|
// in case we fail to find something, give the user a useful log that has
|
|
54
64
|
// the device udids and os versions so they know what's available
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
import {util} from '@appium/support';
|
|
2
2
|
import {errors} from 'appium/driver.js';
|
|
3
3
|
|
|
4
|
+
import type {AndroidDriverConstraints} from '../../constraints.js';
|
|
4
5
|
import type {AndroidDriver} from '../../driver.js';
|
|
5
6
|
import type {GsmAction, GsmSignalStrength, GsmVoiceState, PowerACState, NetworkSpeed} from '../types.js';
|
|
6
7
|
import {requireEmulator} from './utils.js';
|
|
7
8
|
|
|
9
|
+
declare module '../../driver.js' {
|
|
10
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
11
|
+
fingerprint(...args: Parameters<typeof fingerprint>): ReturnType<typeof fingerprint>;
|
|
12
|
+
mobileFingerprint(...args: Parameters<typeof mobileFingerprint>): ReturnType<typeof mobileFingerprint>;
|
|
13
|
+
sendSMS(...args: Parameters<typeof sendSMS>): ReturnType<typeof sendSMS>;
|
|
14
|
+
mobileSendSms(...args: Parameters<typeof mobileSendSms>): ReturnType<typeof mobileSendSms>;
|
|
15
|
+
gsmCall(...args: Parameters<typeof gsmCall>): ReturnType<typeof gsmCall>;
|
|
16
|
+
mobileGsmCall(...args: Parameters<typeof mobileGsmCall>): ReturnType<typeof mobileGsmCall>;
|
|
17
|
+
gsmSignal(...args: Parameters<typeof gsmSignal>): ReturnType<typeof gsmSignal>;
|
|
18
|
+
mobileGsmSignal(...args: Parameters<typeof mobileGsmSignal>): ReturnType<typeof mobileGsmSignal>;
|
|
19
|
+
gsmVoice(...args: Parameters<typeof gsmVoice>): ReturnType<typeof gsmVoice>;
|
|
20
|
+
mobileGsmVoice(...args: Parameters<typeof mobileGsmVoice>): ReturnType<typeof mobileGsmVoice>;
|
|
21
|
+
powerAC(...args: Parameters<typeof powerAC>): ReturnType<typeof powerAC>;
|
|
22
|
+
mobilePowerAc(...args: Parameters<typeof mobilePowerAc>): ReturnType<typeof mobilePowerAc>;
|
|
23
|
+
powerCapacity(...args: Parameters<typeof powerCapacity>): ReturnType<typeof powerCapacity>;
|
|
24
|
+
mobilePowerCapacity(...args: Parameters<typeof mobilePowerCapacity>): ReturnType<typeof mobilePowerCapacity>;
|
|
25
|
+
networkSpeed(...args: Parameters<typeof networkSpeed>): ReturnType<typeof networkSpeed>;
|
|
26
|
+
mobileNetworkSpeed(...args: Parameters<typeof mobileNetworkSpeed>): ReturnType<typeof mobileNetworkSpeed>;
|
|
27
|
+
sensorSet(...args: Parameters<typeof sensorSet>): ReturnType<typeof sensorSet>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
8
31
|
/**
|
|
9
32
|
* @deprecated Use mobile: extension
|
|
10
33
|
*/
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import {errors} from 'appium/driver.js';
|
|
2
2
|
|
|
3
|
+
import type {AndroidDriverConstraints} from '../../constraints.js';
|
|
3
4
|
import type {AndroidDriver} from '../../driver.js';
|
|
4
5
|
|
|
6
|
+
declare module '../../driver.js' {
|
|
7
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
8
|
+
mobileExecEmuConsoleCommand(
|
|
9
|
+
...args: Parameters<typeof mobileExecEmuConsoleCommand>
|
|
10
|
+
): ReturnType<typeof mobileExecEmuConsoleCommand>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
const EMU_CONSOLE_FEATURE = 'emulator_console';
|
|
6
15
|
|
|
7
16
|
/**
|
|
@@ -34,7 +34,7 @@ export function ensureNetworkSpeed(this: AndroidDriver, networkSpeed: string): s
|
|
|
34
34
|
}
|
|
35
35
|
this.log.warn(
|
|
36
36
|
`Wrong network speed param '${networkSpeed}', using default: ${this.adb.NETWORK_SPEED.FULL}. ` +
|
|
37
|
-
`Supported values: ${Object.values(this.adb.NETWORK_SPEED)}`,
|
|
37
|
+
`Supported values: ${Object.values(this.adb.NETWORK_SPEED).join(', ')}`,
|
|
38
38
|
);
|
|
39
39
|
return this.adb.NETWORK_SPEED.FULL;
|
|
40
40
|
}
|
|
@@ -50,8 +50,8 @@ export function prepareAvdArgs(this: AndroidDriver): string[] {
|
|
|
50
50
|
if (avdArgs) {
|
|
51
51
|
if (Array.isArray(avdArgs)) {
|
|
52
52
|
result.push(...avdArgs);
|
|
53
|
-
} else {
|
|
54
|
-
result.push(...util.shellParse(
|
|
53
|
+
} else if (typeof avdArgs === 'string') {
|
|
54
|
+
result.push(...util.shellParse(avdArgs).filter((entry): entry is string => typeof entry === 'string'));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
if (networkSpeed) {
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import {errors} from 'appium/driver.js';
|
|
2
2
|
|
|
3
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
3
4
|
import type {AndroidDriver} from '../driver.js';
|
|
4
5
|
|
|
6
|
+
declare module '../driver.js' {
|
|
7
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
8
|
+
mobileDeviceidle(...args: Parameters<typeof mobileDeviceidle>): ReturnType<typeof mobileDeviceidle>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
const SUPPORTED_ACTIONS = ['whitelistAdd', 'whitelistRemove'] as const;
|
|
6
13
|
|
|
7
14
|
/**
|
|
@@ -36,7 +43,7 @@ export async function mobileDeviceidle(
|
|
|
36
43
|
break;
|
|
37
44
|
default:
|
|
38
45
|
throw new errors.InvalidArgumentError(
|
|
39
|
-
`action must be one of ${JSON.stringify(SUPPORTED_ACTIONS)}. Got '${action}' instead`,
|
|
46
|
+
`action must be one of ${JSON.stringify(SUPPORTED_ACTIONS)}. Got '${String(action)}' instead`,
|
|
40
47
|
);
|
|
41
48
|
}
|
|
42
49
|
await this.adb.shellChunks(argsGenerator, packagesArr);
|
package/lib/commands/element.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
2
|
+
|
|
3
|
+
declare module '../driver.js' {
|
|
4
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
5
|
+
getAttribute(...args: Parameters<typeof getAttribute>): ReturnType<typeof getAttribute>;
|
|
6
|
+
getName(...args: Parameters<typeof getName>): ReturnType<typeof getName>;
|
|
7
|
+
elementDisplayed(...args: Parameters<typeof elementDisplayed>): ReturnType<typeof elementDisplayed>;
|
|
8
|
+
elementEnabled(...args: Parameters<typeof elementEnabled>): ReturnType<typeof elementEnabled>;
|
|
9
|
+
elementSelected(...args: Parameters<typeof elementSelected>): ReturnType<typeof elementSelected>;
|
|
10
|
+
setElementValue(...args: Parameters<typeof setElementValue>): ReturnType<typeof setElementValue>;
|
|
11
|
+
doSetElementValue(...args: Parameters<typeof doSetElementValue>): ReturnType<typeof doSetElementValue>;
|
|
12
|
+
replaceValue(...args: Parameters<typeof replaceValue>): ReturnType<typeof replaceValue>;
|
|
13
|
+
setValueImmediate(...args: Parameters<typeof setValueImmediate>): ReturnType<typeof setValueImmediate>;
|
|
14
|
+
setValue(...args: Parameters<typeof setValue>): ReturnType<typeof setValue>;
|
|
15
|
+
click(...args: Parameters<typeof click>): ReturnType<typeof click>;
|
|
16
|
+
getLocationInView(...args: Parameters<typeof getLocationInView>): ReturnType<typeof getLocationInView>;
|
|
17
|
+
getText(...args: Parameters<typeof getText>): ReturnType<typeof getText>;
|
|
18
|
+
getLocation(...args: Parameters<typeof getLocation>): ReturnType<typeof getLocation>;
|
|
19
|
+
getSize(...args: Parameters<typeof getSize>): ReturnType<typeof getSize>;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
1
22
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
23
|
|
|
3
24
|
import type {Position, Size} from '@appium/types';
|
package/lib/commands/execute.ts
CHANGED
|
@@ -3,8 +3,15 @@ import type {StringRecord, Element} from '@appium/types';
|
|
|
3
3
|
import type {Chromedriver} from 'appium-chromedriver';
|
|
4
4
|
import {errors, PROTOCOLS} from 'appium/driver.js';
|
|
5
5
|
|
|
6
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
6
7
|
import type {AndroidDriver} from '../driver.js';
|
|
7
8
|
|
|
9
|
+
declare module '../driver.js' {
|
|
10
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
11
|
+
execute(...args: Parameters<typeof execute>): ReturnType<typeof execute>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
const EXECUTE_SCRIPT_PREFIX = 'mobile:';
|
|
9
16
|
|
|
10
17
|
type ExecuteMethodArgs = readonly any[] | readonly [StringRecord] | Readonly<StringRecord>;
|
|
@@ -4,8 +4,18 @@ import {fs, util, zip, tempDir} from '@appium/support';
|
|
|
4
4
|
import type {ADB} from 'appium-adb';
|
|
5
5
|
import {errors} from 'appium/driver.js';
|
|
6
6
|
|
|
7
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
7
8
|
import type {AndroidDriver} from '../driver.js';
|
|
8
9
|
|
|
10
|
+
declare module '../driver.js' {
|
|
11
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
12
|
+
pullFile(...args: Parameters<typeof pullFile>): ReturnType<typeof pullFile>;
|
|
13
|
+
pullFolder(...args: Parameters<typeof pullFolder>): ReturnType<typeof pullFolder>;
|
|
14
|
+
pushFile(...args: Parameters<typeof pushFile>): ReturnType<typeof pushFile>;
|
|
15
|
+
mobileDeleteFile(...args: Parameters<typeof mobileDeleteFile>): ReturnType<typeof mobileDeleteFile>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
const CONTAINER_PATH_MARKER = '@';
|
|
10
20
|
const CONTAINER_PATH_PATTERN = new RegExp(`^${CONTAINER_PATH_MARKER}([^/]+)/(.+)`, 's');
|
|
11
21
|
const ANDROID_MEDIA_RESCAN_INTENT = 'android.intent.action.MEDIA_SCANNER_SCAN_FILE';
|
package/lib/commands/find.ts
CHANGED
|
@@ -2,9 +2,18 @@ import {util} from '@appium/support';
|
|
|
2
2
|
import type {Element} from '@appium/types';
|
|
3
3
|
import {errors, isErrorType} from 'appium/driver.js';
|
|
4
4
|
|
|
5
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
5
6
|
import type {AndroidDriver} from '../driver.js';
|
|
6
7
|
import type {FindElementOpts} from './types.js';
|
|
7
8
|
|
|
9
|
+
declare module '../driver.js' {
|
|
10
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
11
|
+
findElOrEls(strategy: string, selector: string, mult: true, context?: string): Promise<Element[]>;
|
|
12
|
+
findElOrEls(strategy: string, selector: string, mult: false, context?: string): Promise<Element>;
|
|
13
|
+
doFindElementOrEls(...args: Parameters<typeof doFindElementOrEls>): ReturnType<typeof doFindElementOrEls>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
/**
|
|
9
18
|
* @param strategy The element location strategy to use (e.g., 'id', 'xpath', 'class name').
|
|
10
19
|
* @param selector The selector value to search for.
|
|
@@ -4,10 +4,30 @@ import {fs, tempDir} from '@appium/support';
|
|
|
4
4
|
import {asyncmap} from 'asyncbox';
|
|
5
5
|
import {SETTINGS_HELPER_ID} from 'io.appium.settings';
|
|
6
6
|
|
|
7
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
7
8
|
import type {AndroidDriver} from '../driver.js';
|
|
8
9
|
import {getThirdPartyPackages} from './app-management.js';
|
|
9
10
|
import type {GeoLocation} from './types.js';
|
|
10
11
|
|
|
12
|
+
declare module '../driver.js' {
|
|
13
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
14
|
+
setGeoLocation(...args: Parameters<typeof setGeoLocation>): ReturnType<typeof setGeoLocation>;
|
|
15
|
+
getGeoLocation(...args: Parameters<typeof getGeoLocation>): ReturnType<typeof getGeoLocation>;
|
|
16
|
+
mobileRefreshGpsCache(...args: Parameters<typeof mobileRefreshGpsCache>): ReturnType<typeof mobileRefreshGpsCache>;
|
|
17
|
+
toggleLocationServices(
|
|
18
|
+
...args: Parameters<typeof toggleLocationServices>
|
|
19
|
+
): ReturnType<typeof toggleLocationServices>;
|
|
20
|
+
isLocationServicesEnabled(
|
|
21
|
+
...args: Parameters<typeof isLocationServicesEnabled>
|
|
22
|
+
): ReturnType<typeof isLocationServicesEnabled>;
|
|
23
|
+
mobileGetGeolocation(...args: Parameters<typeof mobileGetGeolocation>): ReturnType<typeof mobileGetGeolocation>;
|
|
24
|
+
mobileSetGeolocation(...args: Parameters<typeof mobileSetGeolocation>): ReturnType<typeof mobileSetGeolocation>;
|
|
25
|
+
mobileResetGeolocation(
|
|
26
|
+
...args: Parameters<typeof mobileResetGeolocation>
|
|
27
|
+
): ReturnType<typeof mobileResetGeolocation>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
11
31
|
// The value close to zero, but not zero, is needed
|
|
12
32
|
// to trick JSON generation and send a float value instead of an integer,
|
|
13
33
|
// This allows strictly-typed clients, like Java, to properly
|
|
@@ -149,7 +169,7 @@ export async function mobileResetGeolocation(this: AndroidDriver): Promise<void>
|
|
|
149
169
|
if (this.isEmulator()) {
|
|
150
170
|
throw new Error('Geolocation reset does not work on emulators');
|
|
151
171
|
}
|
|
152
|
-
await resetMockLocation.bind(this);
|
|
172
|
+
await resetMockLocation.bind(this)();
|
|
153
173
|
}
|
|
154
174
|
|
|
155
175
|
// #region Internal helpers
|
|
@@ -213,7 +233,7 @@ async function resetMockLocation(this: AndroidDriver): Promise<void> {
|
|
|
213
233
|
return;
|
|
214
234
|
}
|
|
215
235
|
|
|
216
|
-
this.log.debug(`Resetting mock_location permission for the following apps: ${resultPkgs}`);
|
|
236
|
+
this.log.debug(`Resetting mock_location permission for the following apps: ${resultPkgs.join(', ')}`);
|
|
217
237
|
await asyncmap(resultPkgs, async (pkgId) => {
|
|
218
238
|
try {
|
|
219
239
|
await this.adb.shell(['appops', 'set', pkgId, 'android:mock_location', 'deny']);
|
package/lib/commands/gestures.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import type {StringRecord} from '@appium/types';
|
|
2
2
|
import {errors} from 'appium/driver.js';
|
|
3
3
|
|
|
4
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
4
5
|
import type {AndroidDriver} from '../driver.js';
|
|
5
6
|
|
|
7
|
+
declare module '../driver.js' {
|
|
8
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
9
|
+
performActions(...args: Parameters<typeof performActions>): ReturnType<typeof performActions>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
/**
|
|
7
14
|
* Performs a series of actions (gestures) on the device.
|
|
8
15
|
*
|
|
@@ -4,8 +4,17 @@ import path from 'node:path';
|
|
|
4
4
|
import {fs, tempDir} from '@appium/support';
|
|
5
5
|
import {errors} from 'appium/driver.js';
|
|
6
6
|
|
|
7
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
7
8
|
import type {AndroidDriver} from '../driver.js';
|
|
8
9
|
|
|
10
|
+
declare module '../driver.js' {
|
|
11
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
12
|
+
mobileInjectEmulatorCameraImage(
|
|
13
|
+
...args: Parameters<typeof mobileInjectEmulatorCameraImage>
|
|
14
|
+
): ReturnType<typeof mobileInjectEmulatorCameraImage>;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
9
18
|
const EMULATOR_RESOURCES_ROOT = ['emulator', 'resources'];
|
|
10
19
|
const CONFIG_NAME = 'Toren1BD.posters';
|
|
11
20
|
const DEFAULT_CONFIG_PAYLOAD_PREFIX = `poster wall
|
package/lib/commands/ime.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import {errors} from 'appium/driver.js';
|
|
2
2
|
|
|
3
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
3
4
|
import type {AndroidDriver} from '../driver.js';
|
|
4
5
|
import {SET_STYLUS_HANDWRITING_FEATURE} from '../utils.js';
|
|
5
6
|
|
|
7
|
+
declare module '../driver.js' {
|
|
8
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
9
|
+
isIMEActivated(...args: Parameters<typeof isIMEActivated>): ReturnType<typeof isIMEActivated>;
|
|
10
|
+
availableIMEEngines(...args: Parameters<typeof availableIMEEngines>): ReturnType<typeof availableIMEEngines>;
|
|
11
|
+
getActiveIMEEngine(...args: Parameters<typeof getActiveIMEEngine>): ReturnType<typeof getActiveIMEEngine>;
|
|
12
|
+
activateIMEEngine(...args: Parameters<typeof activateIMEEngine>): ReturnType<typeof activateIMEEngine>;
|
|
13
|
+
deactivateIMEEngine(...args: Parameters<typeof deactivateIMEEngine>): ReturnType<typeof deactivateIMEEngine>;
|
|
14
|
+
setStylusHandwriting(...args: Parameters<typeof setStylusHandwriting>): ReturnType<typeof setStylusHandwriting>;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
/**
|
|
7
19
|
* Checks if an IME (Input Method Editor) is activated.
|
|
8
20
|
*
|
package/lib/commands/intent.ts
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import {util} from '@appium/support';
|
|
2
2
|
import {errors} from 'appium/driver.js';
|
|
3
3
|
|
|
4
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
4
5
|
import type {AndroidDriver} from '../driver.js';
|
|
5
6
|
import type {IntentOpts} from './types.js';
|
|
6
7
|
|
|
8
|
+
declare module '../driver.js' {
|
|
9
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
10
|
+
startActivity(
|
|
11
|
+
appPackage: string,
|
|
12
|
+
appActivity: string,
|
|
13
|
+
appWaitPackage?: string,
|
|
14
|
+
appWaitActivity?: string,
|
|
15
|
+
intentAction?: string,
|
|
16
|
+
intentCategory?: string,
|
|
17
|
+
intentFlags?: string,
|
|
18
|
+
optionalIntentArguments?: string,
|
|
19
|
+
dontStopAppOnReset?: boolean,
|
|
20
|
+
): Promise<void>;
|
|
21
|
+
mobileStartActivity(...args: Parameters<typeof mobileStartActivity>): ReturnType<typeof mobileStartActivity>;
|
|
22
|
+
mobileBroadcast(...args: Parameters<typeof mobileBroadcast>): ReturnType<typeof mobileBroadcast>;
|
|
23
|
+
mobileStartService(...args: Parameters<typeof mobileStartService>): ReturnType<typeof mobileStartService>;
|
|
24
|
+
mobileStopService(...args: Parameters<typeof mobileStopService>): ReturnType<typeof mobileStopService>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
7
28
|
const NO_VALUE_ARG_TYPE = 'sn';
|
|
8
29
|
const SUPPORTED_EXTRA_TYPES = [
|
|
9
30
|
's',
|
|
@@ -354,9 +375,6 @@ export async function mobileStopService(
|
|
|
354
375
|
function parseIntentSpec(opts: IntentOpts = {}): string[] {
|
|
355
376
|
const {intent, action, uri, mimeType, identifier, categories, component, extras, flags} = opts;
|
|
356
377
|
const resultArgs: string[] = [];
|
|
357
|
-
if (intent) {
|
|
358
|
-
resultArgs.push(intent);
|
|
359
|
-
}
|
|
360
378
|
if (action) {
|
|
361
379
|
resultArgs.push('-a', action);
|
|
362
380
|
}
|
|
@@ -388,7 +406,7 @@ function parseIntentSpec(opts: IntentOpts = {}): string[] {
|
|
|
388
406
|
}
|
|
389
407
|
for (const item of extras) {
|
|
390
408
|
if (!Array.isArray(item)) {
|
|
391
|
-
throw new errors.InvalidArgumentError(`Extra argument '${item}' must be an array`);
|
|
409
|
+
throw new errors.InvalidArgumentError(`Extra argument '${String(item)}' must be an array`);
|
|
392
410
|
}
|
|
393
411
|
const [type, key, value] = item;
|
|
394
412
|
if (!SUPPORTED_EXTRA_TYPES.includes(type as any)) {
|
|
@@ -416,6 +434,9 @@ function parseIntentSpec(opts: IntentOpts = {}): string[] {
|
|
|
416
434
|
if (flags) {
|
|
417
435
|
resultArgs.push('-f', flags);
|
|
418
436
|
}
|
|
437
|
+
if (intent) {
|
|
438
|
+
resultArgs.push(intent);
|
|
439
|
+
}
|
|
419
440
|
return resultArgs;
|
|
420
441
|
}
|
|
421
442
|
|
package/lib/commands/keyboard.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import {errors} from 'appium/driver.js';
|
|
2
2
|
import {UNICODE_IME, EMPTY_IME} from 'io.appium.settings';
|
|
3
3
|
|
|
4
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
4
5
|
import type {AndroidDriver} from '../driver.js';
|
|
5
6
|
import type {SendKeysOpts} from './types.js';
|
|
6
7
|
|
|
8
|
+
declare module '../driver.js' {
|
|
9
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
10
|
+
hideKeyboard(...args: Parameters<typeof hideKeyboard>): ReturnType<typeof hideKeyboard>;
|
|
11
|
+
isKeyboardShown(...args: Parameters<typeof isKeyboardShown>): ReturnType<typeof isKeyboardShown>;
|
|
12
|
+
keys(...args: Parameters<typeof keys>): ReturnType<typeof keys>;
|
|
13
|
+
doSendKeys(...args: Parameters<typeof doSendKeys>): ReturnType<typeof doSendKeys>;
|
|
14
|
+
pressKeyCode(...args: Parameters<typeof pressKeyCode>): ReturnType<typeof pressKeyCode>;
|
|
15
|
+
longPressKeyCode(...args: Parameters<typeof longPressKeyCode>): ReturnType<typeof longPressKeyCode>;
|
|
16
|
+
mobilePerformEditorAction(
|
|
17
|
+
...args: Parameters<typeof mobilePerformEditorAction>
|
|
18
|
+
): ReturnType<typeof mobilePerformEditorAction>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
7
22
|
/**
|
|
8
23
|
* Hides the on-screen keyboard.
|
|
9
24
|
*
|
package/lib/commands/legacy.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import {errors} from 'appium/driver.js';
|
|
2
2
|
|
|
3
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
3
4
|
import type {AndroidDriver} from '../driver.js';
|
|
4
5
|
|
|
6
|
+
declare module '../driver.js' {
|
|
7
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
8
|
+
reset(...args: Parameters<typeof reset>): ReturnType<typeof reset>;
|
|
9
|
+
closeApp(...args: Parameters<typeof closeApp>): ReturnType<typeof closeApp>;
|
|
10
|
+
launchApp(...args: Parameters<typeof launchApp>): ReturnType<typeof launchApp>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
const ISSUE_URL = 'https://github.com/appium/appium/issues/15807';
|
|
6
15
|
|
|
7
16
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {sleep} from 'asyncbox';
|
|
2
2
|
|
|
3
|
+
import type {AndroidDriverConstraints} from '../../constraints.js';
|
|
3
4
|
import type {AndroidDriver, AndroidDriverCaps} from '../../driver.js';
|
|
4
5
|
import type {UnlockType} from '../types.js';
|
|
5
6
|
import {
|
|
@@ -19,6 +20,15 @@ import {
|
|
|
19
20
|
verifyUnlock,
|
|
20
21
|
} from './helpers.js';
|
|
21
22
|
|
|
23
|
+
declare module '../../driver.js' {
|
|
24
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
25
|
+
lock(...args: Parameters<typeof lock>): ReturnType<typeof lock>;
|
|
26
|
+
unlock(...args: Parameters<typeof unlock>): ReturnType<typeof unlock>;
|
|
27
|
+
mobileUnlock(...args: Parameters<typeof mobileUnlock>): ReturnType<typeof mobileUnlock>;
|
|
28
|
+
isLocked(...args: Parameters<typeof isLocked>): ReturnType<typeof isLocked>;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
/**
|
|
23
33
|
* Locks the device and optionally unlocks it after a specified number of seconds.
|
|
24
34
|
*
|
|
@@ -70,7 +70,7 @@ export function validateUnlockCapabilities<T extends AndroidDriverCaps>(caps: T)
|
|
|
70
70
|
}
|
|
71
71
|
} else {
|
|
72
72
|
throw new Error(
|
|
73
|
-
`Invalid unlock type '${unlockType}'. Only the following unlock types are supported: ${UNLOCK_TYPES}`,
|
|
73
|
+
`Invalid unlock type '${unlockType}'. Only the following unlock types are supported: ${UNLOCK_TYPES.join(', ')}`,
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
return caps;
|
package/lib/commands/log.ts
CHANGED
|
@@ -4,16 +4,31 @@ import os from 'node:os';
|
|
|
4
4
|
import {util} from '@appium/support';
|
|
5
5
|
import type {AppiumServer, WSServer} from '@appium/types';
|
|
6
6
|
import type {ADB} from 'appium-adb';
|
|
7
|
-
import
|
|
8
|
-
import {DEFAULT_WS_PATHNAME_PREFIX, BaseDriver} from 'appium/driver.js';
|
|
7
|
+
import {DEFAULT_WS_PATHNAME_PREFIX} from 'appium/driver.js';
|
|
9
8
|
import {WebSocket, WebSocketServer} from 'ws';
|
|
10
9
|
|
|
10
|
+
import type {AndroidDriverConstraints} from '../constraints.js';
|
|
11
11
|
import type {AndroidDriver} from '../driver.js';
|
|
12
12
|
import {GET_SERVER_LOGS_FEATURE, toLogRecord, nativeLogEntryToSeleniumEntry, type LogEntry} from '../utils.js';
|
|
13
13
|
import {BIDI_EVENT_NAME} from './bidi/constants.js';
|
|
14
14
|
import {makeLogEntryAddedEvent} from './bidi/models.js';
|
|
15
15
|
import {NATIVE_WIN} from './context/helpers.js';
|
|
16
16
|
|
|
17
|
+
declare module '../driver.js' {
|
|
18
|
+
interface AndroidDriver<C extends AndroidDriverConstraints> {
|
|
19
|
+
mobileStartLogsBroadcast(
|
|
20
|
+
...args: Parameters<typeof mobileStartLogsBroadcast>
|
|
21
|
+
): ReturnType<typeof mobileStartLogsBroadcast>;
|
|
22
|
+
mobileStopLogsBroadcast(
|
|
23
|
+
...args: Parameters<typeof mobileStopLogsBroadcast>
|
|
24
|
+
): ReturnType<typeof mobileStopLogsBroadcast>;
|
|
25
|
+
assignBiDiLogListener<EE extends EventEmitter>(
|
|
26
|
+
logEmitter: EE,
|
|
27
|
+
properties: BiDiListenerProperties,
|
|
28
|
+
): [EE, LogListener];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
17
32
|
export const supportedLogTypes = {
|
|
18
33
|
logcat: {
|
|
19
34
|
description: 'Logs for Android applications on real device and emulators via ADB',
|
|
@@ -67,7 +82,7 @@ export async function mobileStartLogsBroadcast(this: AndroidDriver): Promise<voi
|
|
|
67
82
|
const remoteIp = util.isEmpty(req.headers['x-forwarded-for'])
|
|
68
83
|
? req.socket.remoteAddress
|
|
69
84
|
: req.headers['x-forwarded-for'];
|
|
70
|
-
this.log.debug(`Established a new logcat listener web socket connection from ${remoteIp}`);
|
|
85
|
+
this.log.debug(`Established a new logcat listener web socket connection from ${String(remoteIp)}`);
|
|
71
86
|
} else {
|
|
72
87
|
this.log.debug('Established a new logcat listener web socket connection');
|
|
73
88
|
}
|
|
@@ -81,8 +96,8 @@ export async function mobileStartLogsBroadcast(this: AndroidDriver): Promise<voi
|
|
|
81
96
|
}
|
|
82
97
|
}
|
|
83
98
|
};
|
|
99
|
+
this.adb.setLogcatListener(this._logcatWebsocketListener);
|
|
84
100
|
}
|
|
85
|
-
this.adb.setLogcatListener(this._logcatWebsocketListener);
|
|
86
101
|
|
|
87
102
|
ws.on('close', (code, reason) => {
|
|
88
103
|
connectedSockets.delete(ws);
|
|
@@ -94,7 +109,7 @@ export async function mobileStartLogsBroadcast(this: AndroidDriver): Promise<voi
|
|
|
94
109
|
}
|
|
95
110
|
|
|
96
111
|
let closeMsg = 'Logcat listener web socket is closed.';
|
|
97
|
-
if (
|
|
112
|
+
if (code) {
|
|
98
113
|
closeMsg += ` Code: ${code}.`;
|
|
99
114
|
}
|
|
100
115
|
if (!util.isEmpty(reason)) {
|
|
@@ -125,21 +140,6 @@ export async function mobileStopLogsBroadcast(this: AndroidDriver): Promise<void
|
|
|
125
140
|
await server.removeWebSocketHandler(pathname);
|
|
126
141
|
}
|
|
127
142
|
|
|
128
|
-
/**
|
|
129
|
-
* Gets the list of available log types.
|
|
130
|
-
*
|
|
131
|
-
* @returns Promise that resolves to an array of log type names.
|
|
132
|
-
*/
|
|
133
|
-
export async function getLogTypes(this: AndroidDriver): Promise<string[]> {
|
|
134
|
-
// XXX why doesn't `super` work here?
|
|
135
|
-
const nativeLogTypes = await BaseDriver.prototype.getLogTypes.call(this);
|
|
136
|
-
if (this.isWebContext()) {
|
|
137
|
-
const webLogTypes = (await (this.chromedriver as Chromedriver).jwproxy.command('/log/types', 'GET')) as string[];
|
|
138
|
-
return [...nativeLogTypes, ...webLogTypes];
|
|
139
|
-
}
|
|
140
|
-
return nativeLogTypes;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
143
|
/**
|
|
144
144
|
* Assigns a BiDi log listener to an event emitter.
|
|
145
145
|
*
|
|
@@ -164,21 +164,6 @@ export function assignBiDiLogListener<EE extends EventEmitter>(
|
|
|
164
164
|
return [logEmitter, listener];
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
/**
|
|
168
|
-
* Gets logs of a specific type.
|
|
169
|
-
*
|
|
170
|
-
* @param logType The type of logs to retrieve.
|
|
171
|
-
* @returns Promise that resolves to the logs for the specified type.
|
|
172
|
-
*/
|
|
173
|
-
export async function getLog(this: AndroidDriver, logType: string): Promise<any> {
|
|
174
|
-
if (this.isWebContext() && !Object.keys(this.supportedLogTypes).includes(logType)) {
|
|
175
|
-
return await (this.chromedriver as Chromedriver).jwproxy.command('/log', 'POST', {
|
|
176
|
-
type: logType,
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
return await BaseDriver.prototype.getLog.call(this, logType);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
167
|
// #region Internal helpers
|
|
183
168
|
|
|
184
169
|
/**
|