@allwright.dev/core 0.0.55 → 0.0.57
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 +188 -0
- package/dist/types.d.ts +12 -0
- 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.0.
|
|
15
|
+
const DEFAULT_RELEASE_VERSION = "0.0.57";
|
|
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
|
@@ -46,6 +46,63 @@ class MobileAndroidAppImpl {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
async count(selector, options = {}) {
|
|
50
|
+
const handle = await this.#getHandle();
|
|
51
|
+
this.#ensureOpen(handle);
|
|
52
|
+
handle.stream.write({
|
|
53
|
+
surfaceSessionId: this.#surfaceSessionId,
|
|
54
|
+
contextSessionId: this.sessionId,
|
|
55
|
+
countElements: {
|
|
56
|
+
cssSelector: normalizeMobileSelectorForTransport(selector),
|
|
57
|
+
retryOptions: retryOptions(options.timeoutMs),
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
while (true) {
|
|
61
|
+
const event = await handle.queue.next();
|
|
62
|
+
if (event.elementCounted) {
|
|
63
|
+
return {
|
|
64
|
+
selector: event.elementCounted.cssSelector ?? "",
|
|
65
|
+
count: event.elementCounted.count ?? 0,
|
|
66
|
+
note: event.elementCounted.note ?? "",
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (event.error?.message) {
|
|
70
|
+
throw new Error(event.error.message);
|
|
71
|
+
}
|
|
72
|
+
if (event.closed) {
|
|
73
|
+
handle.closed = true;
|
|
74
|
+
throw new Error(`android app session ${this.sessionId} closed while counting elements`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async focus(selector, options = {}) {
|
|
79
|
+
const handle = await this.#getHandle();
|
|
80
|
+
this.#ensureOpen(handle);
|
|
81
|
+
handle.stream.write({
|
|
82
|
+
surfaceSessionId: this.#surfaceSessionId,
|
|
83
|
+
contextSessionId: this.sessionId,
|
|
84
|
+
focusElement: {
|
|
85
|
+
cssSelector: normalizeMobileSelectorForTransport(selector),
|
|
86
|
+
retryOptions: retryOptions(options.timeoutMs),
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
while (true) {
|
|
90
|
+
const event = await handle.queue.next();
|
|
91
|
+
if (event.elementFocused) {
|
|
92
|
+
return {
|
|
93
|
+
selector: event.elementFocused.cssSelector ?? "",
|
|
94
|
+
note: event.elementFocused.note ?? "",
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (event.error?.message) {
|
|
98
|
+
throw new Error(event.error.message);
|
|
99
|
+
}
|
|
100
|
+
if (event.closed) {
|
|
101
|
+
handle.closed = true;
|
|
102
|
+
throw new Error(`android app session ${this.sessionId} closed while focusing`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
49
106
|
async fill(selector, value, options = {}) {
|
|
50
107
|
const handle = await this.#getHandle();
|
|
51
108
|
this.#ensureOpen(handle);
|
|
@@ -76,6 +133,73 @@ class MobileAndroidAppImpl {
|
|
|
76
133
|
}
|
|
77
134
|
}
|
|
78
135
|
}
|
|
136
|
+
async press(selector, key, options = {}) {
|
|
137
|
+
const handle = await this.#getHandle();
|
|
138
|
+
this.#ensureOpen(handle);
|
|
139
|
+
handle.stream.write({
|
|
140
|
+
surfaceSessionId: this.#surfaceSessionId,
|
|
141
|
+
contextSessionId: this.sessionId,
|
|
142
|
+
pressKey: {
|
|
143
|
+
cssSelector: normalizeMobileSelectorForTransport(selector),
|
|
144
|
+
key,
|
|
145
|
+
text: options.text,
|
|
146
|
+
retryOptions: retryOptions(options.timeoutMs),
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
while (true) {
|
|
150
|
+
const event = await handle.queue.next();
|
|
151
|
+
if (event.keyPressed) {
|
|
152
|
+
return {
|
|
153
|
+
selector: event.keyPressed.cssSelector ?? "",
|
|
154
|
+
key: event.keyPressed.key ?? "",
|
|
155
|
+
note: event.keyPressed.note ?? "",
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (event.error?.message) {
|
|
159
|
+
throw new Error(event.error.message);
|
|
160
|
+
}
|
|
161
|
+
if (event.closed) {
|
|
162
|
+
handle.closed = true;
|
|
163
|
+
throw new Error(`android app session ${this.sessionId} closed while pressing key`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async textContent(selector, options = {}) {
|
|
168
|
+
return this.#readText(selector, options, true);
|
|
169
|
+
}
|
|
170
|
+
async innerText(selector, options = {}) {
|
|
171
|
+
return this.#readText(selector, options, false);
|
|
172
|
+
}
|
|
173
|
+
async waitForSelector(selector, options = {}) {
|
|
174
|
+
const handle = await this.#getHandle();
|
|
175
|
+
this.#ensureOpen(handle);
|
|
176
|
+
handle.stream.write({
|
|
177
|
+
surfaceSessionId: this.#surfaceSessionId,
|
|
178
|
+
contextSessionId: this.sessionId,
|
|
179
|
+
waitForSelector: {
|
|
180
|
+
cssSelector: normalizeMobileSelectorForTransport(selector),
|
|
181
|
+
visible: options.visible,
|
|
182
|
+
retryOptions: retryOptions(options.timeoutMs),
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
while (true) {
|
|
186
|
+
const event = await handle.queue.next();
|
|
187
|
+
if (event.selectorWaitSatisfied) {
|
|
188
|
+
return {
|
|
189
|
+
selector: event.selectorWaitSatisfied.cssSelector ?? "",
|
|
190
|
+
visible: event.selectorWaitSatisfied.visible ?? false,
|
|
191
|
+
note: event.selectorWaitSatisfied.note ?? "",
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (event.error?.message) {
|
|
195
|
+
throw new Error(event.error.message);
|
|
196
|
+
}
|
|
197
|
+
if (event.closed) {
|
|
198
|
+
handle.closed = true;
|
|
199
|
+
throw new Error(`android app session ${this.sessionId} closed while waiting for selector`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
79
203
|
async screenshot(options = {}) {
|
|
80
204
|
const handle = await this.#getHandle();
|
|
81
205
|
this.#ensureOpen(handle);
|
|
@@ -119,6 +243,52 @@ class MobileAndroidAppImpl {
|
|
|
119
243
|
throw new Error(`android app session ${this.sessionId} is closed`);
|
|
120
244
|
}
|
|
121
245
|
}
|
|
246
|
+
async #readText(selector, options, textContent) {
|
|
247
|
+
const handle = await this.#getHandle();
|
|
248
|
+
this.#ensureOpen(handle);
|
|
249
|
+
const transportSelector = normalizeMobileSelectorForTransport(selector);
|
|
250
|
+
handle.stream.write(textContent
|
|
251
|
+
? {
|
|
252
|
+
surfaceSessionId: this.#surfaceSessionId,
|
|
253
|
+
contextSessionId: this.sessionId,
|
|
254
|
+
getTextContent: {
|
|
255
|
+
cssSelector: transportSelector,
|
|
256
|
+
retryOptions: retryOptions(options.timeoutMs),
|
|
257
|
+
},
|
|
258
|
+
}
|
|
259
|
+
: {
|
|
260
|
+
surfaceSessionId: this.#surfaceSessionId,
|
|
261
|
+
contextSessionId: this.sessionId,
|
|
262
|
+
getInnerText: {
|
|
263
|
+
cssSelector: transportSelector,
|
|
264
|
+
retryOptions: retryOptions(options.timeoutMs),
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
while (true) {
|
|
268
|
+
const event = await handle.queue.next();
|
|
269
|
+
if (event.textContentResolved) {
|
|
270
|
+
return {
|
|
271
|
+
selector: event.textContentResolved.cssSelector ?? "",
|
|
272
|
+
text: event.textContentResolved.text ?? "",
|
|
273
|
+
note: event.textContentResolved.note ?? "",
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
if (event.innerTextResolved) {
|
|
277
|
+
return {
|
|
278
|
+
selector: event.innerTextResolved.cssSelector ?? "",
|
|
279
|
+
text: event.innerTextResolved.text ?? "",
|
|
280
|
+
note: event.innerTextResolved.note ?? "",
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
if (event.error?.message) {
|
|
284
|
+
throw new Error(event.error.message);
|
|
285
|
+
}
|
|
286
|
+
if (event.closed) {
|
|
287
|
+
handle.closed = true;
|
|
288
|
+
throw new Error(`android app session ${this.sessionId} closed while reading text`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
122
292
|
}
|
|
123
293
|
class MobileAndroidLocatorImpl {
|
|
124
294
|
page;
|
|
@@ -133,6 +303,24 @@ class MobileAndroidLocatorImpl {
|
|
|
133
303
|
async fill(value, options = {}) {
|
|
134
304
|
return this.page.fill(this.selector, value, options);
|
|
135
305
|
}
|
|
306
|
+
async count(options = {}) {
|
|
307
|
+
return this.page.count(this.selector, options);
|
|
308
|
+
}
|
|
309
|
+
async focus(options = {}) {
|
|
310
|
+
return this.page.focus(this.selector, options);
|
|
311
|
+
}
|
|
312
|
+
async press(key, options = {}) {
|
|
313
|
+
return this.page.press(this.selector, key, options);
|
|
314
|
+
}
|
|
315
|
+
async textContent(options = {}) {
|
|
316
|
+
return this.page.textContent(this.selector, options);
|
|
317
|
+
}
|
|
318
|
+
async innerText(options = {}) {
|
|
319
|
+
return this.page.innerText(this.selector, options);
|
|
320
|
+
}
|
|
321
|
+
async waitFor(options = {}) {
|
|
322
|
+
return this.page.waitForSelector(this.selector, options);
|
|
323
|
+
}
|
|
136
324
|
locator(selector) {
|
|
137
325
|
return new MobileAndroidLocatorImpl(this.page, chainMobileSelectorForTransport(this.selector, selector));
|
|
138
326
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -140,14 +140,26 @@ export interface MobileAndroidLocator {
|
|
|
140
140
|
readonly page: MobileAndroidApp;
|
|
141
141
|
readonly selector: string;
|
|
142
142
|
click(options?: CommandOptions): Promise<ClickResult>;
|
|
143
|
+
count(options?: CommandOptions): Promise<CountResult>;
|
|
144
|
+
focus(options?: CommandOptions): Promise<ElementResult>;
|
|
143
145
|
fill(value: string, options?: CommandOptions): Promise<FillResult>;
|
|
146
|
+
press(key: string, options?: PressOptions): Promise<PressResult>;
|
|
147
|
+
textContent(options?: CommandOptions): Promise<TextResult>;
|
|
148
|
+
innerText(options?: CommandOptions): Promise<TextResult>;
|
|
149
|
+
waitFor(options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
|
|
144
150
|
locator(selector: string): MobileAndroidLocator;
|
|
145
151
|
}
|
|
146
152
|
export interface MobileAndroidApp {
|
|
147
153
|
readonly sessionId: string;
|
|
148
154
|
locator(selector: string): MobileAndroidLocator;
|
|
149
155
|
click(selector: string, options?: CommandOptions): Promise<ClickResult>;
|
|
156
|
+
count(selector: string, options?: CommandOptions): Promise<CountResult>;
|
|
157
|
+
focus(selector: string, options?: CommandOptions): Promise<ElementResult>;
|
|
150
158
|
fill(selector: string, value: string, options?: CommandOptions): Promise<FillResult>;
|
|
159
|
+
press(selector: string, key: string, options?: PressOptions): Promise<PressResult>;
|
|
160
|
+
textContent(selector: string, options?: CommandOptions): Promise<TextResult>;
|
|
161
|
+
innerText(selector: string, options?: CommandOptions): Promise<TextResult>;
|
|
162
|
+
waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
|
|
151
163
|
screenshot(options?: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
152
164
|
}
|
|
153
165
|
export interface MobileAndroidDevice {
|