@ekhein/lamda-node-sdk 2.1.3 → 2.1.5
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Selector } from "../rpc/uiautomator";
|
|
2
2
|
export declare class TimeoutException extends Error {
|
|
3
|
-
constructor(
|
|
3
|
+
constructor(selector: Partial<Selector>, timeout: number);
|
|
4
4
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TimeoutException = void 0;
|
|
4
4
|
const util_1 = require("util");
|
|
5
5
|
class TimeoutException extends Error {
|
|
6
|
-
constructor(
|
|
7
|
-
super((0, util_1.format)("%s %sms selector [%s]", TimeoutException.name,
|
|
6
|
+
constructor(selector, timeout) {
|
|
7
|
+
super((0, util_1.format)("%s %sms selector [%s]", TimeoutException.name, timeout, selector));
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
exports.TimeoutException = TimeoutException;
|
package/dist/main.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Corner, Selector } from './rpc/uiautomator';
|
|
1
2
|
import { UtilClient, UiAutomatorClient, ApplicationClient, DebugClient, FileClient, LockClient, ProxyClient, SelinuxPolicyClient, ShellClient, StatusClient, StorageClient, WifiClient, SettingsClient } from './rpc/services';
|
|
2
3
|
export declare class Device {
|
|
3
4
|
readonly Util: UtilClient;
|
|
@@ -16,10 +17,10 @@ export declare class Device {
|
|
|
16
17
|
private channel;
|
|
17
18
|
private client;
|
|
18
19
|
constructor(host?: string, prot?: number);
|
|
19
|
-
click(
|
|
20
|
-
|
|
20
|
+
click(selector: Partial<Selector>, corner?: Corner): Promise<import("./rpc/types").Boolean>;
|
|
21
|
+
clickEx(keys: string, keyboard: Record<"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9", Partial<Selector>>): Promise<void>;
|
|
22
|
+
waitFor(selector: Partial<Selector>, timeout?: number): Promise<true>;
|
|
21
23
|
sleep(min?: number, max?: number): Promise<unknown>;
|
|
22
|
-
passwd(pwd: string, keyboard: Record<"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9", Parameters<typeof this.UiAutomator["selectorClick"]>[0]>): Promise<void>;
|
|
23
24
|
activity(data: string): Promise<import("./rpc/types").Boolean>;
|
|
24
25
|
kill(name: string): Promise<import("./rpc/types").Boolean>;
|
|
25
26
|
open(name: string): Promise<import("./rpc/types").Boolean>;
|
package/dist/main.js
CHANGED
|
@@ -47,36 +47,35 @@ class Device {
|
|
|
47
47
|
})
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
async click(
|
|
50
|
+
async click(selector, corner) {
|
|
51
51
|
return this.UiAutomator
|
|
52
|
-
.selectorClick(
|
|
52
|
+
.selectorClick({ selector, corner });
|
|
53
53
|
}
|
|
54
|
-
async
|
|
55
|
-
|
|
54
|
+
async clickEx(keys, keyboard) {
|
|
55
|
+
for (let i = 0; i < keys.length; i++) {
|
|
56
|
+
await this.sleep(100, 200);
|
|
57
|
+
await this.click(keyboard[keys[i]]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async waitFor(selector, timeout = 15e3) {
|
|
56
61
|
return this.UiAutomator
|
|
57
|
-
.selectorWaitForExists(
|
|
62
|
+
.selectorWaitForExists({ selector, timeout })
|
|
58
63
|
.then(async (exists) => {
|
|
59
|
-
if (
|
|
60
|
-
throw new timeout_exception_1.TimeoutException(
|
|
61
|
-
|
|
64
|
+
if (exists.value === false)
|
|
65
|
+
throw new timeout_exception_1.TimeoutException(selector, timeout);
|
|
66
|
+
return exists.value;
|
|
62
67
|
});
|
|
63
68
|
}
|
|
64
69
|
async sleep(min = 500, max = min) {
|
|
65
70
|
const ms = Math.random() * (max - min) + min;
|
|
66
71
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
67
72
|
}
|
|
68
|
-
async passwd(pwd, keyboard) {
|
|
69
|
-
for (let i = 0; i < pwd.length; i++) {
|
|
70
|
-
await this.sleep(100, 200);
|
|
71
|
-
await this.click(keyboard[pwd[i]]);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
73
|
async activity(data) {
|
|
75
74
|
return this.Application
|
|
76
75
|
.startActivity({
|
|
77
76
|
data,
|
|
78
77
|
action: android_intent_1.ACTION_VIEW,
|
|
79
|
-
flags:
|
|
78
|
+
flags: activity_flag_1.FLAG_ACTIVITY_NEW_TASK | activity_flag_1.FLAG_ACTIVITY_CLEAR_TOP | activity_flag_1.FLAG_ACTIVITY_CLEAR_TASK
|
|
80
79
|
});
|
|
81
80
|
}
|
|
82
81
|
async kill(name) {
|