@humanjs/playwright 0.5.0 → 0.7.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.
- package/README.md +68 -1
- package/dist/index.cjs +322 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +188 -9
- package/dist/index.d.ts +188 -9
- package/dist/index.js +322 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -163,6 +163,28 @@ interface CaptureResult {
|
|
|
163
163
|
cleanup(): Promise<void>;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
/** Options for {@link generatePlaywrightTest} / `Recording.toPlaywright`. */
|
|
167
|
+
interface PlaywrightTestOptions {
|
|
168
|
+
/**
|
|
169
|
+
* Keep recorded `sleep()` pauses. Default `false` — a test shouldn't carry
|
|
170
|
+
* human-timing waits (slow + flaky in CI; Playwright auto-waits instead).
|
|
171
|
+
*/
|
|
172
|
+
readonly keepSleeps?: boolean;
|
|
173
|
+
/** Test title. Defaults to the recording's name, else `'recorded session'`. */
|
|
174
|
+
readonly title?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Wrap actions in `test.step(...)` groups — a new step per navigation — so
|
|
177
|
+
* they show as collapsible sections in the HTML report / trace. Default false.
|
|
178
|
+
*/
|
|
179
|
+
readonly steps?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* When all `goto`s share one origin, emit them as relative paths and add a
|
|
182
|
+
* note to set `use.baseURL` in the Playwright config (portable across
|
|
183
|
+
* environments). Default false — absolute URLs that run without any config.
|
|
184
|
+
*/
|
|
185
|
+
readonly baseUrl?: boolean;
|
|
186
|
+
}
|
|
187
|
+
|
|
166
188
|
/**
|
|
167
189
|
* Encoding quality preset. Picks the per-frame capture quality + the
|
|
168
190
|
* ffmpeg encode settings used to assemble them into a video.
|
|
@@ -212,10 +234,18 @@ interface TimelineEvent {
|
|
|
212
234
|
readonly durationMs: number;
|
|
213
235
|
/** Error message, present only if the action threw. */
|
|
214
236
|
readonly error?: string;
|
|
237
|
+
/**
|
|
238
|
+
* For `type` / `paste`: the actual text written, captured when
|
|
239
|
+
* `captureInputs` is on (the default). Omitted when capture is off or the
|
|
240
|
+
* target is a password field (always masked). Flows into exported code.
|
|
241
|
+
*/
|
|
242
|
+
readonly inputValue?: string;
|
|
215
243
|
}
|
|
216
244
|
/** Structured action timeline of a recording. */
|
|
217
245
|
interface Timeline {
|
|
218
246
|
readonly version: 1;
|
|
247
|
+
/** Optional label for the recording (used as the generated test's title). */
|
|
248
|
+
readonly name?: string;
|
|
219
249
|
readonly personality: string;
|
|
220
250
|
readonly seed: string | null;
|
|
221
251
|
readonly speed: string;
|
|
@@ -224,6 +254,7 @@ interface Timeline {
|
|
|
224
254
|
}
|
|
225
255
|
/** Metadata passed from `human.record()` into the Recording constructor. */
|
|
226
256
|
interface RecordingTimelineSource {
|
|
257
|
+
readonly name?: string;
|
|
227
258
|
readonly personality: string;
|
|
228
259
|
readonly seed: string | null;
|
|
229
260
|
readonly speed: string;
|
|
@@ -288,6 +319,30 @@ declare class Recording {
|
|
|
288
319
|
* @returns the resolved output path.
|
|
289
320
|
*/
|
|
290
321
|
toTimeline(outputPath: string): Promise<string>;
|
|
322
|
+
/**
|
|
323
|
+
* Generates a standalone, runnable HumanJS script from the timeline and
|
|
324
|
+
* writes it to `outputPath`. String selectors round-trip verbatim; typed
|
|
325
|
+
* values are included when `captureInputs` was on (passwords masked).
|
|
326
|
+
*
|
|
327
|
+
* Independent of frame capture — works on timeline-only recordings and is
|
|
328
|
+
* unaffected by `dispose()`.
|
|
329
|
+
*
|
|
330
|
+
* @returns the resolved output path.
|
|
331
|
+
*/
|
|
332
|
+
toHumanJS(outputPath: string): Promise<string>;
|
|
333
|
+
/**
|
|
334
|
+
* Generates a `@playwright/test` spec from the timeline — a humanized test
|
|
335
|
+
* (uses `createHuman` + `human.*`), not raw Playwright — and writes it to
|
|
336
|
+
* `outputPath`. Runs instant in CI / recorded speed locally, drops timing
|
|
337
|
+
* `sleep()`s (pass `{ keepSleeps: true }` to keep them), and derives the
|
|
338
|
+
* assertions it safely can.
|
|
339
|
+
*
|
|
340
|
+
* Independent of frame capture — works on timeline-only recordings and is
|
|
341
|
+
* unaffected by `dispose()`.
|
|
342
|
+
*
|
|
343
|
+
* @returns the resolved output path.
|
|
344
|
+
*/
|
|
345
|
+
toPlaywright(outputPath: string, options?: PlaywrightTestOptions): Promise<string>;
|
|
291
346
|
/**
|
|
292
347
|
* Releases the captured-frames temp directory. After this call, `toVideo()`
|
|
293
348
|
* and `toGif()` throw — but `toTimeline()` and the in-memory `timeline`
|
|
@@ -458,21 +513,29 @@ interface Human {
|
|
|
458
513
|
/**
|
|
459
514
|
* Move the mouse along a humanized Bezier path to `target` and click.
|
|
460
515
|
*
|
|
461
|
-
* `target` accepts
|
|
462
|
-
* `'button:has-text("Buy now")'`)
|
|
463
|
-
*
|
|
516
|
+
* `target` accepts a Playwright-compatible selector string (e.g.
|
|
517
|
+
* `'button:has-text("Buy now")'`), a built `Locator`, or a raw `Point`.
|
|
518
|
+
* For element targets the click point is Gaussian-distributed around the
|
|
519
|
+
* center; for a raw `Point` the exact coordinates are clicked. The
|
|
520
|
+
* `Point` form is the fallback for things with no clean selector —
|
|
521
|
+
* icon-only buttons, canvas, SVG — where you can see the pixel position
|
|
522
|
+
* but can't address the element.
|
|
464
523
|
*
|
|
465
|
-
* In `speed: 'instant'`, all humanization is skipped
|
|
466
|
-
* native `locator.click()`
|
|
524
|
+
* In `speed: 'instant'`, all humanization is skipped: element targets use
|
|
525
|
+
* Playwright's native `locator.click()`; a `Point` dispatches one
|
|
526
|
+
* `mouse.click()` at the coordinates.
|
|
467
527
|
*/
|
|
468
|
-
click(target:
|
|
528
|
+
click(target: MouseTarget): Promise<void>;
|
|
469
529
|
/**
|
|
470
530
|
* Right-click `target` — opens a native context menu. Same Bezier-path
|
|
471
531
|
* motion and hover dwell as `click()`; only the dispatched button differs.
|
|
532
|
+
* Accepts the same selector / `Locator` / `Point` targets as `click()`.
|
|
472
533
|
*
|
|
473
|
-
* In `speed: 'instant'`,
|
|
534
|
+
* In `speed: 'instant'`, element targets fall back to
|
|
535
|
+
* `locator.click({ button: 'right' })`; a `Point` dispatches one
|
|
536
|
+
* `mouse.click({ button: 'right' })` at the coordinates.
|
|
474
537
|
*/
|
|
475
|
-
rightClick(target:
|
|
538
|
+
rightClick(target: MouseTarget): Promise<void>;
|
|
476
539
|
/**
|
|
477
540
|
* Move the cursor to `target` along a humanized Bezier path and settle
|
|
478
541
|
* on it — no click is dispatched. Useful for hover-triggered UI
|
|
@@ -670,9 +733,110 @@ interface Human {
|
|
|
670
733
|
*/
|
|
671
734
|
record(fn: () => Promise<void>): Promise<Recording>;
|
|
672
735
|
record(options: HumanRecordOptions, fn: () => Promise<void>): Promise<Recording>;
|
|
736
|
+
/**
|
|
737
|
+
* Take a screenshot of the page. Forwards to `page.screenshot(options)`
|
|
738
|
+
* unchanged — see Playwright docs for the full options shape.
|
|
739
|
+
*
|
|
740
|
+
* Not a humanized action: no plugin events fire. Pure ergonomic
|
|
741
|
+
* re-export so `human.*` stays a single surface.
|
|
742
|
+
*/
|
|
743
|
+
screenshot(options?: Parameters<Page['screenshot']>[0]): Promise<Buffer>;
|
|
744
|
+
/**
|
|
745
|
+
* Visible text content of the page (`document.body.innerText`). Forwards
|
|
746
|
+
* to `page.innerText('body')`. Useful for AI agents that need to
|
|
747
|
+
* understand what's on screen without parsing HTML.
|
|
748
|
+
*
|
|
749
|
+
* For a region instead of the whole page, use `page.innerText(selector)`.
|
|
750
|
+
*
|
|
751
|
+
* Not a humanized action: no plugin events fire.
|
|
752
|
+
*/
|
|
753
|
+
pageText(): Promise<string>;
|
|
754
|
+
/**
|
|
755
|
+
* Full HTML of the page. Forwards to `page.content()`. Often large
|
|
756
|
+
* (50–500 KB on typical sites) — prefer {@link Human.pageText} when
|
|
757
|
+
* passing to an LLM unless structure matters.
|
|
758
|
+
*
|
|
759
|
+
* Not a humanized action: no plugin events fire.
|
|
760
|
+
*/
|
|
761
|
+
content(): Promise<string>;
|
|
762
|
+
/**
|
|
763
|
+
* Current URL of the page. Forwards to `page.url()`. Synchronous return
|
|
764
|
+
* because Playwright's underlying API is sync.
|
|
765
|
+
*
|
|
766
|
+
* Not a humanized action: no plugin events fire.
|
|
767
|
+
*/
|
|
768
|
+
url(): string;
|
|
769
|
+
/**
|
|
770
|
+
* Current document title. Forwards to `page.title()`.
|
|
771
|
+
*
|
|
772
|
+
* Not a humanized action: no plugin events fire.
|
|
773
|
+
*/
|
|
774
|
+
title(): Promise<string>;
|
|
775
|
+
/**
|
|
776
|
+
* Reload the current page. Forwards to `page.reload(options)`. Real-user
|
|
777
|
+
* analog of hitting the refresh button — the click motion is *not*
|
|
778
|
+
* humanized (we treat reload as navigation, not a cursor action).
|
|
779
|
+
*
|
|
780
|
+
* Plugins observe a `'reload'` action.
|
|
781
|
+
*/
|
|
782
|
+
reload(options?: Parameters<Page['reload']>[0]): Promise<void>;
|
|
783
|
+
/**
|
|
784
|
+
* Navigate back in the browser history. Forwards to `page.goBack(options)`.
|
|
785
|
+
*
|
|
786
|
+
* Plugins observe a `'goBack'` action.
|
|
787
|
+
*/
|
|
788
|
+
goBack(options?: Parameters<Page['goBack']>[0]): Promise<void>;
|
|
789
|
+
/**
|
|
790
|
+
* Navigate forward in the browser history. Forwards to
|
|
791
|
+
* `page.goForward(options)`.
|
|
792
|
+
*
|
|
793
|
+
* Plugins observe a `'goForward'` action.
|
|
794
|
+
*/
|
|
795
|
+
goForward(options?: Parameters<Page['goForward']>[0]): Promise<void>;
|
|
796
|
+
/**
|
|
797
|
+
* Wait until the page reaches the specified load state. Forwards to
|
|
798
|
+
* `page.waitForLoadState(state, options)`. Common after a humanized
|
|
799
|
+
* click that triggers navigation — gives the page time to settle before
|
|
800
|
+
* the next action.
|
|
801
|
+
*
|
|
802
|
+
* Not a humanized action: no plugin events fire.
|
|
803
|
+
*/
|
|
804
|
+
waitForLoadState(state?: Parameters<Page['waitForLoadState']>[0], options?: Parameters<Page['waitForLoadState']>[1]): Promise<void>;
|
|
805
|
+
/**
|
|
806
|
+
* Wait until the page's URL matches `url` (string, RegExp, or predicate).
|
|
807
|
+
* Forwards to `page.waitForURL(url, options)`. Common post-action wait
|
|
808
|
+
* (e.g. after `human.click('#login')`, wait for `/dashboard`).
|
|
809
|
+
*
|
|
810
|
+
* Not a humanized action: no plugin events fire.
|
|
811
|
+
*/
|
|
812
|
+
waitForURL(url: Parameters<Page['waitForURL']>[0], options?: Parameters<Page['waitForURL']>[1]): Promise<void>;
|
|
813
|
+
/**
|
|
814
|
+
* Resize the viewport. Forwards to `page.setViewportSize(size)`. Useful
|
|
815
|
+
* for testing responsive layouts or switching between breakpoints
|
|
816
|
+
* mid-session.
|
|
817
|
+
*
|
|
818
|
+
* Not a humanized action: no plugin events fire.
|
|
819
|
+
*/
|
|
820
|
+
setViewportSize(size: {
|
|
821
|
+
width: number;
|
|
822
|
+
height: number;
|
|
823
|
+
}): Promise<void>;
|
|
824
|
+
/**
|
|
825
|
+
* Render the page as a PDF. Forwards to `page.pdf(options)`. Chromium
|
|
826
|
+
* only; works most reliably in headless mode (in headed mode, Playwright
|
|
827
|
+
* silently switches to a print-style render).
|
|
828
|
+
*
|
|
829
|
+
* Not a humanized action: no plugin events fire.
|
|
830
|
+
*/
|
|
831
|
+
pdf(options?: Parameters<Page['pdf']>[0]): Promise<Buffer>;
|
|
673
832
|
}
|
|
674
833
|
/** Options for {@link Human.record}. */
|
|
675
834
|
interface HumanRecordOptions {
|
|
835
|
+
/**
|
|
836
|
+
* Optional label for the recording. Stored on the timeline and used as the
|
|
837
|
+
* title of a generated `toPlaywright()` test.
|
|
838
|
+
*/
|
|
839
|
+
readonly name?: string;
|
|
676
840
|
/**
|
|
677
841
|
* Whether to capture frames for video output. Defaults to `true`.
|
|
678
842
|
* Set to `false` for timeline-only recordings (no capture loop, no
|
|
@@ -685,6 +849,21 @@ interface HumanRecordOptions {
|
|
|
685
849
|
* Defaults to `'high'`. Ignored when `video: false`.
|
|
686
850
|
*/
|
|
687
851
|
readonly quality?: RecordingQuality;
|
|
852
|
+
/**
|
|
853
|
+
* Capture the actual typed/pasted text into the timeline (and therefore
|
|
854
|
+
* into code generated by `toHumanJS()` / `toPlaywright()`). Defaults to
|
|
855
|
+
* `true`.
|
|
856
|
+
*
|
|
857
|
+
* Values typed/pasted into `input[type="password"]` are always masked
|
|
858
|
+
* (omitted) regardless of this flag — the video already renders them as
|
|
859
|
+
* dots, and freezing a cleartext secret into an artifact would leak more
|
|
860
|
+
* than the recording itself. Set `false` to record no input values at all;
|
|
861
|
+
* exporters then emit empty-string placeholders.
|
|
862
|
+
*
|
|
863
|
+
* Captured values land in the timeline JSON and any exported test, so treat
|
|
864
|
+
* those artifacts with the same care as the values themselves.
|
|
865
|
+
*/
|
|
866
|
+
readonly captureInputs?: boolean;
|
|
688
867
|
}
|
|
689
868
|
/**
|
|
690
869
|
* Creates a humanized session bound to a Playwright `Page`.
|
|
@@ -707,4 +886,4 @@ interface HumanRecordOptions {
|
|
|
707
886
|
*/
|
|
708
887
|
declare function createHuman(page: Page, options?: CreateHumanOptions): Promise<Human>;
|
|
709
888
|
|
|
710
|
-
export { type CreateHumanOptions, type FfmpegPreset, type FfmpegTune, type Human, type HumanRecordOptions, type InstallMouseHelperOptions, type KeyModifier, type KeyName, type KeyOrChord, type MouseTarget, type PressResult, type ReadOptions, type ReadResult, type ReadTarget, Recording, type RecordingQuality, type ScrollOptions, type ScrollResult, type ScrollTarget, type Speed, type Timeline, type TimelineEvent, type ToGifOptions, type ToVideoOptions, createHuman, installMouseHelper };
|
|
889
|
+
export { type CreateHumanOptions, type FfmpegPreset, type FfmpegTune, type Human, type HumanRecordOptions, type InstallMouseHelperOptions, type KeyModifier, type KeyName, type KeyOrChord, type MouseTarget, type PlaywrightTestOptions, type PressResult, type ReadOptions, type ReadResult, type ReadTarget, Recording, type RecordingQuality, type ScrollOptions, type ScrollResult, type ScrollTarget, type Speed, type Timeline, type TimelineEvent, type ToGifOptions, type ToVideoOptions, createHuman, installMouseHelper };
|
package/dist/index.d.ts
CHANGED
|
@@ -163,6 +163,28 @@ interface CaptureResult {
|
|
|
163
163
|
cleanup(): Promise<void>;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
/** Options for {@link generatePlaywrightTest} / `Recording.toPlaywright`. */
|
|
167
|
+
interface PlaywrightTestOptions {
|
|
168
|
+
/**
|
|
169
|
+
* Keep recorded `sleep()` pauses. Default `false` — a test shouldn't carry
|
|
170
|
+
* human-timing waits (slow + flaky in CI; Playwright auto-waits instead).
|
|
171
|
+
*/
|
|
172
|
+
readonly keepSleeps?: boolean;
|
|
173
|
+
/** Test title. Defaults to the recording's name, else `'recorded session'`. */
|
|
174
|
+
readonly title?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Wrap actions in `test.step(...)` groups — a new step per navigation — so
|
|
177
|
+
* they show as collapsible sections in the HTML report / trace. Default false.
|
|
178
|
+
*/
|
|
179
|
+
readonly steps?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* When all `goto`s share one origin, emit them as relative paths and add a
|
|
182
|
+
* note to set `use.baseURL` in the Playwright config (portable across
|
|
183
|
+
* environments). Default false — absolute URLs that run without any config.
|
|
184
|
+
*/
|
|
185
|
+
readonly baseUrl?: boolean;
|
|
186
|
+
}
|
|
187
|
+
|
|
166
188
|
/**
|
|
167
189
|
* Encoding quality preset. Picks the per-frame capture quality + the
|
|
168
190
|
* ffmpeg encode settings used to assemble them into a video.
|
|
@@ -212,10 +234,18 @@ interface TimelineEvent {
|
|
|
212
234
|
readonly durationMs: number;
|
|
213
235
|
/** Error message, present only if the action threw. */
|
|
214
236
|
readonly error?: string;
|
|
237
|
+
/**
|
|
238
|
+
* For `type` / `paste`: the actual text written, captured when
|
|
239
|
+
* `captureInputs` is on (the default). Omitted when capture is off or the
|
|
240
|
+
* target is a password field (always masked). Flows into exported code.
|
|
241
|
+
*/
|
|
242
|
+
readonly inputValue?: string;
|
|
215
243
|
}
|
|
216
244
|
/** Structured action timeline of a recording. */
|
|
217
245
|
interface Timeline {
|
|
218
246
|
readonly version: 1;
|
|
247
|
+
/** Optional label for the recording (used as the generated test's title). */
|
|
248
|
+
readonly name?: string;
|
|
219
249
|
readonly personality: string;
|
|
220
250
|
readonly seed: string | null;
|
|
221
251
|
readonly speed: string;
|
|
@@ -224,6 +254,7 @@ interface Timeline {
|
|
|
224
254
|
}
|
|
225
255
|
/** Metadata passed from `human.record()` into the Recording constructor. */
|
|
226
256
|
interface RecordingTimelineSource {
|
|
257
|
+
readonly name?: string;
|
|
227
258
|
readonly personality: string;
|
|
228
259
|
readonly seed: string | null;
|
|
229
260
|
readonly speed: string;
|
|
@@ -288,6 +319,30 @@ declare class Recording {
|
|
|
288
319
|
* @returns the resolved output path.
|
|
289
320
|
*/
|
|
290
321
|
toTimeline(outputPath: string): Promise<string>;
|
|
322
|
+
/**
|
|
323
|
+
* Generates a standalone, runnable HumanJS script from the timeline and
|
|
324
|
+
* writes it to `outputPath`. String selectors round-trip verbatim; typed
|
|
325
|
+
* values are included when `captureInputs` was on (passwords masked).
|
|
326
|
+
*
|
|
327
|
+
* Independent of frame capture — works on timeline-only recordings and is
|
|
328
|
+
* unaffected by `dispose()`.
|
|
329
|
+
*
|
|
330
|
+
* @returns the resolved output path.
|
|
331
|
+
*/
|
|
332
|
+
toHumanJS(outputPath: string): Promise<string>;
|
|
333
|
+
/**
|
|
334
|
+
* Generates a `@playwright/test` spec from the timeline — a humanized test
|
|
335
|
+
* (uses `createHuman` + `human.*`), not raw Playwright — and writes it to
|
|
336
|
+
* `outputPath`. Runs instant in CI / recorded speed locally, drops timing
|
|
337
|
+
* `sleep()`s (pass `{ keepSleeps: true }` to keep them), and derives the
|
|
338
|
+
* assertions it safely can.
|
|
339
|
+
*
|
|
340
|
+
* Independent of frame capture — works on timeline-only recordings and is
|
|
341
|
+
* unaffected by `dispose()`.
|
|
342
|
+
*
|
|
343
|
+
* @returns the resolved output path.
|
|
344
|
+
*/
|
|
345
|
+
toPlaywright(outputPath: string, options?: PlaywrightTestOptions): Promise<string>;
|
|
291
346
|
/**
|
|
292
347
|
* Releases the captured-frames temp directory. After this call, `toVideo()`
|
|
293
348
|
* and `toGif()` throw — but `toTimeline()` and the in-memory `timeline`
|
|
@@ -458,21 +513,29 @@ interface Human {
|
|
|
458
513
|
/**
|
|
459
514
|
* Move the mouse along a humanized Bezier path to `target` and click.
|
|
460
515
|
*
|
|
461
|
-
* `target` accepts
|
|
462
|
-
* `'button:has-text("Buy now")'`)
|
|
463
|
-
*
|
|
516
|
+
* `target` accepts a Playwright-compatible selector string (e.g.
|
|
517
|
+
* `'button:has-text("Buy now")'`), a built `Locator`, or a raw `Point`.
|
|
518
|
+
* For element targets the click point is Gaussian-distributed around the
|
|
519
|
+
* center; for a raw `Point` the exact coordinates are clicked. The
|
|
520
|
+
* `Point` form is the fallback for things with no clean selector —
|
|
521
|
+
* icon-only buttons, canvas, SVG — where you can see the pixel position
|
|
522
|
+
* but can't address the element.
|
|
464
523
|
*
|
|
465
|
-
* In `speed: 'instant'`, all humanization is skipped
|
|
466
|
-
* native `locator.click()`
|
|
524
|
+
* In `speed: 'instant'`, all humanization is skipped: element targets use
|
|
525
|
+
* Playwright's native `locator.click()`; a `Point` dispatches one
|
|
526
|
+
* `mouse.click()` at the coordinates.
|
|
467
527
|
*/
|
|
468
|
-
click(target:
|
|
528
|
+
click(target: MouseTarget): Promise<void>;
|
|
469
529
|
/**
|
|
470
530
|
* Right-click `target` — opens a native context menu. Same Bezier-path
|
|
471
531
|
* motion and hover dwell as `click()`; only the dispatched button differs.
|
|
532
|
+
* Accepts the same selector / `Locator` / `Point` targets as `click()`.
|
|
472
533
|
*
|
|
473
|
-
* In `speed: 'instant'`,
|
|
534
|
+
* In `speed: 'instant'`, element targets fall back to
|
|
535
|
+
* `locator.click({ button: 'right' })`; a `Point` dispatches one
|
|
536
|
+
* `mouse.click({ button: 'right' })` at the coordinates.
|
|
474
537
|
*/
|
|
475
|
-
rightClick(target:
|
|
538
|
+
rightClick(target: MouseTarget): Promise<void>;
|
|
476
539
|
/**
|
|
477
540
|
* Move the cursor to `target` along a humanized Bezier path and settle
|
|
478
541
|
* on it — no click is dispatched. Useful for hover-triggered UI
|
|
@@ -670,9 +733,110 @@ interface Human {
|
|
|
670
733
|
*/
|
|
671
734
|
record(fn: () => Promise<void>): Promise<Recording>;
|
|
672
735
|
record(options: HumanRecordOptions, fn: () => Promise<void>): Promise<Recording>;
|
|
736
|
+
/**
|
|
737
|
+
* Take a screenshot of the page. Forwards to `page.screenshot(options)`
|
|
738
|
+
* unchanged — see Playwright docs for the full options shape.
|
|
739
|
+
*
|
|
740
|
+
* Not a humanized action: no plugin events fire. Pure ergonomic
|
|
741
|
+
* re-export so `human.*` stays a single surface.
|
|
742
|
+
*/
|
|
743
|
+
screenshot(options?: Parameters<Page['screenshot']>[0]): Promise<Buffer>;
|
|
744
|
+
/**
|
|
745
|
+
* Visible text content of the page (`document.body.innerText`). Forwards
|
|
746
|
+
* to `page.innerText('body')`. Useful for AI agents that need to
|
|
747
|
+
* understand what's on screen without parsing HTML.
|
|
748
|
+
*
|
|
749
|
+
* For a region instead of the whole page, use `page.innerText(selector)`.
|
|
750
|
+
*
|
|
751
|
+
* Not a humanized action: no plugin events fire.
|
|
752
|
+
*/
|
|
753
|
+
pageText(): Promise<string>;
|
|
754
|
+
/**
|
|
755
|
+
* Full HTML of the page. Forwards to `page.content()`. Often large
|
|
756
|
+
* (50–500 KB on typical sites) — prefer {@link Human.pageText} when
|
|
757
|
+
* passing to an LLM unless structure matters.
|
|
758
|
+
*
|
|
759
|
+
* Not a humanized action: no plugin events fire.
|
|
760
|
+
*/
|
|
761
|
+
content(): Promise<string>;
|
|
762
|
+
/**
|
|
763
|
+
* Current URL of the page. Forwards to `page.url()`. Synchronous return
|
|
764
|
+
* because Playwright's underlying API is sync.
|
|
765
|
+
*
|
|
766
|
+
* Not a humanized action: no plugin events fire.
|
|
767
|
+
*/
|
|
768
|
+
url(): string;
|
|
769
|
+
/**
|
|
770
|
+
* Current document title. Forwards to `page.title()`.
|
|
771
|
+
*
|
|
772
|
+
* Not a humanized action: no plugin events fire.
|
|
773
|
+
*/
|
|
774
|
+
title(): Promise<string>;
|
|
775
|
+
/**
|
|
776
|
+
* Reload the current page. Forwards to `page.reload(options)`. Real-user
|
|
777
|
+
* analog of hitting the refresh button — the click motion is *not*
|
|
778
|
+
* humanized (we treat reload as navigation, not a cursor action).
|
|
779
|
+
*
|
|
780
|
+
* Plugins observe a `'reload'` action.
|
|
781
|
+
*/
|
|
782
|
+
reload(options?: Parameters<Page['reload']>[0]): Promise<void>;
|
|
783
|
+
/**
|
|
784
|
+
* Navigate back in the browser history. Forwards to `page.goBack(options)`.
|
|
785
|
+
*
|
|
786
|
+
* Plugins observe a `'goBack'` action.
|
|
787
|
+
*/
|
|
788
|
+
goBack(options?: Parameters<Page['goBack']>[0]): Promise<void>;
|
|
789
|
+
/**
|
|
790
|
+
* Navigate forward in the browser history. Forwards to
|
|
791
|
+
* `page.goForward(options)`.
|
|
792
|
+
*
|
|
793
|
+
* Plugins observe a `'goForward'` action.
|
|
794
|
+
*/
|
|
795
|
+
goForward(options?: Parameters<Page['goForward']>[0]): Promise<void>;
|
|
796
|
+
/**
|
|
797
|
+
* Wait until the page reaches the specified load state. Forwards to
|
|
798
|
+
* `page.waitForLoadState(state, options)`. Common after a humanized
|
|
799
|
+
* click that triggers navigation — gives the page time to settle before
|
|
800
|
+
* the next action.
|
|
801
|
+
*
|
|
802
|
+
* Not a humanized action: no plugin events fire.
|
|
803
|
+
*/
|
|
804
|
+
waitForLoadState(state?: Parameters<Page['waitForLoadState']>[0], options?: Parameters<Page['waitForLoadState']>[1]): Promise<void>;
|
|
805
|
+
/**
|
|
806
|
+
* Wait until the page's URL matches `url` (string, RegExp, or predicate).
|
|
807
|
+
* Forwards to `page.waitForURL(url, options)`. Common post-action wait
|
|
808
|
+
* (e.g. after `human.click('#login')`, wait for `/dashboard`).
|
|
809
|
+
*
|
|
810
|
+
* Not a humanized action: no plugin events fire.
|
|
811
|
+
*/
|
|
812
|
+
waitForURL(url: Parameters<Page['waitForURL']>[0], options?: Parameters<Page['waitForURL']>[1]): Promise<void>;
|
|
813
|
+
/**
|
|
814
|
+
* Resize the viewport. Forwards to `page.setViewportSize(size)`. Useful
|
|
815
|
+
* for testing responsive layouts or switching between breakpoints
|
|
816
|
+
* mid-session.
|
|
817
|
+
*
|
|
818
|
+
* Not a humanized action: no plugin events fire.
|
|
819
|
+
*/
|
|
820
|
+
setViewportSize(size: {
|
|
821
|
+
width: number;
|
|
822
|
+
height: number;
|
|
823
|
+
}): Promise<void>;
|
|
824
|
+
/**
|
|
825
|
+
* Render the page as a PDF. Forwards to `page.pdf(options)`. Chromium
|
|
826
|
+
* only; works most reliably in headless mode (in headed mode, Playwright
|
|
827
|
+
* silently switches to a print-style render).
|
|
828
|
+
*
|
|
829
|
+
* Not a humanized action: no plugin events fire.
|
|
830
|
+
*/
|
|
831
|
+
pdf(options?: Parameters<Page['pdf']>[0]): Promise<Buffer>;
|
|
673
832
|
}
|
|
674
833
|
/** Options for {@link Human.record}. */
|
|
675
834
|
interface HumanRecordOptions {
|
|
835
|
+
/**
|
|
836
|
+
* Optional label for the recording. Stored on the timeline and used as the
|
|
837
|
+
* title of a generated `toPlaywright()` test.
|
|
838
|
+
*/
|
|
839
|
+
readonly name?: string;
|
|
676
840
|
/**
|
|
677
841
|
* Whether to capture frames for video output. Defaults to `true`.
|
|
678
842
|
* Set to `false` for timeline-only recordings (no capture loop, no
|
|
@@ -685,6 +849,21 @@ interface HumanRecordOptions {
|
|
|
685
849
|
* Defaults to `'high'`. Ignored when `video: false`.
|
|
686
850
|
*/
|
|
687
851
|
readonly quality?: RecordingQuality;
|
|
852
|
+
/**
|
|
853
|
+
* Capture the actual typed/pasted text into the timeline (and therefore
|
|
854
|
+
* into code generated by `toHumanJS()` / `toPlaywright()`). Defaults to
|
|
855
|
+
* `true`.
|
|
856
|
+
*
|
|
857
|
+
* Values typed/pasted into `input[type="password"]` are always masked
|
|
858
|
+
* (omitted) regardless of this flag — the video already renders them as
|
|
859
|
+
* dots, and freezing a cleartext secret into an artifact would leak more
|
|
860
|
+
* than the recording itself. Set `false` to record no input values at all;
|
|
861
|
+
* exporters then emit empty-string placeholders.
|
|
862
|
+
*
|
|
863
|
+
* Captured values land in the timeline JSON and any exported test, so treat
|
|
864
|
+
* those artifacts with the same care as the values themselves.
|
|
865
|
+
*/
|
|
866
|
+
readonly captureInputs?: boolean;
|
|
688
867
|
}
|
|
689
868
|
/**
|
|
690
869
|
* Creates a humanized session bound to a Playwright `Page`.
|
|
@@ -707,4 +886,4 @@ interface HumanRecordOptions {
|
|
|
707
886
|
*/
|
|
708
887
|
declare function createHuman(page: Page, options?: CreateHumanOptions): Promise<Human>;
|
|
709
888
|
|
|
710
|
-
export { type CreateHumanOptions, type FfmpegPreset, type FfmpegTune, type Human, type HumanRecordOptions, type InstallMouseHelperOptions, type KeyModifier, type KeyName, type KeyOrChord, type MouseTarget, type PressResult, type ReadOptions, type ReadResult, type ReadTarget, Recording, type RecordingQuality, type ScrollOptions, type ScrollResult, type ScrollTarget, type Speed, type Timeline, type TimelineEvent, type ToGifOptions, type ToVideoOptions, createHuman, installMouseHelper };
|
|
889
|
+
export { type CreateHumanOptions, type FfmpegPreset, type FfmpegTune, type Human, type HumanRecordOptions, type InstallMouseHelperOptions, type KeyModifier, type KeyName, type KeyOrChord, type MouseTarget, type PlaywrightTestOptions, type PressResult, type ReadOptions, type ReadResult, type ReadTarget, Recording, type RecordingQuality, type ScrollOptions, type ScrollResult, type ScrollTarget, type Speed, type Timeline, type TimelineEvent, type ToGifOptions, type ToVideoOptions, createHuman, installMouseHelper };
|