effect-playwright 0.2.4 → 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.
- package/README.md +3 -5
- package/dist/chunk-CfYAbeIz.mjs +13 -0
- package/dist/experimental/index.d.mts +1 -2
- package/dist/experimental/index.mjs +7 -11
- package/dist/{playwright-BUFqTb7H.d.mts → index-CA1jsZ4o.d.mts} +771 -42
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -3
- package/dist/{playwright-BHnfmfWC.mjs → src-DxTog178.mjs} +162 -39
- package/package.json +11 -8
- package/dist/chunk-DQk6qfdC.mjs +0 -18
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, Effect, Layer, Option, Scope, Stream } from "effect";
|
|
2
|
-
import { Browser, BrowserContext, BrowserType, ConnectOverCDPOptions, ConsoleMessage, Dialog, Download, ElementHandle, FileChooser, Frame, JSHandle, Locator, Page, Request, Response, WebError, WebSocket, Worker, chromium } from "playwright-core";
|
|
2
|
+
import { Browser, BrowserContext, BrowserType, Clock, ConnectOverCDPOptions, ConsoleMessage, Dialog, Download, ElementHandle, FileChooser, Frame, JSHandle, Keyboard, Locator, Mouse, Page, Request, Response, Touchscreen, WebError, WebSocket, Worker, chromium } from "playwright-core";
|
|
3
3
|
import { Scope as Scope$1 } from "effect/Scope";
|
|
4
4
|
import * as effect_Types0 from "effect/Types";
|
|
5
5
|
import * as effect_Cause0 from "effect/Cause";
|
|
@@ -253,6 +253,8 @@ interface PlaywrightFrameService {
|
|
|
253
253
|
/**
|
|
254
254
|
* Returns a locator for the given selector.
|
|
255
255
|
*
|
|
256
|
+
* NOTE: This method will cause a defect if `options.has` or `options.hasNot` are provided and belong to a different frame.
|
|
257
|
+
*
|
|
256
258
|
* @see {@link Frame.locator}
|
|
257
259
|
* @since 0.1.3
|
|
258
260
|
*/
|
|
@@ -291,7 +293,7 @@ interface PlaywrightFrameService {
|
|
|
291
293
|
* @see {@link Frame.url}
|
|
292
294
|
* @since 0.1.3
|
|
293
295
|
*/
|
|
294
|
-
readonly url:
|
|
296
|
+
readonly url: () => string;
|
|
295
297
|
/**
|
|
296
298
|
* Returns the full HTML contents of the frame, including the doctype.
|
|
297
299
|
*
|
|
@@ -305,7 +307,7 @@ interface PlaywrightFrameService {
|
|
|
305
307
|
* @see {@link Frame.name}
|
|
306
308
|
* @since 0.1.3
|
|
307
309
|
*/
|
|
308
|
-
readonly name:
|
|
310
|
+
readonly name: () => string;
|
|
309
311
|
/**
|
|
310
312
|
* Clicks an element matching the given selector.
|
|
311
313
|
*
|
|
@@ -331,6 +333,93 @@ declare class PlaywrightFrame extends PlaywrightFrame_base {
|
|
|
331
333
|
static make(frame: Frame): PlaywrightFrameService;
|
|
332
334
|
}
|
|
333
335
|
//#endregion
|
|
336
|
+
//#region src/clock.d.ts
|
|
337
|
+
/**
|
|
338
|
+
* Interface for a Playwright clock.
|
|
339
|
+
* @category model
|
|
340
|
+
*/
|
|
341
|
+
interface PlaywrightClockService {
|
|
342
|
+
/**
|
|
343
|
+
* Advance the clock by jumping forward in time. Only fires due timers at most once. This is equivalent to user
|
|
344
|
+
* closing the laptop lid for a while and reopening it later, after given time.
|
|
345
|
+
*
|
|
346
|
+
* @see {@link Clock.fastForward}
|
|
347
|
+
* @since 0.1.0
|
|
348
|
+
*/
|
|
349
|
+
readonly fastForward: (ticks: number | string) => Effect.Effect<void, PlaywrightError>;
|
|
350
|
+
/**
|
|
351
|
+
* Install fake implementations for time-related functions.
|
|
352
|
+
*
|
|
353
|
+
* @see {@link Clock.install}
|
|
354
|
+
* @since 0.1.0
|
|
355
|
+
*/
|
|
356
|
+
readonly install: (options?: {
|
|
357
|
+
time?: number | string | Date;
|
|
358
|
+
}) => Effect.Effect<void, PlaywrightError>;
|
|
359
|
+
/**
|
|
360
|
+
* Advance the clock by jumping forward in time and pause the time.
|
|
361
|
+
*
|
|
362
|
+
* @see {@link Clock.pauseAt}
|
|
363
|
+
* @since 0.1.0
|
|
364
|
+
*/
|
|
365
|
+
readonly pauseAt: (time: number | string | Date) => Effect.Effect<void, PlaywrightError>;
|
|
366
|
+
/**
|
|
367
|
+
* Resumes timers. Once this method is called, time resumes flowing, timers are fired as usual.
|
|
368
|
+
*
|
|
369
|
+
* @see {@link Clock.resume}
|
|
370
|
+
* @since 0.1.0
|
|
371
|
+
*/
|
|
372
|
+
readonly resume: Effect.Effect<void, PlaywrightError>;
|
|
373
|
+
/**
|
|
374
|
+
* Advance the clock, firing all the time-related callbacks.
|
|
375
|
+
*
|
|
376
|
+
* @see {@link Clock.runFor}
|
|
377
|
+
* @since 0.1.0
|
|
378
|
+
*/
|
|
379
|
+
readonly runFor: (ticks: number | string) => Effect.Effect<void, PlaywrightError>;
|
|
380
|
+
/**
|
|
381
|
+
* Makes `Date.now` and `new Date()` return fixed fake time at all times, keeps all the timers running.
|
|
382
|
+
*
|
|
383
|
+
* @see {@link Clock.setFixedTime}
|
|
384
|
+
* @since 0.1.0
|
|
385
|
+
*/
|
|
386
|
+
readonly setFixedTime: (time: number | string | Date) => Effect.Effect<void, PlaywrightError>;
|
|
387
|
+
/**
|
|
388
|
+
* Sets system time, but does not trigger any timers.
|
|
389
|
+
*
|
|
390
|
+
* @see {@link Clock.setSystemTime}
|
|
391
|
+
* @since 0.1.0
|
|
392
|
+
*/
|
|
393
|
+
readonly setSystemTime: (time: number | string | Date) => Effect.Effect<void, PlaywrightError>;
|
|
394
|
+
/**
|
|
395
|
+
* A generic utility to execute any promise-based method on the underlying Playwright `Clock`.
|
|
396
|
+
* Can be used to access any Clock functionality not directly exposed by this service.
|
|
397
|
+
*
|
|
398
|
+
* @param f - A function that takes the Playwright `Clock` and returns a `Promise`.
|
|
399
|
+
* @returns An effect that wraps the promise and returns its result.
|
|
400
|
+
* @see {@link Clock}
|
|
401
|
+
* @since 0.1.0
|
|
402
|
+
*/
|
|
403
|
+
readonly use: <T>(f: (clock: Clock) => Promise<T>) => Effect.Effect<T, PlaywrightError>;
|
|
404
|
+
}
|
|
405
|
+
declare const PlaywrightClock_base: Context.TagClass<PlaywrightClock, "effect-playwright/PlaywrightClock", PlaywrightClockService>;
|
|
406
|
+
/**
|
|
407
|
+
* A service that provides a `PlaywrightClock` instance.
|
|
408
|
+
*
|
|
409
|
+
* @since 0.1.0
|
|
410
|
+
* @category tag
|
|
411
|
+
*/
|
|
412
|
+
declare class PlaywrightClock extends PlaywrightClock_base {
|
|
413
|
+
/**
|
|
414
|
+
* Creates a `PlaywrightClock` from a Playwright `Clock` instance.
|
|
415
|
+
*
|
|
416
|
+
* @param clock - The Playwright `Clock` instance to wrap.
|
|
417
|
+
* @since 0.1.0
|
|
418
|
+
* @category constructor
|
|
419
|
+
*/
|
|
420
|
+
static make(clock: Clock): typeof PlaywrightClock.Service;
|
|
421
|
+
}
|
|
422
|
+
//#endregion
|
|
334
423
|
//#region src/common.d.ts
|
|
335
424
|
declare const PlaywrightRequest_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => Readonly<A> & {
|
|
336
425
|
readonly _tag: "PlaywrightRequest";
|
|
@@ -340,25 +429,101 @@ declare const PlaywrightRequest_base: new <A extends Record<string, any> = {}>(a
|
|
|
340
429
|
* @since 0.1.2
|
|
341
430
|
*/
|
|
342
431
|
declare class PlaywrightRequest extends PlaywrightRequest_base<{
|
|
432
|
+
/**
|
|
433
|
+
* An object with all the request HTTP headers associated with this request. The header names are lower-cased.
|
|
434
|
+
* @see {@link Request.allHeaders}
|
|
435
|
+
*/
|
|
343
436
|
allHeaders: Effect.Effect<Awaited<ReturnType<Request["allHeaders"]>>, PlaywrightError>;
|
|
437
|
+
/**
|
|
438
|
+
* The method returns null unless this request was a failed one.
|
|
439
|
+
* @see {@link Request.failure}
|
|
440
|
+
*/
|
|
344
441
|
failure: () => Option.Option<NonNullable<ReturnType<Request["failure"]>>>;
|
|
442
|
+
/**
|
|
443
|
+
* Returns the Frame that initiated this request.
|
|
444
|
+
* @see {@link Request.frame}
|
|
445
|
+
*/
|
|
345
446
|
frame: Effect.Effect<PlaywrightFrameService>;
|
|
447
|
+
/**
|
|
448
|
+
* Returns the value of the header matching the name. The name is case insensitive.
|
|
449
|
+
* @see {@link Request.headerValue}
|
|
450
|
+
*/
|
|
346
451
|
headerValue: (name: string) => Effect.Effect<Option.Option<string>, PlaywrightError>;
|
|
347
|
-
|
|
452
|
+
/**
|
|
453
|
+
* An object with the request HTTP headers. The header names are lower-cased.
|
|
454
|
+
* @see {@link Request.headers}
|
|
455
|
+
*/
|
|
456
|
+
headers: () => ReturnType<Request["headers"]>;
|
|
457
|
+
/**
|
|
458
|
+
* An array with all the request HTTP headers associated with this request.
|
|
459
|
+
* @see {@link Request.headersArray}
|
|
460
|
+
*/
|
|
348
461
|
headersArray: Effect.Effect<Awaited<ReturnType<Request["headersArray"]>>, PlaywrightError>;
|
|
349
|
-
|
|
350
|
-
|
|
462
|
+
/**
|
|
463
|
+
* Whether this request is driving frame's navigation.
|
|
464
|
+
* @see {@link Request.isNavigationRequest}
|
|
465
|
+
*/
|
|
466
|
+
isNavigationRequest: () => boolean;
|
|
467
|
+
/**
|
|
468
|
+
* Request's method (GET, POST, etc.)
|
|
469
|
+
* @see {@link Request.method}
|
|
470
|
+
*/
|
|
471
|
+
method: () => string;
|
|
472
|
+
/**
|
|
473
|
+
* Request's post body, if any.
|
|
474
|
+
* @see {@link Request.postData}
|
|
475
|
+
*/
|
|
351
476
|
postData: () => Option.Option<string>;
|
|
477
|
+
/**
|
|
478
|
+
* Request's post body in a binary form, if any.
|
|
479
|
+
* @see {@link Request.postDataBuffer}
|
|
480
|
+
*/
|
|
352
481
|
postDataBuffer: () => Option.Option<NonNullable<ReturnType<Request["postDataBuffer"]>>>;
|
|
482
|
+
/**
|
|
483
|
+
* Returns parsed request's body for form-urlencoded and JSON requests.
|
|
484
|
+
* @see {@link Request.postDataJSON}
|
|
485
|
+
*/
|
|
353
486
|
postDataJSON: Effect.Effect<Option.Option<NonNullable<Awaited<ReturnType<Request["postDataJSON"]>>>>, PlaywrightError>;
|
|
487
|
+
/**
|
|
488
|
+
* Request that was redirected by the server to this one, if any.
|
|
489
|
+
* @see {@link Request.redirectedFrom}
|
|
490
|
+
*/
|
|
354
491
|
redirectedFrom: () => Option.Option<PlaywrightRequest>;
|
|
492
|
+
/**
|
|
493
|
+
* New request issued by the browser if the server responded with redirect.
|
|
494
|
+
* @see {@link Request.redirectedTo}
|
|
495
|
+
*/
|
|
355
496
|
redirectedTo: () => Option.Option<PlaywrightRequest>;
|
|
356
|
-
|
|
497
|
+
/**
|
|
498
|
+
* Contains the request's resource type as it was perceived by the rendering engine.
|
|
499
|
+
* @see {@link Request.resourceType}
|
|
500
|
+
*/
|
|
501
|
+
resourceType: () => string;
|
|
502
|
+
/**
|
|
503
|
+
* Returns the matching Response object, or null if the response was not received due to error.
|
|
504
|
+
* @see {@link Request.response}
|
|
505
|
+
*/
|
|
357
506
|
response: Effect.Effect<Option.Option<PlaywrightResponse>, PlaywrightError>;
|
|
507
|
+
/**
|
|
508
|
+
* Returns the ServiceWorker that initiated this request.
|
|
509
|
+
* @see {@link Request.serviceWorker}
|
|
510
|
+
*/
|
|
358
511
|
serviceWorker: () => Option.Option<PlaywrightWorker>;
|
|
512
|
+
/**
|
|
513
|
+
* Returns resource size information for given request.
|
|
514
|
+
* @see {@link Request.sizes}
|
|
515
|
+
*/
|
|
359
516
|
sizes: Effect.Effect<Awaited<ReturnType<Request["sizes"]>>, PlaywrightError>;
|
|
360
|
-
|
|
361
|
-
|
|
517
|
+
/**
|
|
518
|
+
* Returns resource timing information for given request.
|
|
519
|
+
* @see {@link Request.timing}
|
|
520
|
+
*/
|
|
521
|
+
timing: () => ReturnType<Request["timing"]>;
|
|
522
|
+
/**
|
|
523
|
+
* URL of the request.
|
|
524
|
+
* @see {@link Request.url}
|
|
525
|
+
*/
|
|
526
|
+
url: () => string;
|
|
362
527
|
}> {
|
|
363
528
|
static make(request: Request): PlaywrightRequest;
|
|
364
529
|
}
|
|
@@ -374,20 +539,20 @@ declare class PlaywrightResponse extends PlaywrightResponse_base<{
|
|
|
374
539
|
body: Effect.Effect<Awaited<ReturnType<Response["body"]>>, PlaywrightError>;
|
|
375
540
|
finished: Effect.Effect<Awaited<ReturnType<Response["finished"]>>, PlaywrightError>;
|
|
376
541
|
frame: Effect.Effect<PlaywrightFrameService>;
|
|
377
|
-
fromServiceWorker:
|
|
378
|
-
headers:
|
|
542
|
+
fromServiceWorker: () => boolean;
|
|
543
|
+
headers: () => ReturnType<Response["headers"]>;
|
|
379
544
|
headersArray: Effect.Effect<Awaited<ReturnType<Response["headersArray"]>>, PlaywrightError>;
|
|
380
545
|
headerValue: (name: string) => Effect.Effect<Option.Option<string>, PlaywrightError>;
|
|
381
546
|
headerValues: (name: string) => Effect.Effect<Awaited<ReturnType<Response["headerValues"]>>, PlaywrightError>;
|
|
382
547
|
json: Effect.Effect<Awaited<ReturnType<Response["json"]>>, PlaywrightError>;
|
|
383
|
-
ok:
|
|
548
|
+
ok: () => boolean;
|
|
384
549
|
request: () => PlaywrightRequest;
|
|
385
550
|
securityDetails: Effect.Effect<Option.Option<NonNullable<Awaited<ReturnType<Response["securityDetails"]>>>>, PlaywrightError>;
|
|
386
551
|
serverAddr: Effect.Effect<Option.Option<NonNullable<Awaited<ReturnType<Response["serverAddr"]>>>>, PlaywrightError>;
|
|
387
|
-
status:
|
|
388
|
-
statusText:
|
|
552
|
+
status: () => number;
|
|
553
|
+
statusText: () => string;
|
|
389
554
|
text: Effect.Effect<Awaited<ReturnType<Response["text"]>>, PlaywrightError>;
|
|
390
|
-
url:
|
|
555
|
+
url: () => string;
|
|
391
556
|
}> {
|
|
392
557
|
static make(response: Response): PlaywrightResponse;
|
|
393
558
|
}
|
|
@@ -400,7 +565,7 @@ declare const PlaywrightWorker_base: new <A extends Record<string, any> = {}>(ar
|
|
|
400
565
|
*/
|
|
401
566
|
declare class PlaywrightWorker extends PlaywrightWorker_base<{
|
|
402
567
|
evaluate: <R, Arg = void>(pageFunction: PageFunction<Arg, R>, arg?: Arg) => Effect.Effect<R, PlaywrightError>;
|
|
403
|
-
url:
|
|
568
|
+
url: () => string;
|
|
404
569
|
}> {
|
|
405
570
|
static make(worker: Worker): PlaywrightWorker;
|
|
406
571
|
}
|
|
@@ -413,11 +578,11 @@ declare const PlaywrightDialog_base: new <A extends Record<string, any> = {}>(ar
|
|
|
413
578
|
*/
|
|
414
579
|
declare class PlaywrightDialog extends PlaywrightDialog_base<{
|
|
415
580
|
accept: (promptText?: string) => Effect.Effect<void, PlaywrightError>;
|
|
416
|
-
defaultValue:
|
|
581
|
+
defaultValue: () => string;
|
|
417
582
|
dismiss: Effect.Effect<void, PlaywrightError>;
|
|
418
|
-
message:
|
|
583
|
+
message: () => string;
|
|
419
584
|
page: () => Option.Option<PlaywrightPageService>;
|
|
420
|
-
type:
|
|
585
|
+
type: () => string;
|
|
421
586
|
}> {
|
|
422
587
|
static make(dialog: Dialog): PlaywrightDialog;
|
|
423
588
|
}
|
|
@@ -430,7 +595,7 @@ declare const PlaywrightFileChooser_base: new <A extends Record<string, any> = {
|
|
|
430
595
|
*/
|
|
431
596
|
declare class PlaywrightFileChooser extends PlaywrightFileChooser_base<{
|
|
432
597
|
element: () => ElementHandle;
|
|
433
|
-
isMultiple:
|
|
598
|
+
isMultiple: () => boolean;
|
|
434
599
|
page: () => PlaywrightPageService;
|
|
435
600
|
setFiles: (files: Parameters<FileChooser["setFiles"]>[0], options?: Parameters<FileChooser["setFiles"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
436
601
|
}> {
|
|
@@ -456,13 +621,162 @@ declare class PlaywrightDownload extends PlaywrightDownload_base<{
|
|
|
456
621
|
page: () => PlaywrightPageService;
|
|
457
622
|
path: Effect.Effect<Option.Option<string | null>, PlaywrightError>;
|
|
458
623
|
saveAs: (path: string) => Effect.Effect<void, PlaywrightError>;
|
|
459
|
-
suggestedFilename:
|
|
460
|
-
url:
|
|
624
|
+
suggestedFilename: () => string;
|
|
625
|
+
url: () => string;
|
|
461
626
|
use: <R>(f: (download: Download) => Promise<R>) => Effect.Effect<R, PlaywrightError>;
|
|
462
627
|
}> {
|
|
463
628
|
static make(download: Download): PlaywrightDownload;
|
|
464
629
|
}
|
|
465
630
|
//#endregion
|
|
631
|
+
//#region src/keyboard.d.ts
|
|
632
|
+
/**
|
|
633
|
+
* @category model
|
|
634
|
+
* @since 0.1.0
|
|
635
|
+
*/
|
|
636
|
+
interface PlaywrightKeyboardService {
|
|
637
|
+
/**
|
|
638
|
+
* Dispatches a `keydown` event.
|
|
639
|
+
*
|
|
640
|
+
* @see {@link Keyboard.down}
|
|
641
|
+
* @since 0.1.0
|
|
642
|
+
*/
|
|
643
|
+
readonly down: (key: Parameters<Keyboard["down"]>[0]) => Effect.Effect<void, PlaywrightError>;
|
|
644
|
+
/**
|
|
645
|
+
* Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.
|
|
646
|
+
*
|
|
647
|
+
* @see {@link Keyboard.insertText}
|
|
648
|
+
* @since 0.1.0
|
|
649
|
+
*/
|
|
650
|
+
readonly insertText: (text: Parameters<Keyboard["insertText"]>[0]) => Effect.Effect<void, PlaywrightError>;
|
|
651
|
+
/**
|
|
652
|
+
* Dispatches a `keydown` and `keyup` event.
|
|
653
|
+
*
|
|
654
|
+
* @see {@link Keyboard.press}
|
|
655
|
+
* @since 0.1.0
|
|
656
|
+
*/
|
|
657
|
+
readonly press: (key: Parameters<Keyboard["press"]>[0], options?: Parameters<Keyboard["press"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
658
|
+
/**
|
|
659
|
+
* Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
|
660
|
+
*
|
|
661
|
+
* @see {@link Keyboard.type}
|
|
662
|
+
* @since 0.1.0
|
|
663
|
+
*/
|
|
664
|
+
readonly type: (text: Parameters<Keyboard["type"]>[0], options?: Parameters<Keyboard["type"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
665
|
+
/**
|
|
666
|
+
* Dispatches a `keyup` event.
|
|
667
|
+
*
|
|
668
|
+
* @see {@link Keyboard.up}
|
|
669
|
+
* @since 0.1.0
|
|
670
|
+
*/
|
|
671
|
+
readonly up: (key: Parameters<Keyboard["up"]>[0]) => Effect.Effect<void, PlaywrightError>;
|
|
672
|
+
}
|
|
673
|
+
declare const PlaywrightKeyboard_base: Context.TagClass<PlaywrightKeyboard, "effect-playwright/PlaywrightKeyboard", PlaywrightKeyboardService>;
|
|
674
|
+
/**
|
|
675
|
+
* @category tag
|
|
676
|
+
*/
|
|
677
|
+
declare class PlaywrightKeyboard extends PlaywrightKeyboard_base {
|
|
678
|
+
/**
|
|
679
|
+
* Creates a `PlaywrightKeyboard` from a Playwright `Keyboard` instance.
|
|
680
|
+
*
|
|
681
|
+
* @param keyboard - The Playwright `Keyboard` instance to wrap.
|
|
682
|
+
* @since 0.1.0
|
|
683
|
+
*/
|
|
684
|
+
static make(keyboard: Keyboard): PlaywrightKeyboardService;
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
687
|
+
//#region src/mouse.d.ts
|
|
688
|
+
/**
|
|
689
|
+
* @category model
|
|
690
|
+
* @since 0.3.0
|
|
691
|
+
*/
|
|
692
|
+
interface PlaywrightMouseService {
|
|
693
|
+
/**
|
|
694
|
+
* Shortcut for mouse.move, mouse.down, mouse.up.
|
|
695
|
+
*
|
|
696
|
+
* @see {@link Mouse.click}
|
|
697
|
+
* @since 0.3.0
|
|
698
|
+
*/
|
|
699
|
+
readonly click: (x: Parameters<Mouse["click"]>[0], y: Parameters<Mouse["click"]>[1], options?: Parameters<Mouse["click"]>[2]) => Effect.Effect<void, PlaywrightError>;
|
|
700
|
+
/**
|
|
701
|
+
* Shortcut for mouse.move, mouse.down, mouse.up, mouse.down and mouse.up.
|
|
702
|
+
*
|
|
703
|
+
* @see {@link Mouse.dblclick}
|
|
704
|
+
* @since 0.3.0
|
|
705
|
+
*/
|
|
706
|
+
readonly dblclick: (x: Parameters<Mouse["dblclick"]>[0], y: Parameters<Mouse["dblclick"]>[1], options?: Parameters<Mouse["dblclick"]>[2]) => Effect.Effect<void, PlaywrightError>;
|
|
707
|
+
/**
|
|
708
|
+
* Dispatches a `mousedown` event.
|
|
709
|
+
*
|
|
710
|
+
* @see {@link Mouse.down}
|
|
711
|
+
* @since 0.3.0
|
|
712
|
+
*/
|
|
713
|
+
readonly down: (options?: Parameters<Mouse["down"]>[0]) => Effect.Effect<void, PlaywrightError>;
|
|
714
|
+
/**
|
|
715
|
+
* Dispatches a `mousemove` event.
|
|
716
|
+
*
|
|
717
|
+
* @see {@link Mouse.move}
|
|
718
|
+
* @since 0.3.0
|
|
719
|
+
*/
|
|
720
|
+
readonly move: (x: Parameters<Mouse["move"]>[0], y: Parameters<Mouse["move"]>[1], options?: Parameters<Mouse["move"]>[2]) => Effect.Effect<void, PlaywrightError>;
|
|
721
|
+
/**
|
|
722
|
+
* Dispatches a `mouseup` event.
|
|
723
|
+
*
|
|
724
|
+
* @see {@link Mouse.up}
|
|
725
|
+
* @since 0.3.0
|
|
726
|
+
*/
|
|
727
|
+
readonly up: (options?: Parameters<Mouse["up"]>[0]) => Effect.Effect<void, PlaywrightError>;
|
|
728
|
+
/**
|
|
729
|
+
* Dispatches a `wheel` event.
|
|
730
|
+
*
|
|
731
|
+
* @see {@link Mouse.wheel}
|
|
732
|
+
* @since 0.3.0
|
|
733
|
+
*/
|
|
734
|
+
readonly wheel: (deltaX: Parameters<Mouse["wheel"]>[0], deltaY: Parameters<Mouse["wheel"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
735
|
+
}
|
|
736
|
+
declare const PlaywrightMouse_base: Context.TagClass<PlaywrightMouse, "effect-playwright/PlaywrightMouse", PlaywrightMouseService>;
|
|
737
|
+
/**
|
|
738
|
+
* @category tag
|
|
739
|
+
*/
|
|
740
|
+
declare class PlaywrightMouse extends PlaywrightMouse_base {
|
|
741
|
+
/**
|
|
742
|
+
* Creates a `PlaywrightMouse` from a Playwright `Mouse` instance.
|
|
743
|
+
*
|
|
744
|
+
* @param mouse - The Playwright `Mouse` instance to wrap.
|
|
745
|
+
* @since 0.3.0
|
|
746
|
+
*/
|
|
747
|
+
static make(mouse: Mouse): PlaywrightMouseService;
|
|
748
|
+
}
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region src/touchscreen.d.ts
|
|
751
|
+
/**
|
|
752
|
+
* @category model
|
|
753
|
+
* @since 0.3.0
|
|
754
|
+
*/
|
|
755
|
+
interface PlaywrightTouchscreenService {
|
|
756
|
+
/**
|
|
757
|
+
* Dispatches a `touchstart` and `touchend` event with a single touch at the position
|
|
758
|
+
* ([`x`](https://playwright.dev/docs/api/class-touchscreen#touchscreen-tap-option-x),[`y`](https://playwright.dev/docs/api/class-touchscreen#touchscreen-tap-option-y)).
|
|
759
|
+
*
|
|
760
|
+
* @see {@link Touchscreen.tap}
|
|
761
|
+
* @since 0.3.0
|
|
762
|
+
*/
|
|
763
|
+
readonly tap: (x: Parameters<Touchscreen["tap"]>[0], y: Parameters<Touchscreen["tap"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
764
|
+
}
|
|
765
|
+
declare const PlaywrightTouchscreen_base: Context.TagClass<PlaywrightTouchscreen, "effect-playwright/PlaywrightTouchscreen", PlaywrightTouchscreenService>;
|
|
766
|
+
/**
|
|
767
|
+
* @category tag
|
|
768
|
+
* @since 0.3.0
|
|
769
|
+
*/
|
|
770
|
+
declare class PlaywrightTouchscreen extends PlaywrightTouchscreen_base {
|
|
771
|
+
/**
|
|
772
|
+
* Creates a `PlaywrightTouchscreen` from a Playwright `Touchscreen` instance.
|
|
773
|
+
*
|
|
774
|
+
* @param touchscreen - The Playwright `Touchscreen` instance to wrap.
|
|
775
|
+
* @since 0.3.0
|
|
776
|
+
*/
|
|
777
|
+
static make(touchscreen: Touchscreen): PlaywrightTouchscreenService;
|
|
778
|
+
}
|
|
779
|
+
//#endregion
|
|
466
780
|
//#region src/page.d.ts
|
|
467
781
|
interface PageEvents {
|
|
468
782
|
close: Page;
|
|
@@ -512,6 +826,30 @@ type PageWithPatchedEvents = PatchedEvents<Page, PageEvents>;
|
|
|
512
826
|
* @since 0.1.0
|
|
513
827
|
*/
|
|
514
828
|
interface PlaywrightPageService {
|
|
829
|
+
/**
|
|
830
|
+
* Access the clock.
|
|
831
|
+
*
|
|
832
|
+
* @since 0.3.0
|
|
833
|
+
*/
|
|
834
|
+
readonly clock: PlaywrightClockService;
|
|
835
|
+
/**
|
|
836
|
+
* Access the keyboard.
|
|
837
|
+
*
|
|
838
|
+
* @since 0.3.0
|
|
839
|
+
*/
|
|
840
|
+
readonly keyboard: PlaywrightKeyboardService;
|
|
841
|
+
/**
|
|
842
|
+
* Access the mouse.
|
|
843
|
+
*
|
|
844
|
+
* @since 0.3.0
|
|
845
|
+
*/
|
|
846
|
+
readonly mouse: PlaywrightMouseService;
|
|
847
|
+
/**
|
|
848
|
+
* Access the touchscreen.
|
|
849
|
+
*
|
|
850
|
+
* @since 0.3.0
|
|
851
|
+
*/
|
|
852
|
+
readonly touchscreen: PlaywrightTouchscreenService;
|
|
515
853
|
/**
|
|
516
854
|
* Navigates the page to the given URL.
|
|
517
855
|
*
|
|
@@ -524,6 +862,58 @@ interface PlaywrightPageService {
|
|
|
524
862
|
* @since 0.1.0
|
|
525
863
|
*/
|
|
526
864
|
readonly goto: (url: string, options?: Parameters<Page["goto"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
865
|
+
/**
|
|
866
|
+
* This method internally calls [document.write()](https://developer.mozilla.org/en-US/docs/Web/API/Document/write),
|
|
867
|
+
* inheriting all its specific characteristics and behaviors.
|
|
868
|
+
*
|
|
869
|
+
* @see {@link Page.setContent}
|
|
870
|
+
* @since 0.3.0
|
|
871
|
+
*/
|
|
872
|
+
readonly setContent: (html: string, options?: Parameters<Page["setContent"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
873
|
+
/**
|
|
874
|
+
* This setting will change the default maximum navigation time for the following methods:
|
|
875
|
+
* - {@link PlaywrightPageService.goBack}
|
|
876
|
+
* - {@link PlaywrightPageService.goForward}
|
|
877
|
+
* - {@link PlaywrightPageService.goto}
|
|
878
|
+
* - {@link PlaywrightPageService.reload}
|
|
879
|
+
* - {@link PlaywrightPageService.setContent}
|
|
880
|
+
* - {@link PlaywrightPageService.waitForURL}
|
|
881
|
+
*
|
|
882
|
+
* @see {@link Page.setDefaultNavigationTimeout}
|
|
883
|
+
* @since 0.3.0
|
|
884
|
+
*/
|
|
885
|
+
readonly setDefaultNavigationTimeout: (timeout: Parameters<Page["setDefaultNavigationTimeout"]>[0]) => Effect.Effect<void>;
|
|
886
|
+
/**
|
|
887
|
+
* This setting will change the default maximum time for all the methods accepting `timeout` option.
|
|
888
|
+
*
|
|
889
|
+
* @see {@link Page.setDefaultTimeout}
|
|
890
|
+
* @since 0.3.0
|
|
891
|
+
*/
|
|
892
|
+
readonly setDefaultTimeout: (timeout: Parameters<Page["setDefaultTimeout"]>[0]) => Effect.Effect<void>;
|
|
893
|
+
/**
|
|
894
|
+
* The extra HTTP headers will be sent with every request the page initiates.
|
|
895
|
+
*
|
|
896
|
+
* @see {@link Page.setExtraHTTPHeaders}
|
|
897
|
+
* @since 0.3.0
|
|
898
|
+
*/
|
|
899
|
+
readonly setExtraHTTPHeaders: (headers: Parameters<Page["setExtraHTTPHeaders"]>[0]) => Effect.Effect<void, PlaywrightError>;
|
|
900
|
+
/**
|
|
901
|
+
* Sets the viewport size for the page.
|
|
902
|
+
*
|
|
903
|
+
* @see {@link Page.setViewportSize}
|
|
904
|
+
* @since 0.3.0
|
|
905
|
+
*/
|
|
906
|
+
readonly setViewportSize: (viewportSize: Parameters<Page["setViewportSize"]>[0]) => Effect.Effect<void, PlaywrightError>;
|
|
907
|
+
/**
|
|
908
|
+
* Returns the viewport size.
|
|
909
|
+
*
|
|
910
|
+
* @see {@link Page.viewportSize}
|
|
911
|
+
* @since 0.3.0
|
|
912
|
+
*/
|
|
913
|
+
readonly viewportSize: () => Option.Option<{
|
|
914
|
+
width: number;
|
|
915
|
+
height: number;
|
|
916
|
+
}>;
|
|
527
917
|
/**
|
|
528
918
|
* Waits for the page to navigate to the given URL.
|
|
529
919
|
*
|
|
@@ -565,6 +955,130 @@ interface PlaywrightPageService {
|
|
|
565
955
|
* @since 0.1.0
|
|
566
956
|
*/
|
|
567
957
|
readonly evaluate: <R, Arg = void>(pageFunction: PageFunction<Arg, R>, arg?: Arg) => Effect.Effect<R, PlaywrightError>;
|
|
958
|
+
/**
|
|
959
|
+
* Adds a script which would be evaluated in one of the following scenarios:
|
|
960
|
+
* - Whenever the page is navigated.
|
|
961
|
+
* - Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame.
|
|
962
|
+
*
|
|
963
|
+
* @see {@link Page.addInitScript}
|
|
964
|
+
* @since 0.3.0
|
|
965
|
+
*/
|
|
966
|
+
readonly addInitScript: (script: Parameters<Page["addInitScript"]>[0], arg?: Parameters<Page["addInitScript"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
967
|
+
/**
|
|
968
|
+
* Adds a `<script>` tag into the page with the desired url or content.
|
|
969
|
+
*
|
|
970
|
+
* @see {@link Page.addScriptTag}
|
|
971
|
+
* @since 0.3.0
|
|
972
|
+
*/
|
|
973
|
+
readonly addScriptTag: (options: Parameters<Page["addScriptTag"]>[0]) => Effect.Effect<ElementHandle, PlaywrightError>;
|
|
974
|
+
/**
|
|
975
|
+
* Adds a function called `name` on the `window` object of every frame in this page.
|
|
976
|
+
*
|
|
977
|
+
* The provided function must return an `Effect` which will be executed using the
|
|
978
|
+
* current runtime when the function is called from the browser context.
|
|
979
|
+
*
|
|
980
|
+
* If you don't require your function to have args you can use {@link exposeEffect} instead.
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* ```ts
|
|
984
|
+
* import { Console, Effect } from "effect";
|
|
985
|
+
* import { PlaywrightBrowser } from "effect-playwright/browser";
|
|
986
|
+
*
|
|
987
|
+
* const program = Effect.gen(function* () {
|
|
988
|
+
* const browser = yield* PlaywrightBrowser;
|
|
989
|
+
* const page = yield* browser.newPage();
|
|
990
|
+
*
|
|
991
|
+
* // Expose an Effect-based function to the browser
|
|
992
|
+
* yield* page.exposeFunction("logMessage", (message: string) =>
|
|
993
|
+
* Console.log(`Message from browser: ${message}`),
|
|
994
|
+
* );
|
|
995
|
+
*
|
|
996
|
+
* yield* page.evaluate(() => {
|
|
997
|
+
* // Call the exposed function from the browser context
|
|
998
|
+
* // @ts-expect-error
|
|
999
|
+
* return window.logMessage("Hello from the other side!");
|
|
1000
|
+
* });
|
|
1001
|
+
* });
|
|
1002
|
+
* ```
|
|
1003
|
+
*
|
|
1004
|
+
* @example
|
|
1005
|
+
* ```ts
|
|
1006
|
+
* import { Context, Effect } from "effect";
|
|
1007
|
+
* import { PlaywrightBrowser } from "effect-playwright/browser";
|
|
1008
|
+
*
|
|
1009
|
+
* // A custom Database service used in your Effect application
|
|
1010
|
+
* class Database extends Context.Tag("Database")<
|
|
1011
|
+
* Database,
|
|
1012
|
+
* { readonly insertProduct: (name: string, price: number) => Effect.Effect<void> }
|
|
1013
|
+
* >() {}
|
|
1014
|
+
*
|
|
1015
|
+
* const program = Effect.gen(function* () {
|
|
1016
|
+
* const browser = yield* PlaywrightBrowser;
|
|
1017
|
+
* const page = yield* browser.newPage();
|
|
1018
|
+
*
|
|
1019
|
+
* // Expose a function that seamlessly accesses Effect Context using Effect.fn
|
|
1020
|
+
* yield* page.exposeFunction(
|
|
1021
|
+
* "saveProduct",
|
|
1022
|
+
* Effect.fn(function* (name: string, price: number) {
|
|
1023
|
+
* const db = yield* Database;
|
|
1024
|
+
* yield* db.insertProduct(name, price);
|
|
1025
|
+
* }),
|
|
1026
|
+
* );
|
|
1027
|
+
*
|
|
1028
|
+
* yield* page.evaluate(async () => {
|
|
1029
|
+
* // Extract data from the page and save it
|
|
1030
|
+
* const items = document.querySelectorAll(".product");
|
|
1031
|
+
* for (const item of items) {
|
|
1032
|
+
* const name = item.querySelector(".name")?.textContent || "Unknown";
|
|
1033
|
+
* const price = Number(item.querySelector(".price")?.textContent || 0);
|
|
1034
|
+
*
|
|
1035
|
+
* // Call the Effect function directly from the browser
|
|
1036
|
+
* // @ts-expect-error
|
|
1037
|
+
* await window.saveProduct(name, price);
|
|
1038
|
+
* }
|
|
1039
|
+
* });
|
|
1040
|
+
* });
|
|
1041
|
+
* ```
|
|
1042
|
+
*
|
|
1043
|
+
*
|
|
1044
|
+
* @see {@link Page.exposeFunction}
|
|
1045
|
+
* @since 0.3.0
|
|
1046
|
+
*/
|
|
1047
|
+
readonly exposeFunction: <A, E, R, Args extends unknown[]>(name: Parameters<Page["exposeFunction"]>[0], playwrightFunction: (...args: Args) => Effect.Effect<A, E, R>) => Effect.Effect<void, PlaywrightError, R>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Identical to {@link exposeFunction} but meant to be used with a static `Effect`.
|
|
1050
|
+
* This is useful when the exposed function does not need any arguments and just
|
|
1051
|
+
* runs a pre-defined effect in the application context.
|
|
1052
|
+
*
|
|
1053
|
+
* @example
|
|
1054
|
+
* ```ts
|
|
1055
|
+
* import { Console, Effect } from "effect";
|
|
1056
|
+
* import { PlaywrightBrowser } from "effect-playwright/browser";
|
|
1057
|
+
*
|
|
1058
|
+
* const program = Effect.gen(function* () {
|
|
1059
|
+
* const browser = yield* PlaywrightBrowser;
|
|
1060
|
+
* const page = yield* browser.newPage();
|
|
1061
|
+
*
|
|
1062
|
+
* yield* page.exposeEffect("ping", Console.log("pong"));
|
|
1063
|
+
*
|
|
1064
|
+
* yield* page.evaluate(async () => {
|
|
1065
|
+
* // @ts-expect-error
|
|
1066
|
+
* await window.ping();
|
|
1067
|
+
* });
|
|
1068
|
+
* });
|
|
1069
|
+
* ```
|
|
1070
|
+
*
|
|
1071
|
+
* @see {@link Page.exposeFunction}
|
|
1072
|
+
* @since 0.3.0
|
|
1073
|
+
*/
|
|
1074
|
+
readonly exposeEffect: <A, E, R>(name: Parameters<Page["exposeFunction"]>[0], playwrightFunction: Effect.Effect<A, E, R>) => Effect.Effect<void, PlaywrightError, R>;
|
|
1075
|
+
/**
|
|
1076
|
+
* Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the content.
|
|
1077
|
+
*
|
|
1078
|
+
* @see {@link Page.addStyleTag}
|
|
1079
|
+
* @since 0.3.0
|
|
1080
|
+
*/
|
|
1081
|
+
readonly addStyleTag: (options: Parameters<Page["addStyleTag"]>[0]) => Effect.Effect<ElementHandle, PlaywrightError>;
|
|
568
1082
|
/**
|
|
569
1083
|
* Returns the page title.
|
|
570
1084
|
*
|
|
@@ -577,6 +1091,18 @@ interface PlaywrightPageService {
|
|
|
577
1091
|
* @since 0.1.0
|
|
578
1092
|
*/
|
|
579
1093
|
readonly title: Effect.Effect<string, PlaywrightError>;
|
|
1094
|
+
/**
|
|
1095
|
+
* Returns the full HTML contents of the page, including the doctype.
|
|
1096
|
+
*
|
|
1097
|
+
* @example
|
|
1098
|
+
* ```ts
|
|
1099
|
+
* const html = yield* page.content;
|
|
1100
|
+
* ```
|
|
1101
|
+
*
|
|
1102
|
+
* @see {@link Page.content}
|
|
1103
|
+
* @since 0.3.0
|
|
1104
|
+
*/
|
|
1105
|
+
readonly content: Effect.Effect<string, PlaywrightError>;
|
|
580
1106
|
/**
|
|
581
1107
|
* A generic utility to execute any promise-based method on the underlying Playwright `Page`.
|
|
582
1108
|
* Can be used to access any Page functionality not directly exposed by this service.
|
|
@@ -593,6 +1119,8 @@ interface PlaywrightPageService {
|
|
|
593
1119
|
/**
|
|
594
1120
|
* Returns a locator for the given selector.
|
|
595
1121
|
*
|
|
1122
|
+
* NOTE: This method will cause a defect if `options.has` or `options.hasNot` are provided and belong to a different frame.
|
|
1123
|
+
*
|
|
596
1124
|
* @see {@link Page.locator}
|
|
597
1125
|
* @since 0.1.0
|
|
598
1126
|
*/
|
|
@@ -625,6 +1153,88 @@ interface PlaywrightPageService {
|
|
|
625
1153
|
* @since 0.1.0
|
|
626
1154
|
*/
|
|
627
1155
|
readonly getByTestId: (testId: Parameters<Page["getByTestId"]>[0]) => typeof PlaywrightLocator.Service;
|
|
1156
|
+
/**
|
|
1157
|
+
* Returns a locator that matches the given alt text.
|
|
1158
|
+
*
|
|
1159
|
+
* @see {@link Page.getByAltText}
|
|
1160
|
+
* @since 0.3.0
|
|
1161
|
+
*/
|
|
1162
|
+
readonly getByAltText: (text: Parameters<Page["getByAltText"]>[0], options?: Parameters<Page["getByAltText"]>[1]) => typeof PlaywrightLocator.Service;
|
|
1163
|
+
/**
|
|
1164
|
+
* Returns a locator that matches the given placeholder.
|
|
1165
|
+
*
|
|
1166
|
+
* @see {@link Page.getByPlaceholder}
|
|
1167
|
+
* @since 0.3.0
|
|
1168
|
+
*/
|
|
1169
|
+
readonly getByPlaceholder: (text: Parameters<Page["getByPlaceholder"]>[0], options?: Parameters<Page["getByPlaceholder"]>[1]) => typeof PlaywrightLocator.Service;
|
|
1170
|
+
/**
|
|
1171
|
+
* Returns a locator that matches the given title.
|
|
1172
|
+
*
|
|
1173
|
+
* @see {@link Page.getByTitle}
|
|
1174
|
+
* @since 0.3.0
|
|
1175
|
+
*/
|
|
1176
|
+
readonly getByTitle: (text: Parameters<Page["getByTitle"]>[0], options?: Parameters<Page["getByTitle"]>[1]) => typeof PlaywrightLocator.Service;
|
|
1177
|
+
/**
|
|
1178
|
+
* Captures a screenshot of the page.
|
|
1179
|
+
*
|
|
1180
|
+
* @example
|
|
1181
|
+
* ```ts
|
|
1182
|
+
* const buffer = yield* page.screenshot({ path: "screenshot.png" });
|
|
1183
|
+
* ```
|
|
1184
|
+
*
|
|
1185
|
+
* @see {@link Page.screenshot}
|
|
1186
|
+
* @since 0.3.0
|
|
1187
|
+
*/
|
|
1188
|
+
readonly screenshot: (options?: Parameters<Page["screenshot"]>[0]) => Effect.Effect<Buffer, PlaywrightError>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Returns the PDF buffer.
|
|
1191
|
+
*
|
|
1192
|
+
* `page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call
|
|
1193
|
+
* {@link PlaywrightPageService.emulateMedia} before calling `page.pdf()`.
|
|
1194
|
+
*
|
|
1195
|
+
* @see {@link Page.pdf}
|
|
1196
|
+
* @since 0.3.0
|
|
1197
|
+
*/
|
|
1198
|
+
readonly pdf: (options?: Parameters<Page["pdf"]>[0]) => Effect.Effect<Buffer, PlaywrightError>;
|
|
1199
|
+
/**
|
|
1200
|
+
* Clicks an element matching the given selector.
|
|
1201
|
+
*
|
|
1202
|
+
* @example
|
|
1203
|
+
* ```ts
|
|
1204
|
+
* yield* page.click("button#submit");
|
|
1205
|
+
* ```
|
|
1206
|
+
* @deprecated Use {@link PlaywrightPageService.locator} to create a locator and then call `click` on it instead.
|
|
1207
|
+
* @see {@link Page.click}
|
|
1208
|
+
* @since 0.1.0
|
|
1209
|
+
* @category deprecated
|
|
1210
|
+
*/
|
|
1211
|
+
readonly click: (selector: string, options?: Parameters<Page["click"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
1212
|
+
/**
|
|
1213
|
+
* Drags a source element to a target element and drops it.
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* ```ts
|
|
1217
|
+
* yield* page.dragAndDrop("#source", "#target");
|
|
1218
|
+
* ```
|
|
1219
|
+
*
|
|
1220
|
+
* @see {@link Page.dragAndDrop}
|
|
1221
|
+
* @since 0.3.0
|
|
1222
|
+
*/
|
|
1223
|
+
readonly dragAndDrop: (source: Parameters<Page["dragAndDrop"]>[0], target: Parameters<Page["dragAndDrop"]>[1], options?: Parameters<Page["dragAndDrop"]>[2]) => Effect.Effect<void, PlaywrightError>;
|
|
1224
|
+
/**
|
|
1225
|
+
* This method changes the CSS media type through the media argument,
|
|
1226
|
+
* and/or the 'prefers-colors-scheme' media feature, using the colorScheme argument.
|
|
1227
|
+
*
|
|
1228
|
+
* @example
|
|
1229
|
+
* ```ts
|
|
1230
|
+
* yield* page.emulateMedia({ colorScheme: "dark" });
|
|
1231
|
+
* yield* page.emulateMedia({ media: "print" });
|
|
1232
|
+
* ```
|
|
1233
|
+
*
|
|
1234
|
+
* @see {@link Page.emulateMedia}
|
|
1235
|
+
* @since 0.3.0
|
|
1236
|
+
*/
|
|
1237
|
+
readonly emulateMedia: (options?: Parameters<Page["emulateMedia"]>[0]) => Effect.Effect<void, PlaywrightError>;
|
|
628
1238
|
/**
|
|
629
1239
|
* Reloads the page.
|
|
630
1240
|
*
|
|
@@ -632,6 +1242,52 @@ interface PlaywrightPageService {
|
|
|
632
1242
|
* @since 0.1.0
|
|
633
1243
|
*/
|
|
634
1244
|
readonly reload: Effect.Effect<void, PlaywrightError>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Navigate to the previous page in history.
|
|
1247
|
+
*
|
|
1248
|
+
* @example
|
|
1249
|
+
* ```ts
|
|
1250
|
+
* const response = yield* page.goBack();
|
|
1251
|
+
* ```
|
|
1252
|
+
*
|
|
1253
|
+
* @see {@link Page.goBack}
|
|
1254
|
+
* @since 0.3.0
|
|
1255
|
+
*/
|
|
1256
|
+
readonly goBack: (options?: Parameters<Page["goBack"]>[0]) => Effect.Effect<Option.Option<PlaywrightResponse>, PlaywrightError>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Navigate to the next page in history.
|
|
1259
|
+
*
|
|
1260
|
+
* @example
|
|
1261
|
+
* ```ts
|
|
1262
|
+
* const response = yield* page.goForward();
|
|
1263
|
+
* ```
|
|
1264
|
+
*
|
|
1265
|
+
* @see {@link Page.goForward}
|
|
1266
|
+
* @since 0.3.0
|
|
1267
|
+
*/
|
|
1268
|
+
readonly goForward: (options?: Parameters<Page["goForward"]>[0]) => Effect.Effect<Option.Option<PlaywrightResponse>, PlaywrightError>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Request the page to perform garbage collection. Note that there is no guarantee that all unreachable objects will
|
|
1271
|
+
* be collected.
|
|
1272
|
+
*
|
|
1273
|
+
* @see {@link Page.requestGC}
|
|
1274
|
+
* @since 0.3.0
|
|
1275
|
+
*/
|
|
1276
|
+
readonly requestGC: Effect.Effect<void, PlaywrightError>;
|
|
1277
|
+
/**
|
|
1278
|
+
* Brings page to front (activates tab).
|
|
1279
|
+
*
|
|
1280
|
+
* @see {@link Page.bringToFront}
|
|
1281
|
+
* @since 0.3.0
|
|
1282
|
+
*/
|
|
1283
|
+
readonly bringToFront: Effect.Effect<void, PlaywrightError>;
|
|
1284
|
+
/**
|
|
1285
|
+
* Pauses the script execution.
|
|
1286
|
+
*
|
|
1287
|
+
* @see {@link Page.pause}
|
|
1288
|
+
* @since 0.3.0
|
|
1289
|
+
*/
|
|
1290
|
+
readonly pause: Effect.Effect<void, PlaywrightError>;
|
|
635
1291
|
/**
|
|
636
1292
|
* Closes the page.
|
|
637
1293
|
*
|
|
@@ -639,18 +1295,84 @@ interface PlaywrightPageService {
|
|
|
639
1295
|
* @since 0.1.0
|
|
640
1296
|
*/
|
|
641
1297
|
readonly close: Effect.Effect<void, PlaywrightError>;
|
|
1298
|
+
/**
|
|
1299
|
+
* Indicates that the page has been closed.
|
|
1300
|
+
*
|
|
1301
|
+
* @see {@link Page.isClosed}
|
|
1302
|
+
* @since 0.3.0
|
|
1303
|
+
*/
|
|
1304
|
+
readonly isClosed: () => boolean;
|
|
642
1305
|
/**
|
|
643
1306
|
* Returns the current URL of the page.
|
|
644
1307
|
*
|
|
645
1308
|
* @example
|
|
646
1309
|
* ```ts
|
|
647
|
-
* const url =
|
|
1310
|
+
* const url = page.url();
|
|
648
1311
|
* ```
|
|
649
1312
|
*
|
|
650
1313
|
* @see {@link Page.url}
|
|
651
1314
|
* @since 0.1.0
|
|
652
1315
|
*/
|
|
653
|
-
readonly url:
|
|
1316
|
+
readonly url: () => string;
|
|
1317
|
+
/**
|
|
1318
|
+
* Returns all messages that have been logged to the console.
|
|
1319
|
+
*
|
|
1320
|
+
* @example
|
|
1321
|
+
* ```ts
|
|
1322
|
+
* const consoleMessages = yield* page.consoleMessages;
|
|
1323
|
+
* ```
|
|
1324
|
+
*
|
|
1325
|
+
* @see {@link Page.consoleMessages}
|
|
1326
|
+
* @since 0.3.0
|
|
1327
|
+
*/
|
|
1328
|
+
readonly consoleMessages: Effect.Effect<ReadonlyArray<ConsoleMessage>, PlaywrightError>;
|
|
1329
|
+
/**
|
|
1330
|
+
* Returns all errors that have been thrown in the page.
|
|
1331
|
+
*
|
|
1332
|
+
* @example
|
|
1333
|
+
* ```ts
|
|
1334
|
+
* const pageErrors = yield* page.pageErrors;
|
|
1335
|
+
* ```
|
|
1336
|
+
*
|
|
1337
|
+
* @see {@link Page.pageErrors}
|
|
1338
|
+
* @since 0.3.0
|
|
1339
|
+
*/
|
|
1340
|
+
readonly pageErrors: Effect.Effect<ReadonlyArray<Error>, PlaywrightError>;
|
|
1341
|
+
/**
|
|
1342
|
+
* Returns all workers.
|
|
1343
|
+
*
|
|
1344
|
+
* @see {@link Page.workers}
|
|
1345
|
+
* @since 0.3.0
|
|
1346
|
+
*/
|
|
1347
|
+
readonly workers: () => ReadonlyArray<PlaywrightWorker>;
|
|
1348
|
+
/**
|
|
1349
|
+
* Get the browser context that the page belongs to.
|
|
1350
|
+
*
|
|
1351
|
+
* @see {@link Page.context}
|
|
1352
|
+
* @since 0.3.0
|
|
1353
|
+
*/
|
|
1354
|
+
readonly context: () => PlaywrightBrowserContextService;
|
|
1355
|
+
/**
|
|
1356
|
+
* Returns the opener for popup pages and `Option.none` for others.
|
|
1357
|
+
*
|
|
1358
|
+
* If the opener has been closed already, returns `Option.none`.
|
|
1359
|
+
*
|
|
1360
|
+
* @see {@link Page.opener}
|
|
1361
|
+
* @since 0.3.0
|
|
1362
|
+
*/
|
|
1363
|
+
readonly opener: Effect.Effect<Option.Option<PlaywrightPageService>, PlaywrightError>;
|
|
1364
|
+
/**
|
|
1365
|
+
* Returns a frame matching the specified criteria.
|
|
1366
|
+
*
|
|
1367
|
+
* @example
|
|
1368
|
+
* ```ts
|
|
1369
|
+
* const frame = Option.getOrNull(page.frame("frame-name"));
|
|
1370
|
+
* ```
|
|
1371
|
+
*
|
|
1372
|
+
* @see {@link Page.frame}
|
|
1373
|
+
* @since 0.3.0
|
|
1374
|
+
*/
|
|
1375
|
+
readonly frame: (frameSelector: Parameters<Page["frame"]>[0]) => Option.Option<typeof PlaywrightFrame.Service>;
|
|
654
1376
|
/**
|
|
655
1377
|
* Returns all frames attached to the page.
|
|
656
1378
|
*
|
|
@@ -658,6 +1380,13 @@ interface PlaywrightPageService {
|
|
|
658
1380
|
* @since 0.2.0
|
|
659
1381
|
*/
|
|
660
1382
|
readonly frames: Effect.Effect<ReadonlyArray<typeof PlaywrightFrame.Service>, PlaywrightError>;
|
|
1383
|
+
/**
|
|
1384
|
+
* The page's main frame. Page is guaranteed to have a main frame which persists during navigations.
|
|
1385
|
+
*
|
|
1386
|
+
* @see {@link Page.mainFrame}
|
|
1387
|
+
* @since 0.3.0
|
|
1388
|
+
*/
|
|
1389
|
+
readonly mainFrame: () => typeof PlaywrightFrame.Service;
|
|
661
1390
|
/**
|
|
662
1391
|
* Creates a stream of the given event from the page.
|
|
663
1392
|
*
|
|
@@ -671,19 +1400,6 @@ interface PlaywrightPageService {
|
|
|
671
1400
|
* @since 0.1.0
|
|
672
1401
|
*/
|
|
673
1402
|
readonly eventStream: <K extends keyof PageEvents>(event: K) => Stream.Stream<ReturnType<(typeof eventMappings$2)[K]>>;
|
|
674
|
-
/**
|
|
675
|
-
* Clicks an element matching the given selector.
|
|
676
|
-
*
|
|
677
|
-
* @example
|
|
678
|
-
* ```ts
|
|
679
|
-
* yield* page.click("button#submit");
|
|
680
|
-
* ```
|
|
681
|
-
* @deprecated Use {@link PlaywrightPageService.locator} to create a locator and then call `click` on it instead.
|
|
682
|
-
* @see {@link Page.click}
|
|
683
|
-
* @since 0.1.0
|
|
684
|
-
* @category deprecated
|
|
685
|
-
*/
|
|
686
|
-
readonly click: (selector: string, options?: Parameters<Page["click"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
687
1403
|
}
|
|
688
1404
|
declare const PlaywrightPage_base: Context.TagClass<PlaywrightPage, "effect-playwright/PlaywrightPage", PlaywrightPageService>;
|
|
689
1405
|
/**
|
|
@@ -732,6 +1448,10 @@ type BrowserContextWithPatchedEvents = PatchedEvents<BrowserContext, BrowserCont
|
|
|
732
1448
|
* @since 0.1.0
|
|
733
1449
|
*/
|
|
734
1450
|
interface PlaywrightBrowserContextService {
|
|
1451
|
+
/**
|
|
1452
|
+
* Access the clock.
|
|
1453
|
+
*/
|
|
1454
|
+
readonly clock: PlaywrightClockService;
|
|
735
1455
|
/**
|
|
736
1456
|
* Returns the list of all open pages in the browser context.
|
|
737
1457
|
*
|
|
@@ -758,6 +1478,15 @@ interface PlaywrightBrowserContextService {
|
|
|
758
1478
|
* @since 0.1.0
|
|
759
1479
|
*/
|
|
760
1480
|
readonly close: Effect.Effect<void, PlaywrightError>;
|
|
1481
|
+
/**
|
|
1482
|
+
* Adds a script which would be evaluated in one of the following scenarios:
|
|
1483
|
+
* - Whenever a page is created in the browser context or is navigated.
|
|
1484
|
+
* - Whenever a child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame.
|
|
1485
|
+
*
|
|
1486
|
+
* @see {@link BrowserContext.addInitScript}
|
|
1487
|
+
* @since 0.2.0
|
|
1488
|
+
*/
|
|
1489
|
+
readonly addInitScript: (script: Parameters<BrowserContext["addInitScript"]>[0], arg?: Parameters<BrowserContext["addInitScript"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
761
1490
|
/**
|
|
762
1491
|
* Creates a stream of the given event from the browser context.
|
|
763
1492
|
*
|
|
@@ -838,23 +1567,23 @@ interface PlaywrightBrowserService {
|
|
|
838
1567
|
* An Effect that returns the list of all open browser contexts.
|
|
839
1568
|
* @see {@link Browser.contexts}
|
|
840
1569
|
*/
|
|
841
|
-
readonly contexts:
|
|
1570
|
+
readonly contexts: () => Array<typeof PlaywrightBrowserContext.Service>;
|
|
842
1571
|
readonly newContext: (options?: NewContextOptions) => Effect.Effect<typeof PlaywrightBrowserContext.Service, PlaywrightError, Scope$1>;
|
|
843
1572
|
/**
|
|
844
1573
|
* An Effect that returns the browser type (chromium, firefox or webkit) that the browser belongs to.
|
|
845
1574
|
* @see {@link Browser.browserType}
|
|
846
1575
|
*/
|
|
847
|
-
readonly browserType:
|
|
1576
|
+
readonly browserType: () => BrowserType;
|
|
848
1577
|
/**
|
|
849
1578
|
* An Effect that returns the version of the browser.
|
|
850
1579
|
* @see {@link Browser.version}
|
|
851
1580
|
*/
|
|
852
|
-
readonly version:
|
|
1581
|
+
readonly version: () => string;
|
|
853
1582
|
/**
|
|
854
1583
|
* An Effect that returns whether the browser is connected.
|
|
855
1584
|
* @see {@link Browser.isConnected}
|
|
856
1585
|
*/
|
|
857
|
-
readonly isConnected:
|
|
1586
|
+
readonly isConnected: () => boolean;
|
|
858
1587
|
/**
|
|
859
1588
|
* Creates a stream of the given event from the browser.
|
|
860
1589
|
*
|
|
@@ -1089,4 +1818,4 @@ declare class Playwright extends Playwright_base {
|
|
|
1089
1818
|
static readonly layer: Layer.Layer<Playwright, never, never>;
|
|
1090
1819
|
}
|
|
1091
1820
|
//#endregion
|
|
1092
|
-
export {
|
|
1821
|
+
export { PlaywrightError as A, PlaywrightWorker as C, PlaywrightFrameService as D, PlaywrightFrame as E, PlaywrightLocator as O, PlaywrightResponse as S, PlaywrightClockService as T, PlaywrightKeyboardService as _, NewPageOptions as a, PlaywrightFileChooser as b, PlaywrightBrowserContext as c, PlaywrightPageService as d, PlaywrightTouchscreen as f, PlaywrightKeyboard as g, PlaywrightMouseService as h, NewContextOptions as i, PlaywrightErrorReason as j, PlaywrightLocatorService as k, PlaywrightBrowserContextService as l, PlaywrightMouse as m, PlaywrightService as n, PlaywrightBrowser as o, PlaywrightTouchscreenService as p, LaunchOptions$1 as r, PlaywrightBrowserService as s, Playwright as t, PlaywrightPage as u, PlaywrightDialog as v, PlaywrightClock as w, PlaywrightRequest as x, PlaywrightDownload as y };
|