@allwright.dev/core 0.1.13 → 0.1.14
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/README.md +17 -0
- package/dist/bootstrap.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/locator.d.ts +7 -1
- package/dist/locator.js +18 -0
- package/dist/page.d.ts +8 -1
- package/dist/page.js +46 -0
- package/dist/types.d.ts +42 -0
- package/package.json +1 -1
- package/proto/core/v1/context.proto +39 -0
package/README.md
CHANGED
|
@@ -95,3 +95,20 @@ resolving its browsing context, and waiting for a fully loaded document with 200
|
|
|
95
95
|
without DOM mutations. The default is 10 seconds. Closing the frame page releases
|
|
96
96
|
its session; it does not remove the iframe or close the parent tab. Resolve a new
|
|
97
97
|
frame page after the iframe is replaced.
|
|
98
|
+
|
|
99
|
+
### Read page and element state
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const url = await page.url();
|
|
103
|
+
const value = await page.locator('input, textarea').inputValue();
|
|
104
|
+
const options = await page.locator('select').selectedOptions(); // [{ value, label, index }]
|
|
105
|
+
const selectedText = await page.locator('textarea').selectedText();
|
|
106
|
+
const checked = await page.locator('input[type=checkbox]').isChecked();
|
|
107
|
+
const text = await page.locator('h1').innerText(); // { selector, text, note }
|
|
108
|
+
const attribute = await page.locator('a').getAttribute('href');
|
|
109
|
+
const box = await page.locator('button').boundingBox(); // { x, y, width, height }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Element reads also have page methods such as `page.inputValue(selector, options)` and accept `timeoutMs`. Reads use the first locator match and work in frame pages. `inputValue` reads the live property of an input, textarea, or select. `selectedOptions` supports native selects (including multiple selections) and ARIA combobox/listbox options marked `aria-selected="true"`. `selectedText` returns the textbox's selected substring, an empty string for a caret, or `null` for input types without selection support. `isChecked` supports native checkbox/radio and ARIA checked controls; ARIA mixed state returns false.
|
|
113
|
+
|
|
114
|
+
Missing attributes return `null` (an empty attribute remains `""`). Bounding boxes use CSS pixels relative to the page/frame viewport and return `null` for hidden or zero-area elements. Missing elements and incompatible control types raise errors. Use `textContent()` for raw text or `innerText()` for rendered text.
|
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.14";
|
|
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/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { PageImpl } from "./page.js";
|
|
|
5
5
|
import { setServerAddr, shutdown } from "./runtime.js";
|
|
6
6
|
import type { Browser, BrowserKind, BrowserType, LaunchOptions, Page, FileChooser, Download, HookType, ResolveConfigOptions, ResolvedAllwrightConfig } from "./types.js";
|
|
7
7
|
export { findConfigFile, loadConfigFile, resolveConfig, setServerAddr, shutdown };
|
|
8
|
-
export type { AccessibilitySnapshotOptions, AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, Hook, HookType, FileChooser, Download, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, LaunchOptions, MobileAndroidConnectOptions, MobileAndroidDevice, MobileAndroidLaunchOptions, MobileAndroidLocator, MobileAndroidApp, Locator, LocatorInfo, MobileSurfaceNamespace, NavigateResult, Page, PageInfo, PressOptions, PressResult, ResolveConfigOptions, ResolvedAllwrightConfig, RetryConfig, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult, } from "./types.js";
|
|
8
|
+
export type { CapturedOption, BoundingBox, AccessibilitySnapshotOptions, AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, Hook, HookType, FileChooser, Download, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, LaunchOptions, MobileAndroidConnectOptions, MobileAndroidDevice, MobileAndroidLaunchOptions, MobileAndroidLocator, MobileAndroidApp, Locator, LocatorInfo, MobileSurfaceNamespace, NavigateResult, Page, PageInfo, PressOptions, PressResult, ResolveConfigOptions, ResolvedAllwrightConfig, RetryConfig, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult, } from "./types.js";
|
|
9
9
|
export declare const chromium: BrowserType;
|
|
10
10
|
export declare const firefox: BrowserType;
|
|
11
11
|
export declare const hooks: {
|
package/dist/locator.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebLocatorBuilders, type LocatorFilterOptions } from "./web-locators.js";
|
|
2
|
-
import type { ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, Locator, LocatorInfo, Page, PressOptions, PressResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult } from "./types.js";
|
|
2
|
+
import type { BoundingBox, CapturedOption, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, Locator, LocatorInfo, Page, PressOptions, PressResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult } from "./types.js";
|
|
3
3
|
export declare class LocatorImpl extends WebLocatorBuilders implements Locator {
|
|
4
4
|
readonly page: Page;
|
|
5
5
|
readonly selector: string;
|
|
@@ -13,6 +13,12 @@ export declare class LocatorImpl extends WebLocatorBuilders implements Locator {
|
|
|
13
13
|
fill(value: string, options?: CommandOptions): Promise<FillResult>;
|
|
14
14
|
hover(options?: CommandOptions): Promise<ElementResult>;
|
|
15
15
|
press(key: string, options?: PressOptions): Promise<PressResult>;
|
|
16
|
+
inputValue(options?: CommandOptions): Promise<string>;
|
|
17
|
+
selectedOptions(options?: CommandOptions): Promise<CapturedOption[]>;
|
|
18
|
+
selectedText(options?: CommandOptions): Promise<string | null>;
|
|
19
|
+
isChecked(options?: CommandOptions): Promise<boolean>;
|
|
20
|
+
getAttribute(name: string, options?: CommandOptions): Promise<string | null>;
|
|
21
|
+
boundingBox(options?: CommandOptions): Promise<BoundingBox | null>;
|
|
16
22
|
textContent(options?: CommandOptions): Promise<TextResult>;
|
|
17
23
|
innerText(options?: CommandOptions): Promise<TextResult>;
|
|
18
24
|
waitFor(options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
|
package/dist/locator.js
CHANGED
|
@@ -31,6 +31,24 @@ export class LocatorImpl extends WebLocatorBuilders {
|
|
|
31
31
|
async press(key, options = {}) {
|
|
32
32
|
return this.page.press(this.selector, key, options);
|
|
33
33
|
}
|
|
34
|
+
async inputValue(options = {}) {
|
|
35
|
+
return this.page.inputValue(this.selector, options);
|
|
36
|
+
}
|
|
37
|
+
async selectedOptions(options = {}) {
|
|
38
|
+
return this.page.selectedOptions(this.selector, options);
|
|
39
|
+
}
|
|
40
|
+
async selectedText(options = {}) {
|
|
41
|
+
return this.page.selectedText(this.selector, options);
|
|
42
|
+
}
|
|
43
|
+
async isChecked(options = {}) {
|
|
44
|
+
return this.page.isChecked(this.selector, options);
|
|
45
|
+
}
|
|
46
|
+
async getAttribute(name, options = {}) {
|
|
47
|
+
return this.page.getAttribute(this.selector, name, options);
|
|
48
|
+
}
|
|
49
|
+
async boundingBox(options = {}) {
|
|
50
|
+
return this.page.boundingBox(this.selector, options);
|
|
51
|
+
}
|
|
34
52
|
async textContent(options = {}) {
|
|
35
53
|
return this.page.textContent(this.selector, options);
|
|
36
54
|
}
|
package/dist/page.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebLocatorBuilders, type LocatorFilterOptions } from "./web-locators.js";
|
|
2
|
-
import type { AccessibilitySnapshotOptions, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, FileChooser, Download, HighlightOptions, HighlightResult, Hook, HookType, Locator, NavigateResult, Page, PageInfo, PressOptions, PressResult, RuntimeClient, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult } from "./types.js";
|
|
2
|
+
import type { BoundingBox, CapturedOption, AccessibilitySnapshotOptions, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, FileChooser, Download, HighlightOptions, HighlightResult, Hook, HookType, Locator, NavigateResult, Page, PageInfo, PressOptions, PressResult, RuntimeClient, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult } from "./types.js";
|
|
3
3
|
export declare class PageImpl extends WebLocatorBuilders implements Page {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(input: PageInfo & {
|
|
@@ -21,6 +21,13 @@ export declare class PageImpl extends WebLocatorBuilders implements Page {
|
|
|
21
21
|
fill(selector: string, value: string, options?: CommandOptions): Promise<FillResult>;
|
|
22
22
|
hover(selector: string, options?: CommandOptions): Promise<ElementResult>;
|
|
23
23
|
press(selector: string, key: string, options?: PressOptions): Promise<PressResult>;
|
|
24
|
+
url(options?: CommandOptions): Promise<string>;
|
|
25
|
+
inputValue(selector: string, options?: CommandOptions): Promise<string>;
|
|
26
|
+
selectedOptions(selector: string, options?: CommandOptions): Promise<CapturedOption[]>;
|
|
27
|
+
selectedText(selector: string, options?: CommandOptions): Promise<string | null>;
|
|
28
|
+
isChecked(selector: string, options?: CommandOptions): Promise<boolean>;
|
|
29
|
+
getAttribute(selector: string, name: string, options?: CommandOptions): Promise<string | null>;
|
|
30
|
+
boundingBox(selector: string, options?: CommandOptions): Promise<BoundingBox | null>;
|
|
24
31
|
textContent(selector: string, options?: CommandOptions): Promise<TextResult>;
|
|
25
32
|
innerText(selector: string, options?: CommandOptions): Promise<TextResult>;
|
|
26
33
|
waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
|
package/dist/page.js
CHANGED
|
@@ -476,6 +476,52 @@ export class PageImpl extends WebLocatorBuilders {
|
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
|
+
async #capture(kind, selector, attributeName, options) {
|
|
480
|
+
const handle = await this.#getHandle();
|
|
481
|
+
this.#ensureOpen(handle);
|
|
482
|
+
handle.stream.write({ surfaceSessionId: this.browserSessionId, contextSessionId: this.sessionId,
|
|
483
|
+
capture: { kind, cssSelector: selector ? normalizeSelectorForTransport(selector) : "", attributeName,
|
|
484
|
+
retryOptions: options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : undefined } });
|
|
485
|
+
while (true) {
|
|
486
|
+
const event = await handle.queue.next();
|
|
487
|
+
if (event.captureResolved)
|
|
488
|
+
return event.captureResolved;
|
|
489
|
+
if (event.error)
|
|
490
|
+
throw formatActionError("capture", event.error.message ?? "capture failed", selector);
|
|
491
|
+
if (event.closed) {
|
|
492
|
+
handle.closed = true;
|
|
493
|
+
throw new Error("page session closed while capturing");
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
async url(options = {}) {
|
|
498
|
+
const r = await this.#capture("CAPTURE_KIND_URL", "", "", options);
|
|
499
|
+
return r.value ?? "";
|
|
500
|
+
}
|
|
501
|
+
async inputValue(selector, options = {}) {
|
|
502
|
+
const r = await this.#capture("CAPTURE_KIND_INPUT_VALUE", selector, "", options);
|
|
503
|
+
return r.value ?? "";
|
|
504
|
+
}
|
|
505
|
+
async selectedOptions(selector, options = {}) {
|
|
506
|
+
const r = await this.#capture("CAPTURE_KIND_SELECTED_OPTIONS", selector, "", options);
|
|
507
|
+
return r.selectedOptions ?? [];
|
|
508
|
+
}
|
|
509
|
+
async selectedText(selector, options = {}) {
|
|
510
|
+
const r = await this.#capture("CAPTURE_KIND_SELECTED_TEXT", selector, "", options);
|
|
511
|
+
return r.value ?? null;
|
|
512
|
+
}
|
|
513
|
+
async isChecked(selector, options = {}) {
|
|
514
|
+
const r = await this.#capture("CAPTURE_KIND_CHECKED", selector, "", options);
|
|
515
|
+
return r.checked ?? false;
|
|
516
|
+
}
|
|
517
|
+
async getAttribute(selector, name, options = {}) {
|
|
518
|
+
const r = await this.#capture("CAPTURE_KIND_ATTRIBUTE", selector, name, options);
|
|
519
|
+
return r.value ?? null;
|
|
520
|
+
}
|
|
521
|
+
async boundingBox(selector, options = {}) {
|
|
522
|
+
const r = await this.#capture("CAPTURE_KIND_BOUNDING_BOX", selector, "", options);
|
|
523
|
+
return r.boundingBox ?? null;
|
|
524
|
+
}
|
|
479
525
|
async textContent(selector, options = {}) {
|
|
480
526
|
return this.#readText(selector, options, true);
|
|
481
527
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -133,6 +133,13 @@ export interface Browser extends BrowserInfo {
|
|
|
133
133
|
browserInfo(): BrowserInfo;
|
|
134
134
|
}
|
|
135
135
|
export interface Page extends PageInfo, WebLocators {
|
|
136
|
+
url(options?: CommandOptions): Promise<string>;
|
|
137
|
+
inputValue(selector: string, options?: CommandOptions): Promise<string>;
|
|
138
|
+
selectedOptions(selector: string, options?: CommandOptions): Promise<CapturedOption[]>;
|
|
139
|
+
selectedText(selector: string, options?: CommandOptions): Promise<string | null>;
|
|
140
|
+
isChecked(selector: string, options?: CommandOptions): Promise<boolean>;
|
|
141
|
+
getAttribute(selector: string, name: string, options?: CommandOptions): Promise<string | null>;
|
|
142
|
+
boundingBox(selector: string, options?: CommandOptions): Promise<BoundingBox | null>;
|
|
136
143
|
frame(selector: string, options?: CommandOptions): Promise<Page>;
|
|
137
144
|
registerHook<T>(type: HookType<T>): Promise<Hook<T>>;
|
|
138
145
|
accessibilitySnapshot(options?: AccessibilitySnapshotOptions): Promise<string>;
|
|
@@ -207,6 +214,12 @@ export interface MobileSurfaceNamespace {
|
|
|
207
214
|
};
|
|
208
215
|
}
|
|
209
216
|
export interface Locator extends WebLocators {
|
|
217
|
+
inputValue(options?: CommandOptions): Promise<string>;
|
|
218
|
+
selectedOptions(options?: CommandOptions): Promise<CapturedOption[]>;
|
|
219
|
+
selectedText(options?: CommandOptions): Promise<string | null>;
|
|
220
|
+
isChecked(options?: CommandOptions): Promise<boolean>;
|
|
221
|
+
getAttribute(name: string, options?: CommandOptions): Promise<string | null>;
|
|
222
|
+
boundingBox(options?: CommandOptions): Promise<BoundingBox | null>;
|
|
210
223
|
frame(options?: CommandOptions): Promise<Page>;
|
|
211
224
|
Frame(options?: CommandOptions): Promise<Page>;
|
|
212
225
|
not(other: Locator): Locator;
|
|
@@ -377,6 +390,7 @@ export interface SurfaceSessionEvent {
|
|
|
377
390
|
};
|
|
378
391
|
}
|
|
379
392
|
export interface ContextSessionEvent {
|
|
393
|
+
captureResolved?: CaptureResult;
|
|
380
394
|
frameResolved?: {
|
|
381
395
|
contextSessionId?: string;
|
|
382
396
|
};
|
|
@@ -816,6 +830,17 @@ export interface CloseContextRequest {
|
|
|
816
830
|
}
|
|
817
831
|
export type SurfaceSessionRequest = LaunchBrowserRequest | LaunchChromeRequest | OpenContextRequest | ConnectMobileRequest | LaunchAppRequest | SurfacePingRequest | CloseSurfaceRequest;
|
|
818
832
|
export type ContextSessionRequest = {
|
|
833
|
+
surfaceSessionId: string;
|
|
834
|
+
contextSessionId: string;
|
|
835
|
+
capture: {
|
|
836
|
+
kind: string;
|
|
837
|
+
cssSelector: string;
|
|
838
|
+
attributeName: string;
|
|
839
|
+
retryOptions?: {
|
|
840
|
+
timeoutMs: number;
|
|
841
|
+
};
|
|
842
|
+
};
|
|
843
|
+
} | {
|
|
819
844
|
surfaceSessionId: string;
|
|
820
845
|
contextSessionId: string;
|
|
821
846
|
resolveFrame: {
|
|
@@ -866,3 +891,20 @@ export declare class EventQueue<T> {
|
|
|
866
891
|
fail(error: Error): void;
|
|
867
892
|
next(): Promise<T>;
|
|
868
893
|
}
|
|
894
|
+
export interface CapturedOption {
|
|
895
|
+
value: string;
|
|
896
|
+
label: string;
|
|
897
|
+
index: number;
|
|
898
|
+
}
|
|
899
|
+
export interface BoundingBox {
|
|
900
|
+
x: number;
|
|
901
|
+
y: number;
|
|
902
|
+
width: number;
|
|
903
|
+
height: number;
|
|
904
|
+
}
|
|
905
|
+
export interface CaptureResult {
|
|
906
|
+
value?: string;
|
|
907
|
+
checked?: boolean;
|
|
908
|
+
selectedOptions?: CapturedOption[];
|
|
909
|
+
boundingBox?: BoundingBox;
|
|
910
|
+
}
|
package/package.json
CHANGED
|
@@ -38,6 +38,7 @@ message ContextSessionCommand {
|
|
|
38
38
|
SetMobileFileChooserFilesCommand set_mobile_file_chooser_files = 24;
|
|
39
39
|
SaveMobileDownloadCommand save_mobile_download = 25;
|
|
40
40
|
ResolveFrameCommand resolve_frame = 26;
|
|
41
|
+
CaptureCommand capture = 27;
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -78,6 +79,7 @@ message ContextSessionEvent {
|
|
|
78
79
|
MobileFileChooserFilesSetEvent mobile_file_chooser_files_set = 26;
|
|
79
80
|
MobileDownloadSavedEvent mobile_download_saved = 27;
|
|
80
81
|
FrameResolvedEvent frame_resolved = 28;
|
|
82
|
+
CaptureResolvedEvent capture_resolved = 29;
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
|
|
@@ -311,3 +313,40 @@ message AccessibilitySnapshotCapturedEvent {
|
|
|
311
313
|
string snapshot = 1;
|
|
312
314
|
string format = 2;
|
|
313
315
|
}
|
|
316
|
+
|
|
317
|
+
// Read-only web inspection. Element reads use the first locator match.
|
|
318
|
+
enum CaptureKind {
|
|
319
|
+
CAPTURE_KIND_UNSPECIFIED = 0;
|
|
320
|
+
CAPTURE_KIND_URL = 1;
|
|
321
|
+
CAPTURE_KIND_INPUT_VALUE = 2;
|
|
322
|
+
CAPTURE_KIND_SELECTED_OPTIONS = 3;
|
|
323
|
+
CAPTURE_KIND_SELECTED_TEXT = 4;
|
|
324
|
+
CAPTURE_KIND_CHECKED = 5;
|
|
325
|
+
CAPTURE_KIND_ATTRIBUTE = 6;
|
|
326
|
+
CAPTURE_KIND_BOUNDING_BOX = 7;
|
|
327
|
+
}
|
|
328
|
+
message CaptureCommand {
|
|
329
|
+
CaptureKind kind = 1;
|
|
330
|
+
string css_selector = 2;
|
|
331
|
+
string attribute_name = 3;
|
|
332
|
+
optional CommandRetryOptions retry_options = 4;
|
|
333
|
+
}
|
|
334
|
+
message CapturedOption {
|
|
335
|
+
string value = 1;
|
|
336
|
+
string label = 2;
|
|
337
|
+
uint32 index = 3;
|
|
338
|
+
}
|
|
339
|
+
message BoundingBox {
|
|
340
|
+
double x = 1;
|
|
341
|
+
double y = 2;
|
|
342
|
+
double width = 3;
|
|
343
|
+
double height = 4;
|
|
344
|
+
}
|
|
345
|
+
message CaptureResolvedEvent {
|
|
346
|
+
// Absent for a missing attribute or unsupported text selection.
|
|
347
|
+
optional string value = 1;
|
|
348
|
+
optional bool checked = 2;
|
|
349
|
+
repeated CapturedOption selected_options = 3;
|
|
350
|
+
// Viewport coordinates in CSS pixels, absent for an element without a visible box.
|
|
351
|
+
optional BoundingBox bounding_box = 4;
|
|
352
|
+
}
|