effect-playwright 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/experimental/index.d.mts +1 -1
- package/dist/experimental/index.mjs +2 -2
- package/dist/{index-BdIazBpL.d.mts → index-xKVXY-Ra.d.mts} +513 -513
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-BBJfAuBn.mjs → src-bN0oCmot.mjs} +4 -4
- package/package.json +11 -11
- /package/dist/{chunk-BiucMVzj.mjs → chunk-Bo1DHCg-.mjs} +0 -0
|
@@ -61,119 +61,119 @@ type PatchedEvents<Original, Events> = Original & {
|
|
|
61
61
|
*/
|
|
62
62
|
interface PlaywrightLocatorService {
|
|
63
63
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
* Clicks the element.
|
|
65
|
+
*
|
|
66
|
+
* @see {@link Locator.click}
|
|
67
|
+
* @since 0.1.0
|
|
68
|
+
*/
|
|
69
69
|
readonly click: (options?: Parameters<Locator["click"]>[0]) => Effect.Effect<void, PlaywrightError>;
|
|
70
70
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
* Fills the input field.
|
|
72
|
+
*
|
|
73
|
+
* @see {@link Locator.fill}
|
|
74
|
+
* @since 0.1.0
|
|
75
|
+
*/
|
|
76
76
|
readonly fill: (value: string, options?: Parameters<Locator["fill"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
77
77
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
* Gets an attribute value.
|
|
79
|
+
*
|
|
80
|
+
* @see {@link Locator.getAttribute}
|
|
81
|
+
* @since 0.1.0
|
|
82
|
+
*/
|
|
83
83
|
readonly getAttribute: (name: string, options?: Parameters<Locator["getAttribute"]>[1]) => Effect.Effect<string | null, PlaywrightError>;
|
|
84
84
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
* Gets the inner text.
|
|
86
|
+
*
|
|
87
|
+
* @see {@link Locator.innerText}
|
|
88
|
+
* @since 0.1.0
|
|
89
|
+
*/
|
|
90
90
|
readonly innerText: (options?: Parameters<Locator["innerText"]>[0]) => Effect.Effect<string, PlaywrightError>;
|
|
91
91
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
* Gets the inner HTML.
|
|
93
|
+
*
|
|
94
|
+
* @see {@link Locator.innerHTML}
|
|
95
|
+
* @since 0.1.0
|
|
96
|
+
*/
|
|
97
97
|
readonly innerHTML: (options?: Parameters<Locator["innerHTML"]>[0]) => Effect.Effect<string, PlaywrightError>;
|
|
98
98
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
* Gets the input value.
|
|
100
|
+
*
|
|
101
|
+
* @see {@link Locator.inputValue}
|
|
102
|
+
* @since 0.1.0
|
|
103
|
+
*/
|
|
104
104
|
readonly inputValue: (options?: Parameters<Locator["inputValue"]>[0]) => Effect.Effect<string, PlaywrightError>;
|
|
105
105
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
* Gets the text content.
|
|
107
|
+
*
|
|
108
|
+
* @see {@link Locator.textContent}
|
|
109
|
+
* @since 0.1.0
|
|
110
|
+
*/
|
|
111
111
|
readonly textContent: (options?: Parameters<Locator["textContent"]>[0]) => Effect.Effect<string | null, PlaywrightError>;
|
|
112
112
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
* Counts the number of matched elements.
|
|
114
|
+
*
|
|
115
|
+
* @see {@link Locator.count}
|
|
116
|
+
* @since 0.1.0
|
|
117
|
+
*/
|
|
118
118
|
readonly count: Effect.Effect<number, PlaywrightError>;
|
|
119
119
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
* Returns a locator that points to the first matched element.
|
|
121
|
+
* @see {@link Locator.first}
|
|
122
|
+
* @since 0.1.0
|
|
123
|
+
*/
|
|
124
124
|
readonly first: () => PlaywrightLocatorService;
|
|
125
125
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
* Returns a locator that points to the last matched element.
|
|
127
|
+
*
|
|
128
|
+
* @see {@link Locator.last}
|
|
129
|
+
* @since 0.1.0
|
|
130
|
+
*/
|
|
131
131
|
readonly last: () => PlaywrightLocatorService;
|
|
132
132
|
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
* Returns a locator that points to the nth matched element.
|
|
134
|
+
*
|
|
135
|
+
* @see {@link Locator.nth}
|
|
136
|
+
* @since 0.1.0
|
|
137
|
+
*/
|
|
138
138
|
readonly nth: (index: number) => PlaywrightLocatorService;
|
|
139
139
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
140
|
+
* Evaluates a function on the matched element.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* import { PlaywrightBrowser } from "effect-playwright";
|
|
145
|
+
* import { PlaywrightEnvironment } from "effect-playwright/experimental";
|
|
146
|
+
* import { chromium } from "@playwright/test";
|
|
147
|
+
* import { Effect } from "effect";
|
|
148
|
+
*
|
|
149
|
+
* const program = Effect.gen(function* () {
|
|
150
|
+
* const browser = yield* PlaywrightBrowser;
|
|
151
|
+
* const page = yield* browser.newPage();
|
|
152
|
+
* const locator = yield* page.locator("button");
|
|
153
|
+
* const buttonContent = yield* locator.evaluate((button) => button.textContent());
|
|
154
|
+
* }).pipe(PlaywrightEnvironment.provideBrowser, Effect.provide(PlaywrightEnvironment.layer(chromium)));
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* @see {@link Locator.evaluate}
|
|
158
|
+
* @since 0.1.0
|
|
159
|
+
*/
|
|
160
160
|
readonly evaluate: <R, Arg = void, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: (element: E, arg: Unboxed<Arg>) => R | Promise<R>, arg?: Arg, options?: {
|
|
161
161
|
timeout?: number;
|
|
162
162
|
}) => Effect.Effect<R, PlaywrightError>;
|
|
163
163
|
/**
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
164
|
+
* A generic utility to execute any promise-based method on the underlying Playwright `Locator`.
|
|
165
|
+
* Can be used to access any Locator functionality not directly exposed by this service.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const isVisible = yield* locator.use((l) => l.isVisible());
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @param f - A function that takes the Playwright `Locator` and returns a `Promise`.
|
|
173
|
+
* @returns An effect that wraps the promise and returns its result.
|
|
174
|
+
* @see {@link Locator}
|
|
175
|
+
* @since 0.1.0
|
|
176
|
+
*/
|
|
177
177
|
readonly use: <T>(f: (locator: Locator) => Promise<T>) => Effect.Effect<T, PlaywrightError>;
|
|
178
178
|
}
|
|
179
179
|
declare const PlaywrightLocator_base: Context.TagClass<PlaywrightLocator, "effect-playwright/PlaywrightLocator", PlaywrightLocatorService>;
|
|
@@ -185,19 +185,19 @@ declare const PlaywrightLocator_base: Context.TagClass<PlaywrightLocator, "effec
|
|
|
185
185
|
*/
|
|
186
186
|
declare class PlaywrightLocator extends PlaywrightLocator_base {
|
|
187
187
|
/**
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
188
|
+
* Creates a `PlaywrightLocator` from a Playwright `Locator` instance. This is mostly for internal use.
|
|
189
|
+
* But you could use this if you have used `use` or similar to wrap the locator.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* const playwrightNativeLocator = yield* page.use((p) => p.locator("button"));
|
|
194
|
+
* const locator = PlaywrightLocator.make(playwrightNativeLocator);
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @param locator - The Playwright `Locator` instance to wrap.
|
|
198
|
+
* @since 0.1.0
|
|
199
|
+
* @category constructor
|
|
200
|
+
*/
|
|
201
201
|
static make(locator: Locator): typeof PlaywrightLocator.Service;
|
|
202
202
|
}
|
|
203
203
|
//#endregion
|
|
@@ -208,112 +208,112 @@ declare class PlaywrightLocator extends PlaywrightLocator_base {
|
|
|
208
208
|
*/
|
|
209
209
|
interface PlaywrightFrameService {
|
|
210
210
|
/**
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
211
|
+
* Navigates the frame to the given URL.
|
|
212
|
+
*
|
|
213
|
+
* @see {@link Frame.goto}
|
|
214
|
+
* @since 0.1.3
|
|
215
|
+
*/
|
|
216
216
|
readonly goto: (url: string, options?: Parameters<Frame["goto"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
217
217
|
/**
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
* Waits for the frame to navigate to the given URL.
|
|
219
|
+
*
|
|
220
|
+
* @see {@link Frame.waitForURL}
|
|
221
|
+
* @since 0.1.3
|
|
222
|
+
*/
|
|
223
223
|
readonly waitForURL: (url: Parameters<Frame["waitForURL"]>[0], options?: Parameters<Frame["waitForURL"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
224
224
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
225
|
+
* Waits for the frame to reach the given load state.
|
|
226
|
+
*
|
|
227
|
+
* @see {@link Frame.waitForLoadState}
|
|
228
|
+
* @since 0.2.0
|
|
229
|
+
*/
|
|
230
230
|
readonly waitForLoadState: (state?: Parameters<Frame["waitForLoadState"]>[0], options?: Parameters<Frame["waitForLoadState"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
231
231
|
/**
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
232
|
+
* Evaluates a function in the context of the frame.
|
|
233
|
+
*
|
|
234
|
+
* @see {@link Frame.evaluate}
|
|
235
|
+
* @since 0.1.3
|
|
236
|
+
*/
|
|
237
237
|
readonly evaluate: <R, Arg = void>(pageFunction: PageFunction<Arg, R>, arg?: Arg) => Effect.Effect<R, PlaywrightError>;
|
|
238
238
|
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
239
|
+
* Returns the frame title.
|
|
240
|
+
*
|
|
241
|
+
* @see {@link Frame.title}
|
|
242
|
+
* @since 0.1.3
|
|
243
|
+
*/
|
|
244
244
|
readonly title: Effect.Effect<string, PlaywrightError>;
|
|
245
245
|
/**
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
* A generic utility to execute any promise-based method on the underlying Playwright `Frame`.
|
|
247
|
+
* Can be used to access any Frame functionality not directly exposed by this service.
|
|
248
|
+
*
|
|
249
|
+
* @see {@link Frame}
|
|
250
|
+
* @since 0.1.2
|
|
251
|
+
*/
|
|
252
252
|
readonly use: <T>(f: (frame: Frame) => Promise<T>) => Effect.Effect<T, PlaywrightError>;
|
|
253
253
|
/**
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
* Returns a locator for the given selector.
|
|
255
|
+
*
|
|
256
|
+
* @see {@link Frame.locator}
|
|
257
|
+
* @since 0.1.3
|
|
258
|
+
*/
|
|
259
259
|
readonly locator: (selector: string, options?: Parameters<Frame["locator"]>[1]) => typeof PlaywrightLocator.Service;
|
|
260
260
|
/**
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
* Returns a locator that matches the given role.
|
|
262
|
+
*
|
|
263
|
+
* @see {@link Frame.getByRole}
|
|
264
|
+
* @since 0.1.3
|
|
265
|
+
*/
|
|
266
266
|
readonly getByRole: (role: Parameters<Frame["getByRole"]>[0], options?: Parameters<Frame["getByRole"]>[1]) => typeof PlaywrightLocator.Service;
|
|
267
267
|
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
268
|
+
* Returns a locator that matches the given text.
|
|
269
|
+
*
|
|
270
|
+
* @see {@link Frame.getByText}
|
|
271
|
+
* @since 0.1.3
|
|
272
|
+
*/
|
|
273
273
|
readonly getByText: (text: Parameters<Frame["getByText"]>[0], options?: Parameters<Frame["getByText"]>[1]) => typeof PlaywrightLocator.Service;
|
|
274
274
|
/**
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
275
|
+
* Returns a locator that matches the given label.
|
|
276
|
+
*
|
|
277
|
+
* @see {@link Frame.getByLabel}
|
|
278
|
+
* @since 0.1.3
|
|
279
|
+
*/
|
|
280
280
|
readonly getByLabel: (label: Parameters<Frame["getByLabel"]>[0], options?: Parameters<Frame["getByLabel"]>[1]) => typeof PlaywrightLocator.Service;
|
|
281
281
|
/**
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
282
|
+
* Returns a locator that matches the given test id.
|
|
283
|
+
*
|
|
284
|
+
* @see {@link Frame.getByTestId}
|
|
285
|
+
* @since 0.1.3
|
|
286
|
+
*/
|
|
287
287
|
readonly getByTestId: (testId: Parameters<Frame["getByTestId"]>[0]) => typeof PlaywrightLocator.Service;
|
|
288
288
|
/**
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
289
|
+
* Returns the current URL of the frame.
|
|
290
|
+
*
|
|
291
|
+
* @see {@link Frame.url}
|
|
292
|
+
* @since 0.1.3
|
|
293
|
+
*/
|
|
294
294
|
readonly url: Effect.Effect<string, PlaywrightError>;
|
|
295
295
|
/**
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
296
|
+
* Returns the full HTML contents of the frame, including the doctype.
|
|
297
|
+
*
|
|
298
|
+
* @see {@link Frame.content}
|
|
299
|
+
* @since 0.1.3
|
|
300
|
+
*/
|
|
301
301
|
readonly content: Effect.Effect<string, PlaywrightError>;
|
|
302
302
|
/**
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
303
|
+
* Returns the frame name.
|
|
304
|
+
*
|
|
305
|
+
* @see {@link Frame.name}
|
|
306
|
+
* @since 0.1.3
|
|
307
|
+
*/
|
|
308
308
|
readonly name: Effect.Effect<string>;
|
|
309
309
|
/**
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
310
|
+
* Clicks an element matching the given selector.
|
|
311
|
+
*
|
|
312
|
+
* @deprecated Use {@link PlaywrightFrameService.locator} to create a locator and then call `click` on it instead.
|
|
313
|
+
* @see {@link Frame.click}
|
|
314
|
+
* @since 0.1.3
|
|
315
|
+
* @category deprecated
|
|
316
|
+
*/
|
|
317
317
|
readonly click: (selector: string, options?: Parameters<Frame["click"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
318
318
|
}
|
|
319
319
|
declare const PlaywrightFrame_base: Context.TagClass<PlaywrightFrame, "effect-playwright/PlaywrightFrame", PlaywrightFrameService>;
|
|
@@ -323,11 +323,11 @@ declare const PlaywrightFrame_base: Context.TagClass<PlaywrightFrame, "effect-pl
|
|
|
323
323
|
*/
|
|
324
324
|
declare class PlaywrightFrame extends PlaywrightFrame_base {
|
|
325
325
|
/**
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
326
|
+
* Creates a `PlaywrightFrame` from a Playwright `Frame` instance.
|
|
327
|
+
*
|
|
328
|
+
* @param frame - The Playwright `Frame` instance to wrap.
|
|
329
|
+
* @since 0.1.2
|
|
330
|
+
*/
|
|
331
331
|
static make(frame: Frame): PlaywrightFrameService;
|
|
332
332
|
}
|
|
333
333
|
//#endregion
|
|
@@ -446,10 +446,10 @@ declare const PlaywrightDownload_base: new <A extends Record<string, any> = {}>(
|
|
|
446
446
|
declare class PlaywrightDownload extends PlaywrightDownload_base<{
|
|
447
447
|
cancel: Effect.Effect<void, PlaywrightError>;
|
|
448
448
|
/**
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
449
|
+
* Creates a stream of the download data.
|
|
450
|
+
* @category custom
|
|
451
|
+
* @since 0.2.0
|
|
452
|
+
*/
|
|
453
453
|
stream: Stream.Stream<Uint8Array, PlaywrightError>;
|
|
454
454
|
delete: Effect.Effect<void, PlaywrightError>;
|
|
455
455
|
failure: Effect.Effect<Option.Option<string | null>, PlaywrightError>;
|
|
@@ -513,176 +513,176 @@ type PageWithPatchedEvents = PatchedEvents<Page, PageEvents>;
|
|
|
513
513
|
*/
|
|
514
514
|
interface PlaywrightPageService {
|
|
515
515
|
/**
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
516
|
+
* Navigates the page to the given URL.
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```ts
|
|
520
|
+
* yield* page.goto("https://google.com");
|
|
521
|
+
* ```
|
|
522
|
+
*
|
|
523
|
+
* @see {@link Page.goto}
|
|
524
|
+
* @since 0.1.0
|
|
525
|
+
*/
|
|
526
526
|
readonly goto: (url: string, options?: Parameters<Page["goto"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
527
527
|
/**
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
528
|
+
* Waits for the page to navigate to the given URL.
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```ts
|
|
532
|
+
* yield* page.waitForURL("https://google.com");
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* @see {@link Page.waitForURL}
|
|
536
|
+
* @since 0.1.0
|
|
537
|
+
*/
|
|
538
538
|
readonly waitForURL: (url: Parameters<Page["waitForURL"]>[0], options?: Parameters<Page["waitForURL"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
539
539
|
/**
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
540
|
+
* Waits for the page to reach the given load state.
|
|
541
|
+
*
|
|
542
|
+
* NOTE: Most of the time, this method is not needed because Playwright auto-waits before every action.
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```ts
|
|
546
|
+
* yield* page.waitForLoadState("domcontentloaded");
|
|
547
|
+
* ```
|
|
548
|
+
*
|
|
549
|
+
* @see {@link Page.waitForLoadState}
|
|
550
|
+
* @since 0.2.0
|
|
551
|
+
*/
|
|
552
552
|
readonly waitForLoadState: (state?: Parameters<Page["waitForLoadState"]>[0], options?: Parameters<Page["waitForLoadState"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
553
553
|
/**
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
554
|
+
* Evaluates a function in the context of the page.
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```ts
|
|
558
|
+
* const dimensions = yield* page.evaluate(() => ({
|
|
559
|
+
* width: document.documentElement.clientWidth,
|
|
560
|
+
* height: document.documentElement.clientHeight
|
|
561
|
+
* }));
|
|
562
|
+
* ```
|
|
563
|
+
*
|
|
564
|
+
* @see {@link Page.evaluate}
|
|
565
|
+
* @since 0.1.0
|
|
566
|
+
*/
|
|
567
567
|
readonly evaluate: <R, Arg = void>(pageFunction: PageFunction<Arg, R>, arg?: Arg) => Effect.Effect<R, PlaywrightError>;
|
|
568
568
|
/**
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
569
|
+
* Returns the page title.
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* ```ts
|
|
573
|
+
* const title = yield* page.title;
|
|
574
|
+
* ```
|
|
575
|
+
*
|
|
576
|
+
* @see {@link Page.title}
|
|
577
|
+
* @since 0.1.0
|
|
578
|
+
*/
|
|
579
579
|
readonly title: Effect.Effect<string, PlaywrightError>;
|
|
580
580
|
/**
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
581
|
+
* A generic utility to execute any promise-based method on the underlying Playwright `Page`.
|
|
582
|
+
* Can be used to access any Page functionality not directly exposed by this service.
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* ```ts
|
|
586
|
+
* const title = yield* page.use((p) => p.title());
|
|
587
|
+
* ```
|
|
588
|
+
*
|
|
589
|
+
* @see {@link Page}
|
|
590
|
+
* @since 0.1.0
|
|
591
|
+
*/
|
|
592
592
|
readonly use: <T>(f: (page: Page) => Promise<T>) => Effect.Effect<T, PlaywrightError>;
|
|
593
593
|
/**
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
594
|
+
* Returns a locator for the given selector.
|
|
595
|
+
*
|
|
596
|
+
* @see {@link Page.locator}
|
|
597
|
+
* @since 0.1.0
|
|
598
|
+
*/
|
|
599
599
|
readonly locator: (selector: string, options?: Parameters<Page["locator"]>[1]) => typeof PlaywrightLocator.Service;
|
|
600
600
|
/**
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
601
|
+
* Returns a locator that matches the given role.
|
|
602
|
+
*
|
|
603
|
+
* @see {@link Page.getByRole}
|
|
604
|
+
* @since 0.1.0
|
|
605
|
+
*/
|
|
606
606
|
readonly getByRole: (role: Parameters<Page["getByRole"]>[0], options?: Parameters<Page["getByRole"]>[1]) => typeof PlaywrightLocator.Service;
|
|
607
607
|
/**
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
608
|
+
* Returns a locator that matches the given text.
|
|
609
|
+
*
|
|
610
|
+
* @see {@link Page.getByText}
|
|
611
|
+
* @since 0.1.0
|
|
612
|
+
*/
|
|
613
613
|
readonly getByText: (text: Parameters<Page["getByText"]>[0], options?: Parameters<Page["getByText"]>[1]) => typeof PlaywrightLocator.Service;
|
|
614
614
|
/**
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
615
|
+
* Returns a locator that matches the given label.
|
|
616
|
+
*
|
|
617
|
+
* @see {@link Page.getByLabel}
|
|
618
|
+
* @since 0.1.0
|
|
619
|
+
*/
|
|
620
620
|
readonly getByLabel: (label: Parameters<Page["getByLabel"]>[0], options?: Parameters<Page["getByLabel"]>[1]) => typeof PlaywrightLocator.Service;
|
|
621
621
|
/**
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
622
|
+
* Returns a locator that matches the given test id.
|
|
623
|
+
*
|
|
624
|
+
* @see {@link Page.getByTestId}
|
|
625
|
+
* @since 0.1.0
|
|
626
|
+
*/
|
|
627
627
|
readonly getByTestId: (testId: Parameters<Page["getByTestId"]>[0]) => typeof PlaywrightLocator.Service;
|
|
628
628
|
/**
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
629
|
+
* Reloads the page.
|
|
630
|
+
*
|
|
631
|
+
* @see {@link Page.reload}
|
|
632
|
+
* @since 0.1.0
|
|
633
|
+
*/
|
|
634
634
|
readonly reload: Effect.Effect<void, PlaywrightError>;
|
|
635
635
|
/**
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
636
|
+
* Closes the page.
|
|
637
|
+
*
|
|
638
|
+
* @see {@link Page.close}
|
|
639
|
+
* @since 0.1.0
|
|
640
|
+
*/
|
|
641
641
|
readonly close: Effect.Effect<void, PlaywrightError>;
|
|
642
642
|
/**
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
643
|
+
* Returns the current URL of the page.
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* ```ts
|
|
647
|
+
* const url = yield* page.url;
|
|
648
|
+
* ```
|
|
649
|
+
*
|
|
650
|
+
* @see {@link Page.url}
|
|
651
|
+
* @since 0.1.0
|
|
652
|
+
*/
|
|
653
653
|
readonly url: Effect.Effect<string, PlaywrightError>;
|
|
654
654
|
/**
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
655
|
+
* Returns all frames attached to the page.
|
|
656
|
+
*
|
|
657
|
+
* @see {@link Page.frames}
|
|
658
|
+
* @since 0.2.0
|
|
659
|
+
*/
|
|
660
660
|
readonly frames: Effect.Effect<ReadonlyArray<typeof PlaywrightFrame.Service>, PlaywrightError>;
|
|
661
661
|
/**
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
662
|
+
* Creates a stream of the given event from the page.
|
|
663
|
+
*
|
|
664
|
+
* @example
|
|
665
|
+
* ```ts
|
|
666
|
+
* const consoleStream = page.eventStream("console");
|
|
667
|
+
* ```
|
|
668
|
+
*
|
|
669
|
+
* @category custom
|
|
670
|
+
* @see {@link Page.on}
|
|
671
|
+
* @since 0.1.0
|
|
672
|
+
*/
|
|
673
673
|
readonly eventStream: <K extends keyof PageEvents>(event: K) => Stream.Stream<ReturnType<(typeof eventMappings$2)[K]>>;
|
|
674
674
|
/**
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
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
686
|
readonly click: (selector: string, options?: Parameters<Page["click"]>[1]) => Effect.Effect<void, PlaywrightError>;
|
|
687
687
|
}
|
|
688
688
|
declare const PlaywrightPage_base: Context.TagClass<PlaywrightPage, "effect-playwright/PlaywrightPage", PlaywrightPageService>;
|
|
@@ -691,11 +691,11 @@ declare const PlaywrightPage_base: Context.TagClass<PlaywrightPage, "effect-play
|
|
|
691
691
|
*/
|
|
692
692
|
declare class PlaywrightPage extends PlaywrightPage_base {
|
|
693
693
|
/**
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
694
|
+
* Creates a `PlaywrightPage` from a Playwright `Page` instance.
|
|
695
|
+
*
|
|
696
|
+
* @param page - The Playwright `Page` instance to wrap.
|
|
697
|
+
* @since 0.1.0
|
|
698
|
+
*/
|
|
699
699
|
static make(page: PageWithPatchedEvents): PlaywrightPageService;
|
|
700
700
|
}
|
|
701
701
|
//#endregion
|
|
@@ -733,43 +733,43 @@ type BrowserContextWithPatchedEvents = PatchedEvents<BrowserContext, BrowserCont
|
|
|
733
733
|
*/
|
|
734
734
|
interface PlaywrightBrowserContextService {
|
|
735
735
|
/**
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
736
|
+
* Returns the list of all open pages in the browser context.
|
|
737
|
+
*
|
|
738
|
+
* @see {@link BrowserContext.pages}
|
|
739
|
+
* @since 0.1.0
|
|
740
|
+
*/
|
|
741
741
|
readonly pages: Effect.Effect<Array<typeof PlaywrightPage.Service>>;
|
|
742
742
|
/**
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
743
|
+
* Opens a new page in the browser context.
|
|
744
|
+
*
|
|
745
|
+
* @example
|
|
746
|
+
* ```ts
|
|
747
|
+
* const page = yield* context.newPage;
|
|
748
|
+
* ```
|
|
749
|
+
*
|
|
750
|
+
* @see {@link BrowserContext.newPage}
|
|
751
|
+
* @since 0.1.0
|
|
752
|
+
*/
|
|
753
753
|
readonly newPage: Effect.Effect<typeof PlaywrightPage.Service, PlaywrightError>;
|
|
754
754
|
/**
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
755
|
+
* Closes the browser context.
|
|
756
|
+
*
|
|
757
|
+
* @see {@link BrowserContext.close}
|
|
758
|
+
* @since 0.1.0
|
|
759
|
+
*/
|
|
760
760
|
readonly close: Effect.Effect<void, PlaywrightError>;
|
|
761
761
|
/**
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
762
|
+
* Creates a stream of the given event from the browser context.
|
|
763
|
+
*
|
|
764
|
+
* @example
|
|
765
|
+
* ```ts
|
|
766
|
+
* const pageStream = context.eventStream("page");
|
|
767
|
+
* ```
|
|
768
|
+
*
|
|
769
|
+
* @category custom
|
|
770
|
+
* @see {@link BrowserContext.on}
|
|
771
|
+
* @since 0.1.2
|
|
772
|
+
*/
|
|
773
773
|
readonly eventStream: <K extends keyof typeof eventMappings$1>(event: K) => Stream.Stream<ReturnType<(typeof eventMappings$1)[K]>>;
|
|
774
774
|
}
|
|
775
775
|
declare const PlaywrightBrowserContext_base: Context.TagClass<PlaywrightBrowserContext, "effect-playwright/PlaywrightBrowserContext", PlaywrightBrowserContextService>;
|
|
@@ -778,11 +778,11 @@ declare const PlaywrightBrowserContext_base: Context.TagClass<PlaywrightBrowserC
|
|
|
778
778
|
*/
|
|
779
779
|
declare class PlaywrightBrowserContext extends PlaywrightBrowserContext_base {
|
|
780
780
|
/**
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
781
|
+
* Creates a `PlaywrightBrowserContext` from a Playwright `BrowserContext` instance.
|
|
782
|
+
*
|
|
783
|
+
* @param context - The Playwright `BrowserContext` instance to wrap.
|
|
784
|
+
* @since 0.1.0
|
|
785
|
+
*/
|
|
786
786
|
static make(context: BrowserContextWithPatchedEvents): PlaywrightBrowserContextService;
|
|
787
787
|
}
|
|
788
788
|
//#endregion
|
|
@@ -803,70 +803,70 @@ type BrowserWithPatchedEvents = PatchedEvents<Browser, BrowserEvents>;
|
|
|
803
803
|
*/
|
|
804
804
|
interface PlaywrightBrowserService {
|
|
805
805
|
/**
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
806
|
+
* Opens a new page in the browser.
|
|
807
|
+
*
|
|
808
|
+
* @example
|
|
809
|
+
* ```typescript
|
|
810
|
+
* const page = yield* browser.newPage();
|
|
811
|
+
* ```
|
|
812
|
+
*
|
|
813
|
+
* @param options - Optional options for creating the new page.
|
|
814
|
+
* @returns An effect that resolves to a `PlaywrightPage` service.
|
|
815
|
+
* @see {@link Browser.newPage}
|
|
816
|
+
*/
|
|
817
817
|
readonly newPage: (options?: NewPageOptions) => Effect.Effect<typeof PlaywrightPage.Service, PlaywrightError>;
|
|
818
818
|
/**
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
819
|
+
* A generic utility to execute any promise-based method on the underlying Playwright `Browser`.
|
|
820
|
+
* Can be used to access any Browser functionality not directly exposed by this service.
|
|
821
|
+
*
|
|
822
|
+
* @example
|
|
823
|
+
* ```typescript
|
|
824
|
+
* const contexts = yield* browser.use((b) => b.contexts());
|
|
825
|
+
* ```
|
|
826
|
+
*
|
|
827
|
+
* @param f - A function that takes the Playwright `Browser` and returns a `Promise`.
|
|
828
|
+
* @returns An effect that wraps the promise and returns its result.
|
|
829
|
+
* @see {@link Browser}
|
|
830
|
+
*/
|
|
831
831
|
readonly use: <T>(f: (browser: Browser) => Promise<T>) => Effect.Effect<T, PlaywrightError>;
|
|
832
832
|
/**
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
833
|
+
* An Effect that closes the browser and all of its pages.
|
|
834
|
+
* @see {@link Browser.close}
|
|
835
|
+
*/
|
|
836
836
|
readonly close: Effect.Effect<void, PlaywrightError>;
|
|
837
837
|
/**
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
838
|
+
* An Effect that returns the list of all open browser contexts.
|
|
839
|
+
* @see {@link Browser.contexts}
|
|
840
|
+
*/
|
|
841
841
|
readonly contexts: Effect.Effect<Array<typeof PlaywrightBrowserContext.Service>>;
|
|
842
842
|
readonly newContext: (options?: NewContextOptions) => Effect.Effect<typeof PlaywrightBrowserContext.Service, PlaywrightError, Scope$1>;
|
|
843
843
|
/**
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
844
|
+
* An Effect that returns the browser type (chromium, firefox or webkit) that the browser belongs to.
|
|
845
|
+
* @see {@link Browser.browserType}
|
|
846
|
+
*/
|
|
847
847
|
readonly browserType: Effect.Effect<BrowserType>;
|
|
848
848
|
/**
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
849
|
+
* An Effect that returns the version of the browser.
|
|
850
|
+
* @see {@link Browser.version}
|
|
851
|
+
*/
|
|
852
852
|
readonly version: Effect.Effect<string>;
|
|
853
853
|
/**
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
854
|
+
* An Effect that returns whether the browser is connected.
|
|
855
|
+
* @see {@link Browser.isConnected}
|
|
856
|
+
*/
|
|
857
857
|
readonly isConnected: Effect.Effect<boolean>;
|
|
858
858
|
/**
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
859
|
+
* Creates a stream of the given event from the browser.
|
|
860
|
+
*
|
|
861
|
+
* @example
|
|
862
|
+
* ```ts
|
|
863
|
+
* const disconnectedStream = browser.eventStream("disconnected");
|
|
864
|
+
* ```
|
|
865
|
+
*
|
|
866
|
+
* @category custom
|
|
867
|
+
* @see {@link Browser.on}
|
|
868
|
+
* @since 0.1.2
|
|
869
|
+
*/
|
|
870
870
|
readonly eventStream: <K extends keyof typeof eventMappings>(event: K) => Stream.Stream<ReturnType<(typeof eventMappings)[K]>>;
|
|
871
871
|
}
|
|
872
872
|
declare const PlaywrightBrowser_base: Context.TagClass<PlaywrightBrowser, "effect-playwright/PlaywrightBrowser", PlaywrightBrowserService>;
|
|
@@ -875,8 +875,8 @@ declare const PlaywrightBrowser_base: Context.TagClass<PlaywrightBrowser, "effec
|
|
|
875
875
|
*/
|
|
876
876
|
declare class PlaywrightBrowser extends PlaywrightBrowser_base {
|
|
877
877
|
/**
|
|
878
|
-
|
|
879
|
-
|
|
878
|
+
* @category constructor
|
|
879
|
+
*/
|
|
880
880
|
static make(browser: BrowserWithPatchedEvents): PlaywrightBrowserService;
|
|
881
881
|
}
|
|
882
882
|
//#endregion
|
|
@@ -887,106 +887,106 @@ declare class PlaywrightBrowser extends PlaywrightBrowser_base {
|
|
|
887
887
|
*/
|
|
888
888
|
interface PlaywrightService {
|
|
889
889
|
/**
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
890
|
+
* Launches a new browser instance.
|
|
891
|
+
*
|
|
892
|
+
* It is the caller's responsibility to manage the browser's lifecycle and close
|
|
893
|
+
* it when no longer needed. For automatic scope-based management, use
|
|
894
|
+
* {@link launchScoped} instead.
|
|
895
|
+
*
|
|
896
|
+
* ```ts
|
|
897
|
+
* import { Effect } from "effect";
|
|
898
|
+
* import { Playwright } from "effect-playwright";
|
|
899
|
+
* import { chromium } from "playwright-core";
|
|
900
|
+
*
|
|
901
|
+
* const program = Effect.gen(function* () {
|
|
902
|
+
* const browser = yield* Playwright.launch(chromium);
|
|
903
|
+
* // ... use browser ...
|
|
904
|
+
* yield* browser.close;
|
|
905
|
+
* });
|
|
906
|
+
*
|
|
907
|
+
* await Effect.runPromise(program);
|
|
908
|
+
* ```
|
|
909
|
+
*
|
|
910
|
+
* @param browserType - The browser type to launch (e.g. chromium, firefox, webkit).
|
|
911
|
+
* @param options - Optional launch options.
|
|
912
|
+
* @since 0.1.0
|
|
913
|
+
*/
|
|
914
914
|
launch: (browserType: BrowserType, options?: LaunchOptions$1) => Effect.Effect<typeof PlaywrightBrowser.Service, PlaywrightError>;
|
|
915
915
|
/**
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
916
|
+
* Launches a new browser instance managed by a Scope.
|
|
917
|
+
*
|
|
918
|
+
* This method automatically closes the browser when the scope is closed.
|
|
919
|
+
*
|
|
920
|
+
* ```ts
|
|
921
|
+
* import { Effect } from "effect";
|
|
922
|
+
* import { Playwright } from "effect-playwright";
|
|
923
|
+
* import { chromium } from "playwright-core";
|
|
924
|
+
*
|
|
925
|
+
* const program = Effect.gen(function* () {
|
|
926
|
+
* const browser = yield* Playwright.launchScoped(chromium);
|
|
927
|
+
* // Browser will be closed automatically when scope closes
|
|
928
|
+
* });
|
|
929
|
+
*
|
|
930
|
+
* await Effect.runPromise(program);
|
|
931
|
+
* ```
|
|
932
|
+
*
|
|
933
|
+
* @param browserType - The browser type to launch (e.g. chromium, firefox, webkit).
|
|
934
|
+
* @param options - Optional launch options.
|
|
935
|
+
* @since 0.1.0
|
|
936
|
+
*/
|
|
937
937
|
launchScoped: (browserType: BrowserType, options?: LaunchOptions$1) => Effect.Effect<typeof PlaywrightBrowser.Service, PlaywrightError, Scope.Scope>;
|
|
938
938
|
/**
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
939
|
+
* Connects to a browser instance via Chrome DevTools Protocol (CDP).
|
|
940
|
+
*
|
|
941
|
+
* Unlike {@link connectCDPScoped}, this method does **not** close the connection when the
|
|
942
|
+
* scope is closed. It is the caller's responsibility to manage the connection's
|
|
943
|
+
* lifecycle.
|
|
944
|
+
*
|
|
945
|
+
* If you want to close the connection using a scope simply add a finalizer:
|
|
946
|
+
*
|
|
947
|
+
* ```ts
|
|
948
|
+
* import { Effect } from "effect";
|
|
949
|
+
* import { Playwright } from "effect-playwright";
|
|
950
|
+
*
|
|
951
|
+
* const program = Effect.gen(function* () {
|
|
952
|
+
* const playwright = yield* Playwright;
|
|
953
|
+
* const browser = yield* playwright.connectCDP(cdpUrl);
|
|
954
|
+
* yield* Effect.addFinalizer(() => browser.close.pipe(Effect.ignore));
|
|
955
|
+
* });
|
|
956
|
+
*
|
|
957
|
+
* await Effect.runPromise(program);
|
|
958
|
+
* ```
|
|
959
|
+
*
|
|
960
|
+
* @param cdpUrl - The CDP URL to connect to.
|
|
961
|
+
* @param options - Optional options for connecting to the CDP URL.
|
|
962
|
+
* @since 0.1.0
|
|
963
|
+
*/
|
|
964
964
|
connectCDP: (cdpUrl: string, options?: ConnectOverCDPOptions) => Effect.Effect<typeof PlaywrightBrowser.Service, PlaywrightError>;
|
|
965
965
|
/**
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
966
|
+
* Connects to a browser instance via Chrome DevTools Protocol (CDP) managed by a Scope.
|
|
967
|
+
*
|
|
968
|
+
* This method automatically closes the connection when the scope is closed.
|
|
969
|
+
*
|
|
970
|
+
* Note that closing a CDP connection does **not** close the browser instance itself,
|
|
971
|
+
* only the CDP connection.
|
|
972
|
+
*
|
|
973
|
+
* ```ts
|
|
974
|
+
* import { Effect } from "effect";
|
|
975
|
+
* import { Playwright } from "effect-playwright";
|
|
976
|
+
*
|
|
977
|
+
* const program = Effect.gen(function* () {
|
|
978
|
+
* const playwright = yield* Playwright;
|
|
979
|
+
* const browser = yield* playwright.connectCDPScoped(cdpUrl);
|
|
980
|
+
* // Connection will be closed automatically when scope closes
|
|
981
|
+
* });
|
|
982
|
+
*
|
|
983
|
+
* await Effect.runPromise(program);
|
|
984
|
+
* ```
|
|
985
|
+
*
|
|
986
|
+
* @param cdpUrl - The CDP URL to connect to.
|
|
987
|
+
* @param options - Optional options for connecting to the CDP URL.
|
|
988
|
+
* @since 0.1.1
|
|
989
|
+
*/
|
|
990
990
|
connectCDPScoped: (cdpUrl: string, options?: ConnectOverCDPOptions) => Effect.Effect<typeof PlaywrightBrowser.Service, PlaywrightError, Scope.Scope>;
|
|
991
991
|
}
|
|
992
992
|
declare const Playwright_base: Context.TagClass<Playwright, "effect-playwright/index/Playwright", PlaywrightService>;
|
|
@@ -996,8 +996,8 @@ declare const Playwright_base: Context.TagClass<Playwright, "effect-playwright/i
|
|
|
996
996
|
*/
|
|
997
997
|
declare class Playwright extends Playwright_base {
|
|
998
998
|
/**
|
|
999
|
-
|
|
1000
|
-
|
|
999
|
+
* @category layer
|
|
1000
|
+
*/
|
|
1001
1001
|
static readonly layer: Layer.Layer<Playwright, never, never>;
|
|
1002
1002
|
}
|
|
1003
1003
|
//#endregion
|