@allwright.dev/core 0.1.17 → 0.1.19
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/dist/bootstrap.js +1 -1
- package/dist/mobile.js +25 -0
- package/dist/mobileSelectors.js +4 -1
- package/dist/types.d.ts +9 -1
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -12,7 +12,7 @@ const ALLWRIGHT_HOME_ENV_VAR = "ALLWRIGHT_HOME";
|
|
|
12
12
|
const ALLWRIGHT_REPOSITORY_ENV_VAR = "ALLWRIGHT_REPOSITORY";
|
|
13
13
|
const ALLWRIGHT_VERSION_ENV_VAR = "ALLWRIGHT_VERSION";
|
|
14
14
|
const DEFAULT_RELEASE_REPOSITORY = "allwright-dev/allwright";
|
|
15
|
-
const DEFAULT_RELEASE_VERSION = "0.1.
|
|
15
|
+
const DEFAULT_RELEASE_VERSION = "0.1.19";
|
|
16
16
|
const STARTUP_TIMEOUT_MS = 20_000;
|
|
17
17
|
const PING_TIMEOUT_MS = 1_000;
|
|
18
18
|
const PROTO_ROOT = fileURLToPath(new URL("../proto/", import.meta.url));
|
package/dist/mobile.js
CHANGED
|
@@ -3,6 +3,7 @@ import { open, rename, unlink, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { basename } from "node:path";
|
|
5
5
|
import { chainMobileSelectorForTransport, normalizeMobileSelectorForTransport } from "./mobileSelectors.js";
|
|
6
|
+
import { semanticSelector } from "./web-locators.js";
|
|
6
7
|
function retryOptions(timeoutMs) {
|
|
7
8
|
return timeoutMs ? { timeoutMs } : undefined;
|
|
8
9
|
}
|
|
@@ -19,6 +20,18 @@ class MobileAndroidAppImpl {
|
|
|
19
20
|
locator(selector) {
|
|
20
21
|
return new MobileAndroidLocatorImpl(this, normalizeMobileSelectorForTransport(selector));
|
|
21
22
|
}
|
|
23
|
+
getByRole(role, options = {}) {
|
|
24
|
+
return this.locator(semanticSelector({ ...options, kind: "role", role }));
|
|
25
|
+
}
|
|
26
|
+
getByText(text, options = {}) {
|
|
27
|
+
return this.locator(semanticSelector({ ...options, kind: "text", text }));
|
|
28
|
+
}
|
|
29
|
+
getByLabel(text, options = {}) {
|
|
30
|
+
return this.locator(semanticSelector({ ...options, kind: "label", text }));
|
|
31
|
+
}
|
|
32
|
+
getByTestId(text) {
|
|
33
|
+
return this.locator(semanticSelector({ kind: "testId", text }));
|
|
34
|
+
}
|
|
22
35
|
async registerHook(type) {
|
|
23
36
|
if (type.name !== "fileChooser" && type.name !== "download") {
|
|
24
37
|
throw new Error(`hook type ${type.name} is not supported by Android apps`);
|
|
@@ -550,6 +563,18 @@ class MobileAndroidLocatorImpl {
|
|
|
550
563
|
locator(selector) {
|
|
551
564
|
return new MobileAndroidLocatorImpl(this.page, chainMobileSelectorForTransport(this.selector, selector));
|
|
552
565
|
}
|
|
566
|
+
getByRole(role, options = {}) {
|
|
567
|
+
return this.locator(semanticSelector({ ...options, kind: "role", role }));
|
|
568
|
+
}
|
|
569
|
+
getByText(text, options = {}) {
|
|
570
|
+
return this.locator(semanticSelector({ ...options, kind: "text", text }));
|
|
571
|
+
}
|
|
572
|
+
getByLabel(text, options = {}) {
|
|
573
|
+
return this.locator(semanticSelector({ ...options, kind: "label", text }));
|
|
574
|
+
}
|
|
575
|
+
getByTestId(text) {
|
|
576
|
+
return this.locator(semanticSelector({ kind: "testId", text }));
|
|
577
|
+
}
|
|
553
578
|
}
|
|
554
579
|
class MobileAndroidDeviceImpl {
|
|
555
580
|
sessionId;
|
package/dist/mobileSelectors.js
CHANGED
|
@@ -30,7 +30,7 @@ const UIAUTOMATOR_SELECTOR_KEYS = new Set([
|
|
|
30
30
|
"index",
|
|
31
31
|
"instance",
|
|
32
32
|
]);
|
|
33
|
-
const SELECTOR_PREFIXES = ["xpath=", "xpath:", "css=", "css:", "uia=", "uia:"];
|
|
33
|
+
const SELECTOR_PREFIXES = ["xpath=", "xpath:", "css=", "css:", "uia=", "uia:", "aw=", "aw:"];
|
|
34
34
|
function decodeSelectorBody(body) {
|
|
35
35
|
const candidate = body.trim();
|
|
36
36
|
if (candidate.startsWith("\"") && candidate.endsWith("\"")) {
|
|
@@ -54,6 +54,9 @@ function parseExplicitSelectorPrefix(selector) {
|
|
|
54
54
|
if (lowered.startsWith("uia=") || lowered.startsWith("uia:")) {
|
|
55
55
|
return { flavor: "uia", prefixLength: 4 };
|
|
56
56
|
}
|
|
57
|
+
if (lowered.startsWith("aw=") || lowered.startsWith("aw:")) {
|
|
58
|
+
return { flavor: "aw", prefixLength: 3 };
|
|
59
|
+
}
|
|
57
60
|
return null;
|
|
58
61
|
}
|
|
59
62
|
function findJsonStringEnd(value) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WebLocators, LocatorFilterOptions } from "./web-locators.js";
|
|
1
|
+
import type { WebLocators, LocatorFilterOptions, RoleOptions, TextMatcher, TextOptions } from "./web-locators.js";
|
|
2
2
|
import grpc from "@grpc/grpc-js";
|
|
3
3
|
export { AllwrightError } from "./errors.js";
|
|
4
4
|
export interface LaunchOptions {
|
|
@@ -195,11 +195,19 @@ export interface MobileAndroidLocator {
|
|
|
195
195
|
innerText(options?: CommandOptions): Promise<TextResult>;
|
|
196
196
|
waitFor(options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
|
|
197
197
|
locator(selector: string): MobileAndroidLocator;
|
|
198
|
+
getByRole(role: string, options?: RoleOptions): MobileAndroidLocator;
|
|
199
|
+
getByText(text: TextMatcher, options?: TextOptions): MobileAndroidLocator;
|
|
200
|
+
getByLabel(text: TextMatcher, options?: TextOptions): MobileAndroidLocator;
|
|
201
|
+
getByTestId(text: TextMatcher): MobileAndroidLocator;
|
|
198
202
|
}
|
|
199
203
|
export interface MobileAndroidApp {
|
|
200
204
|
accessibilitySnapshot(options?: AccessibilitySnapshotOptions): Promise<string>;
|
|
201
205
|
readonly sessionId: string;
|
|
202
206
|
locator(selector: string): MobileAndroidLocator;
|
|
207
|
+
getByRole(role: string, options?: RoleOptions): MobileAndroidLocator;
|
|
208
|
+
getByText(text: TextMatcher, options?: TextOptions): MobileAndroidLocator;
|
|
209
|
+
getByLabel(text: TextMatcher, options?: TextOptions): MobileAndroidLocator;
|
|
210
|
+
getByTestId(text: TextMatcher): MobileAndroidLocator;
|
|
203
211
|
click(selector: string, options?: CommandOptions): Promise<ClickResult>;
|
|
204
212
|
count(selector: string, options?: CommandOptions): Promise<CountResult>;
|
|
205
213
|
focus(selector: string, options?: CommandOptions): Promise<ElementResult>;
|