testsurfer 0.1.2 → 0.3.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.
Files changed (84) hide show
  1. package/README.md +52 -149
  2. package/dist/browser.d.ts +135 -1
  3. package/dist/browser.js +378 -2
  4. package/dist/browser.js.map +1 -1
  5. package/dist/cli.d.ts +16 -0
  6. package/dist/cli.js +140 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/client.d.ts +12 -2
  9. package/dist/client.js +73 -4
  10. package/dist/client.js.map +1 -1
  11. package/dist/diff.d.ts +19 -0
  12. package/dist/diff.js +116 -0
  13. package/dist/diff.js.map +1 -0
  14. package/dist/events.d.ts +386 -0
  15. package/dist/events.js +1035 -0
  16. package/dist/events.js.map +1 -0
  17. package/dist/expect.d.ts +135 -26
  18. package/dist/expect.js +634 -130
  19. package/dist/expect.js.map +1 -1
  20. package/dist/frame.d.ts +88 -0
  21. package/dist/frame.js +194 -0
  22. package/dist/frame.js.map +1 -0
  23. package/dist/global.d.ts +12 -0
  24. package/dist/global.js +136 -0
  25. package/dist/global.js.map +1 -0
  26. package/dist/hooks.d.ts +28 -0
  27. package/dist/hooks.js +48 -0
  28. package/dist/hooks.js.map +1 -0
  29. package/dist/index.d.ts +22 -3
  30. package/dist/index.js +21 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/injected.d.ts +15 -0
  33. package/dist/injected.js +2025 -0
  34. package/dist/injected.js.map +1 -0
  35. package/dist/locator.d.ts +374 -86
  36. package/dist/locator.js +845 -244
  37. package/dist/locator.js.map +1 -1
  38. package/dist/media.d.ts +15 -0
  39. package/dist/media.js +83 -0
  40. package/dist/media.js.map +1 -0
  41. package/dist/net.d.ts +110 -0
  42. package/dist/net.js +498 -0
  43. package/dist/net.js.map +1 -0
  44. package/dist/page.d.ts +448 -5
  45. package/dist/page.js +1187 -31
  46. package/dist/page.js.map +1 -1
  47. package/dist/png.d.ts +28 -0
  48. package/dist/png.js +197 -0
  49. package/dist/png.js.map +1 -0
  50. package/dist/pwconfig.d.ts +66 -0
  51. package/dist/pwconfig.js +77 -0
  52. package/dist/pwconfig.js.map +1 -0
  53. package/dist/register.d.ts +6 -0
  54. package/dist/register.js +9 -0
  55. package/dist/register.js.map +1 -0
  56. package/dist/request.d.ts +29 -0
  57. package/dist/request.js +75 -0
  58. package/dist/request.js.map +1 -0
  59. package/dist/runner.d.ts +99 -15
  60. package/dist/runner.js +354 -58
  61. package/dist/runner.js.map +1 -1
  62. package/dist/screenshot.d.ts +35 -0
  63. package/dist/screenshot.js +171 -0
  64. package/dist/screenshot.js.map +1 -0
  65. package/dist/selector.d.ts +55 -0
  66. package/dist/selector.js +208 -0
  67. package/dist/selector.js.map +1 -0
  68. package/dist/selectors.d.ts +13 -0
  69. package/dist/selectors.js +16 -0
  70. package/dist/selectors.js.map +1 -0
  71. package/dist/serialize.d.ts +17 -0
  72. package/dist/serialize.js +149 -0
  73. package/dist/serialize.js.map +1 -0
  74. package/dist/shim.d.ts +15 -0
  75. package/dist/shim.js +211 -0
  76. package/dist/shim.js.map +1 -0
  77. package/dist/testinfo.d.ts +62 -0
  78. package/dist/testinfo.js +23 -0
  79. package/dist/testinfo.js.map +1 -0
  80. package/dist/values.d.ts +67 -0
  81. package/dist/values.js +293 -0
  82. package/dist/values.js.map +1 -0
  83. package/package.json +10 -3
  84. package/skills/testsurfer/SKILL.md +55 -0
package/dist/locator.d.ts CHANGED
@@ -1,24 +1,51 @@
1
1
  /**
2
- * Locators: lazy, re-resolving element handles over the a11y tree.
2
+ * Locators: lazy, re-resolving element queries.
3
3
  *
4
- * A locator stores a query (role + name, text, or label), not a ref.
5
- * Every action and assertion re-resolves the query against a fresh
6
- * view, so locators survive re-renders and navigation. Actions retry
7
- * on STALE_TOKEN and NOT_FOUND until the action timeout elapses.
4
+ * A locator stores a chain of queries, never an element. Every action
5
+ * and read resolves the chain again, in the page, through the engine
6
+ * in src/injected.ts, so locators survive re-renders and navigation.
7
+ * Single-element operations are strict: more than one match is an
8
+ * error unless first(), last() or nth() picks one. Actions wait until
9
+ * the element is attached, visible, enabled and not covered, then
10
+ * click with trusted native input at its center.
8
11
  */
9
- import { type Snapshot, type TreeNode } from './tree.ts';
10
- import type { LayoutRect, Page } from './page.ts';
12
+ import { type CssExtras } from './selector.ts';
13
+ import type { Snapshot } from './tree.ts';
14
+ import type { Page } from './page.ts';
15
+ import type { Frame as FrameType } from './frame.ts';
11
16
  export interface ByRoleOptions {
12
- /** Accessible name. String: whole-string, case-insensitive (case-sensitive with exact). RegExp: tested as-is. */
17
+ /** Accessible name. String: case-insensitive substring (whole string and case-sensitive with exact). RegExp: tested as-is. */
13
18
  name?: string | RegExp;
14
19
  exact?: boolean;
15
- /** Heading level, matched against the node's level attribute. */
20
+ checked?: boolean | 'mixed';
21
+ disabled?: boolean;
22
+ expanded?: boolean;
23
+ includeHidden?: boolean;
24
+ /** Heading level, from h1-h6 or aria-level. */
16
25
  level?: number;
26
+ pressed?: boolean | 'mixed';
27
+ selected?: boolean;
28
+ /** @internal role= selector `[name="x"]`: whole string, case-insensitive. */
29
+ nameFull?: boolean;
17
30
  }
18
31
  export interface ByTextOptions {
19
32
  /** String matching is substring, case-insensitive; exact makes it whole-string, case-sensitive. */
20
33
  exact?: boolean;
21
34
  }
35
+ export interface FilterOptions {
36
+ /** Keep matches whose text contains this (substring, case-insensitive) or matches the RegExp. */
37
+ hasText?: string | RegExp;
38
+ /** Drop matches whose text contains this. */
39
+ hasNotText?: string | RegExp;
40
+ /** Keep matches that contain an element matching this locator. */
41
+ has?: Locator;
42
+ /** Drop matches that contain an element matching this locator. */
43
+ hasNot?: Locator;
44
+ /** Keep only visible (true) or only hidden (false) matches. */
45
+ visible?: boolean;
46
+ }
47
+ /** page.locator() / locator.locator() options: the same filters, minus visible. */
48
+ export type LocatorOptions = Omit<FilterOptions, 'visible'>;
22
49
  export type LocatorQuery = {
23
50
  kind: 'role';
24
51
  role: string;
@@ -27,116 +54,234 @@ export type LocatorQuery = {
27
54
  kind: 'text';
28
55
  text: string | RegExp;
29
56
  options: ByTextOptions;
57
+ light?: boolean;
58
+ legacy?: boolean;
30
59
  } | {
31
60
  kind: 'label';
32
61
  text: string | RegExp;
33
62
  options: ByTextOptions;
63
+ } | {
64
+ kind: 'css';
65
+ selector: string;
66
+ extras?: CssExtras;
67
+ light?: boolean;
68
+ } | {
69
+ kind: 'xpath';
70
+ xpath: string;
71
+ } | {
72
+ kind: 'attr';
73
+ method: string;
74
+ attr: string;
75
+ value: string | RegExp;
76
+ exact: boolean;
77
+ } | {
78
+ kind: 'and' | 'or';
79
+ left: Locator;
80
+ right: Locator;
81
+ } | {
82
+ kind: 'frame';
83
+ }
84
+ /** The previous step's matches themselves, so an index or filter can apply after an index. */
85
+ | {
86
+ kind: 'self';
87
+ }
88
+ /** A held element (ElementHandle). */
89
+ | {
90
+ kind: 'handle';
91
+ id: number;
92
+ }
93
+ /** A selector that failed to parse; resolving it throws `message`. */
94
+ | {
95
+ kind: 'invalid';
96
+ selector: string;
97
+ message: string;
98
+ };
99
+ /** One link of a chain: a query, its filters, and an optional index. */
100
+ export interface Step {
101
+ query: LocatorQuery;
102
+ filters: FilterOptions[];
103
+ /** nth() index; negative counts from the end (last() is -1). */
104
+ index: number | null;
105
+ /** The marked part of a `*css=` capture selector. */
106
+ capture?: boolean;
107
+ }
108
+ export interface BoundingBox {
109
+ x: number;
110
+ y: number;
111
+ width: number;
112
+ height: number;
113
+ }
114
+ export interface ActionOptions {
115
+ timeout?: number;
116
+ force?: boolean;
117
+ noWaitAfter?: boolean;
118
+ trial?: boolean;
119
+ }
120
+ export interface ClickOptions extends ActionOptions {
121
+ button?: 'left' | 'right' | 'middle';
122
+ clickCount?: number;
123
+ delay?: number;
124
+ modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[];
125
+ position?: {
126
+ x: number;
127
+ y: number;
128
+ };
129
+ }
130
+ export type SelectOptionValue = string | {
131
+ value?: string;
132
+ label?: string;
133
+ index?: number;
134
+ };
135
+ export type InputFile = string | {
136
+ name: string;
137
+ mimeType: string;
138
+ buffer: Buffer;
34
139
  };
35
140
  export declare function describeQuery(query: LocatorQuery): string;
36
- export declare function findMatches(snap: Snapshot, query: LocatorQuery): TreeNode[];
141
+ export declare function byAttr(method: string, attr: string, value: string | RegExp, exact: boolean): LocatorQuery;
142
+ /** A Playwright selector string as chain steps. */
143
+ export declare function selectorSteps(selector: string): Step[];
37
144
  export declare class Locator {
38
- private readonly page;
39
- private readonly query;
40
- private readonly index;
41
- /** Refs from the previous visibility resolve, used as the composite layout hint. */
42
- private layoutHint;
43
- constructor(page: Page, query: LocatorQuery, index?: number | null);
145
+ private readonly owner;
146
+ private readonly steps;
147
+ private readonly desc;
148
+ constructor(page: Page, steps: Step[] | LocatorQuery, description?: string);
44
149
  /** The owning page's expect timeout, used as the assertion default. */
45
150
  get expectTimeout(): number;
46
- /** Pick the first match instead of failing on multiple matches. */
151
+ /** The page this locator belongs to. */
152
+ page(): Page;
153
+ /** The chain in the engine's wire form. */
154
+ wire(): unknown[];
155
+ /** Steps up to and including the last frame hop, and the rest. */
156
+ private frameSplit;
157
+ private static stepsText;
158
+ /**
159
+ * and()/or(): both sides inside the same frame compose inside it;
160
+ * frame locators on different frames cannot be combined.
161
+ */
162
+ private composite;
163
+ private get tail();
164
+ private withTail;
165
+ /** This chain followed by `more`. */
166
+ extendWith(more: Step[]): Locator;
167
+ private chain;
47
168
  first(): Locator;
48
- /** Pick the i-th match (0-based) instead of failing on multiple matches. */
169
+ last(): Locator;
170
+ /** The i-th match (0-based; negative counts from the end). */
49
171
  nth(index: number): Locator;
172
+ filter(options: FilterOptions): Locator;
173
+ and(other: Locator): Locator;
174
+ or(other: Locator): Locator;
175
+ /** A selector (or another locator) searched inside this locator's matches. */
176
+ locator(selector: string | Locator, options?: LocatorOptions): Locator;
177
+ getByRole(role: string, options?: ByRoleOptions): Locator;
178
+ getByText(text: string | RegExp, options?: ByTextOptions): Locator;
179
+ getByLabel(text: string | RegExp, options?: ByTextOptions): Locator;
180
+ getByTestId(id: string | RegExp): Locator;
181
+ getByPlaceholder(text: string | RegExp, options?: ByTextOptions): Locator;
182
+ getByAltText(text: string | RegExp, options?: ByTextOptions): Locator;
183
+ getByTitle(text: string | RegExp, options?: ByTextOptions): Locator;
184
+ /** `fn(element, arg)` in the page, keeping the result there as a handle. */
185
+ evaluateHandle<A = unknown>(fn: string | ((el: any, arg: A) => unknown), arg?: A, options?: {
186
+ timeout?: number;
187
+ }): Promise<JSHandle>;
188
+ /** The matched element as an ElementHandle (waits for it, strict). */
189
+ elementHandle(options?: {
190
+ timeout?: number;
191
+ }): Promise<ElementHandle>;
192
+ /** Every current match as an ElementHandle. */
193
+ elementHandles(): Promise<ElementHandle[]>;
194
+ /** The first match as an ElementHandle, or null (no waiting, not strict). */
195
+ firstHandle(): Promise<ElementHandle | null>;
196
+ /** The content of the iframe this locator matches. */
197
+ contentFrame(): FrameLocator;
198
+ /** The iframe matching `selector` inside this locator's matches. */
199
+ frameLocator(selector: string): FrameLocator;
200
+ /** The same locator, shown as `description` in errors and toString(). */
201
+ /** The text given to describe(), or null. */
202
+ description(): string | null;
203
+ describe(description: string): Locator;
50
204
  toString(): string;
205
+ private run;
206
+ private strictError;
51
207
  /**
52
- * All current matches against a fresh view. Visible matches are
53
- * preferred, judged from the tree alone (hid=1 on self or ancestor):
54
- * hidden duplicates of interactive elements are dropped when a
55
- * visible one exists. No layout round trip.
208
+ * Run a one-element op, waiting until something matches and the op
209
+ * stops asking to retry. Strict-mode violations fail at once.
56
210
  */
57
- resolveAll(): Promise<TreeNode[]>;
211
+ private waitOne;
212
+ /** One-element op with no waiting: undefined when nothing matches. */
213
+ peek<T>(apiName: string, op: string, args?: unknown): Promise<{
214
+ found: boolean;
215
+ v?: T;
216
+ preview?: string;
217
+ }>;
218
+ /** A multi-element op over the current matches. */
219
+ many<T>(op: string, args?: unknown, fn?: string): Promise<T>;
58
220
  /**
59
- * Matches that are currently visible. Interactive refs carry hid=1
60
- * in the tree, but hidden non-interactive elements (a heading inside
61
- * a `hidden` container) do not, so survivors are verified against
62
- * vs_layout's per-ref visible flag.
221
+ * Click the element. A left click without modifiers is a trusted
222
+ * native click at the element's center; other buttons, modifiers and
223
+ * multi-clicks are dispatched in the page.
63
224
  */
64
- resolveVisible(): Promise<TreeNode[]>;
65
- /** Strict-mode selection: exactly one node, nth() overrides, null when none. */
66
- private pickOne;
225
+ click(options?: ClickOptions): Promise<void>;
67
226
  /**
68
- * Resolve an action target against the cached snapshot when it is
69
- * still baseline-synced. Optimistic concurrency covers the race: if
70
- * the page changed since, the act fails with STALE_TOKEN, the retry
71
- * loop refreshes, and we re-resolve.
227
+ * Whether the last native click's release reached the page without a
228
+ * click event. The page can answer before the mouse events arrive
229
+ * (WebKit sends each once the last is acknowledged), so this waits
230
+ * for the release first; click follows mouseup in the same dispatch.
72
231
  */
73
- private resolveForAction;
74
- /** Wait until the locator resolves to one node, then run the action, retrying on staleness. */
75
- private withResolved;
232
+ private clickWasLost;
233
+ dblclick(options?: Omit<ClickOptions, 'clickCount'>): Promise<void>;
234
+ tap(options?: ClickOptions): Promise<void>;
235
+ /** Move the pointer over the element with trusted input. */
236
+ hover(options?: ActionOptions & {
237
+ position?: {
238
+ x: number;
239
+ y: number;
240
+ };
241
+ }): Promise<void>;
242
+ /** Replace the field's value (inputs, textareas, contenteditable). */
243
+ fill(value: string, options?: ActionOptions): Promise<void>;
244
+ clear(options?: ActionOptions): Promise<void>;
76
245
  /**
77
- * Click the element. Visible targets get a trusted native click at
78
- * their rect center via vs_click_at, which honors the page's input
79
- * mode (robotic by default; the humanized path behind plain
80
- * `vs_act click` costs seconds per click). Zero-size or hidden
81
- * targets cannot be hit by coordinates and fall back to vs_act,
82
- * whose JS path dispatches regardless of geometry.
246
+ * Focus the element, then type with trusted per-character key events
247
+ * (isTrusted=true), for editors that ignore fill().
83
248
  */
84
- click(options?: {
249
+ pressSequentially(text: string, options?: {
250
+ delay?: number;
85
251
  timeout?: number;
86
252
  }): Promise<void>;
87
- /** Replace the field's text via the engine's fill path. */
88
- fill(value: string, options?: {
89
- timeout?: number;
90
- }): Promise<void>;
91
- /**
92
- * Focus the element, then send real per-character key events
93
- * (isTrusted=true), for rich-text editors and inputs that ignore a
94
- * programmatic fill. Use fill() for plain inputs.
95
- */
253
+ /** Same as pressSequentially(). */
96
254
  type(text: string, options?: {
255
+ delay?: number;
97
256
  timeout?: number;
98
257
  }): Promise<void>;
99
- /** Send a key chord to the element, e.g. `Enter` or `Ctrl+K`. */
258
+ /** Focus the element and press a key or chord, e.g. `Enter` or `Control+A`. */
100
259
  press(key: string, options?: {
101
- timeout?: number;
102
- }): Promise<void>;
103
- hover(options?: {
260
+ delay?: number;
104
261
  timeout?: number;
105
262
  }): Promise<void>;
106
263
  focus(options?: {
107
264
  timeout?: number;
108
265
  }): Promise<void>;
109
- /** Full text content of the element via vs_read. */
110
- textContent(options?: {
111
- timeout?: number;
112
- }): Promise<string>;
113
- /** Number of current matches (no waiting). */
114
- count(): Promise<number>;
115
- /** True if the locator has a visible match right now (no waiting). */
116
- isVisible(): Promise<boolean>;
117
- /** Checked state of a checkbox or radio, from the tree (vibesurfer 0.2.12+). */
118
- isChecked(options?: {
119
- timeout?: number;
120
- }): Promise<boolean>;
121
- /** Click a checkbox or radio unless it is already checked. */
122
- check(options?: {
266
+ blur(options?: {
123
267
  timeout?: number;
124
268
  }): Promise<void>;
125
- /** Click a checkbox unless it is already unchecked. */
126
- uncheck(options?: {
269
+ setChecked(checked: boolean, options?: ClickOptions): Promise<void>;
270
+ check(options?: ClickOptions): Promise<void>;
271
+ uncheck(options?: ClickOptions): Promise<void>;
272
+ /** Select options by value or label (or `{ value, label, index }`). Returns the selected values. */
273
+ selectOption(values: SelectOptionValue | SelectOptionValue[] | null, options?: ActionOptions): Promise<string[]>;
274
+ selectText(options?: ActionOptions): Promise<void>;
275
+ /** Set the files of an `<input type=file>`: paths, or `{ name, mimeType, buffer }`. */
276
+ setInputFiles(files: InputFile | InputFile[], options?: ActionOptions): Promise<void>;
277
+ dispatchEvent(type: string, eventInit?: Record<string, unknown>, options?: {
127
278
  timeout?: number;
128
279
  }): Promise<void>;
129
- /**
130
- * Current value of a text field or select. The tree labels a field
131
- * with its value; a password field reads `***` once filled.
132
- */
133
- inputValue(options?: {
280
+ scrollIntoViewIfNeeded(options?: {
134
281
  timeout?: number;
135
- }): Promise<string>;
136
- /** Viewport rect in CSS px, or null when the element is not rendered. */
137
- boundingBox(options?: {
138
- timeout?: number;
139
- }): Promise<LayoutRect | null>;
282
+ }): Promise<void>;
283
+ /** Accepted for compatibility; there is no headed browser to highlight in. */
284
+ highlight(): Promise<void>;
140
285
  /**
141
286
  * Drag this element onto `target` with a trusted press, move and
142
287
  * release from center to center. vibesurfer also fires the HTML5
@@ -145,13 +290,156 @@ export declare class Locator {
145
290
  dragTo(target: Locator, options?: {
146
291
  timeout?: number;
147
292
  }): Promise<void>;
148
- /** The matched element's subtree as template text (see toMatchAriaSnapshot). */
293
+ /** Wait for the locator to reach a state: attached, detached, visible (default) or hidden. */
294
+ waitFor(options?: {
295
+ state?: 'attached' | 'detached' | 'visible' | 'hidden';
296
+ timeout?: number;
297
+ }): Promise<void>;
298
+ textContent(options?: {
299
+ timeout?: number;
300
+ }): Promise<string>;
301
+ innerText(options?: {
302
+ timeout?: number;
303
+ }): Promise<string>;
304
+ innerHTML(options?: {
305
+ timeout?: number;
306
+ }): Promise<string>;
307
+ /** An attribute's value, or null when absent. */
308
+ getAttribute(name: string, options?: {
309
+ timeout?: number;
310
+ }): Promise<string | null>;
311
+ /** Current value of an input, textarea or select. */
312
+ inputValue(options?: {
313
+ timeout?: number;
314
+ }): Promise<string>;
315
+ isChecked(options?: {
316
+ timeout?: number;
317
+ }): Promise<boolean>;
318
+ /** Disabled natively (`disabled`, a disabled fieldset) or with `aria-disabled="true"`. */
319
+ isDisabled(options?: {
320
+ timeout?: number;
321
+ }): Promise<boolean>;
322
+ isEnabled(options?: {
323
+ timeout?: number;
324
+ }): Promise<boolean>;
325
+ isEditable(options?: {
326
+ timeout?: number;
327
+ }): Promise<boolean>;
328
+ isFocused(options?: {
329
+ timeout?: number;
330
+ }): Promise<boolean>;
331
+ /** True if the locator's element is visible right now (no waiting). */
332
+ isVisible(): Promise<boolean>;
333
+ isHidden(): Promise<boolean>;
334
+ /** Number of current matches (no waiting). A navigation mid-query counts as no matches. */
335
+ count(options?: {
336
+ __testHookBeforeQuery?: () => Promise<unknown>;
337
+ }): Promise<number>;
338
+ /** One locator per current match, in document order (no waiting). */
339
+ all(): Promise<Locator[]>;
340
+ allTextContents(): Promise<string[]>;
341
+ allInnerTexts(): Promise<string[]>;
342
+ /** Rect in CSS px relative to the main frame's viewport, or null when not rendered. */
343
+ boundingBox(options?: {
344
+ timeout?: number;
345
+ }): Promise<BoundingBox | null>;
346
+ /** Call `fn(element, arg)` in the page and return its result. */
347
+ evaluate<R, A = unknown>(fn: string | ((el: any, arg: A) => R | Promise<R>), arg?: A, options?: {
348
+ timeout?: number;
349
+ }): Promise<R>;
350
+ /** Call `fn(elements, arg)` with every match and return its result. */
351
+ evaluateAll<R, A = unknown>(fn: string | ((els: any[], arg: A) => R | Promise<R>), arg?: A): Promise<R>;
352
+ /** PNG of the element. Returns the bytes; with `path`, also writes the file. */
353
+ screenshot(options?: {
354
+ path?: string;
355
+ timeout?: number;
356
+ }): Promise<Buffer>;
357
+ /** The matched element's accessibility subtree as template text (see toMatchAriaSnapshot). */
149
358
  ariaSnapshot(options?: {
150
359
  timeout?: number;
151
360
  }): Promise<string>;
152
- /** Refs of the strict-mode match, for scoping a snapshot match. */
153
- resolveScope(): Promise<{
361
+ /** Tree refs of the strict-mode match, for scoping a snapshot match. */
362
+ resolveScope(timeout?: number): Promise<{
154
363
  snap: Snapshot;
155
364
  refs: number[];
156
365
  }>;
157
366
  }
367
+ /** Locators inside an iframe (Playwright's FrameLocator). */
368
+ export declare class FrameLocator {
369
+ private readonly frame;
370
+ constructor(frame: Locator);
371
+ /** The iframe element itself. */
372
+ owner(): Locator;
373
+ private inside;
374
+ first(): FrameLocator;
375
+ last(): FrameLocator;
376
+ nth(index: number): FrameLocator;
377
+ locator(selector: string | Locator, options?: LocatorOptions): Locator;
378
+ frameLocator(selector: string): FrameLocator;
379
+ getByRole(role: string, options?: ByRoleOptions): Locator;
380
+ getByText(text: string | RegExp, options?: ByTextOptions): Locator;
381
+ getByLabel(text: string | RegExp, options?: ByTextOptions): Locator;
382
+ getByTestId(id: string | RegExp): Locator;
383
+ getByPlaceholder(text: string | RegExp, options?: ByTextOptions): Locator;
384
+ getByAltText(text: string | RegExp, options?: ByTextOptions): Locator;
385
+ getByTitle(text: string | RegExp, options?: ByTextOptions): Locator;
386
+ }
387
+ /** A page value held by the test (Playwright's JSHandle). */
388
+ export declare class JSHandle {
389
+ readonly handleId: number;
390
+ readonly ownerPage: Page;
391
+ constructor(page: Page, id: number);
392
+ /** Call `fn(value, arg)` in the page. */
393
+ evaluate<R, A = unknown>(fn: string | ((v: any, arg: A) => R | Promise<R>), arg?: A): Promise<R>;
394
+ evaluateHandle<A = unknown>(fn: string | ((v: any, arg: A) => unknown), arg?: A): Promise<JSHandle>;
395
+ /** The value, serialized back. */
396
+ jsonValue<T = unknown>(): Promise<T>;
397
+ getProperty(name: string): Promise<JSHandle>;
398
+ getProperties(): Promise<Map<string, JSHandle>>;
399
+ asElement(): ElementHandle | null;
400
+ dispose(): Promise<void>;
401
+ /** @internal What the page showed for the value when it was adopted. */
402
+ previewText: string;
403
+ toString(): string;
404
+ }
405
+ /**
406
+ * An element held by the test (Playwright's ElementHandle). It is a
407
+ * locator pinned to that one element, so every locator method works on
408
+ * it; selectors on it search inside the element.
409
+ */
410
+ export declare class ElementHandle extends Locator {
411
+ readonly handleId: number;
412
+ readonly ownerPage: Page;
413
+ constructor(page: Page, id: number);
414
+ asElement(): ElementHandle;
415
+ /**
416
+ * The frame this <iframe> element hosts. Playwright gives handles an
417
+ * async contentFrame() returning a Frame, unlike Locator's, which
418
+ * returns a FrameLocator; the override is deliberately incompatible.
419
+ */
420
+ contentFrame(): Promise<FrameType | null>;
421
+ /** The frame the element is in (the main frame for top-level elements). */
422
+ ownerFrame(): Promise<FrameType>;
423
+ /** The first element matching `selector` inside this one, or null. */
424
+ $(selector: string): Promise<ElementHandle | null>;
425
+ $$(selector: string): Promise<ElementHandle[]>;
426
+ $eval<R, A = unknown>(selector: string, fn: string | ((el: any, arg: A) => R | Promise<R>), arg?: A): Promise<R>;
427
+ $$eval<R, A = unknown>(selector: string, fn: string | ((els: any[], arg: A) => R | Promise<R>), arg?: A): Promise<R>;
428
+ evaluateHandle<A = unknown>(fn: string | ((v: any, arg: A) => unknown), arg?: A): Promise<JSHandle>;
429
+ jsonValue<T = unknown>(): Promise<T>;
430
+ /** @internal Set when the handle came from evaluateHandle. */
431
+ previewText: string;
432
+ getProperty(name: string): Promise<JSHandle>;
433
+ getProperties(): Promise<Map<string, JSHandle>>;
434
+ dispose(): Promise<void>;
435
+ /** The element matching `selector` inside this one, once it reaches `state` (visible by default). */
436
+ waitForSelector(selector: string, options?: {
437
+ state?: 'attached' | 'detached' | 'visible' | 'hidden';
438
+ timeout?: number;
439
+ }): Promise<ElementHandle | null>;
440
+ /** Wait for the element to be visible, hidden, stable, enabled, disabled or editable. */
441
+ waitForElementState(state: 'visible' | 'hidden' | 'stable' | 'enabled' | 'disabled' | 'editable', options?: {
442
+ timeout?: number;
443
+ }): Promise<void>;
444
+ toString(): string;
445
+ }