playwright-ruby-client 1.20.2 → 1.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/documentation/docs/api/api_request_context.md +15 -2
- data/documentation/docs/api/browser.md +16 -0
- data/documentation/docs/api/browser_context.md +15 -2
- data/documentation/docs/api/browser_type.md +5 -1
- data/documentation/docs/api/console_message.md +27 -1
- data/documentation/docs/api/element_handle.md +23 -13
- data/documentation/docs/api/experimental/android.md +1 -1
- data/documentation/docs/api/experimental/android_device.md +4 -0
- data/documentation/docs/api/file_chooser.md +1 -1
- data/documentation/docs/api/frame.md +12 -5
- data/documentation/docs/api/frame_locator.md +1 -1
- data/documentation/docs/api/locator.md +44 -13
- data/documentation/docs/api/page.md +32 -9
- data/documentation/docs/api/request.md +3 -1
- data/documentation/docs/api/response.md +12 -1
- data/documentation/docs/api/route.md +67 -0
- data/documentation/docs/include/api_coverage.md +6 -3
- data/documentation/package.json +6 -6
- data/documentation/yarn.lock +2931 -3220
- data/lib/playwright/channel.rb +1 -3
- data/lib/playwright/channel_owners/browser.rb +13 -0
- data/lib/playwright/channel_owners/browser_context.rb +89 -13
- data/lib/playwright/channel_owners/browser_type.rb +4 -0
- data/lib/playwright/channel_owners/element_handle.rb +12 -3
- data/lib/playwright/channel_owners/frame.rb +20 -7
- data/lib/playwright/channel_owners/local_utils.rb +29 -0
- data/lib/playwright/channel_owners/page.rb +54 -22
- data/lib/playwright/channel_owners/request.rb +31 -6
- data/lib/playwright/channel_owners/response.rb +6 -0
- data/lib/playwright/channel_owners/route.rb +104 -45
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/connection.rb +6 -1
- data/lib/playwright/har_router.rb +82 -0
- data/lib/playwright/http_headers.rb +1 -1
- data/lib/playwright/input_files.rb +60 -8
- data/lib/playwright/javascript/regex.rb +23 -0
- data/lib/playwright/javascript/value_parser.rb +17 -2
- data/lib/playwright/javascript/value_serializer.rb +16 -6
- data/lib/playwright/javascript/visitor_info.rb +26 -0
- data/lib/playwright/javascript.rb +1 -0
- data/lib/playwright/locator_impl.rb +18 -5
- data/lib/playwright/playwright_api.rb +26 -6
- data/lib/playwright/route_handler.rb +2 -6
- data/lib/playwright/transport.rb +12 -2
- data/lib/playwright/utils.rb +31 -6
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright.rb +2 -0
- data/lib/playwright_api/accessibility.rb +2 -1
- data/lib/playwright_api/android.rb +2 -2
- data/lib/playwright_api/android_device.rb +5 -1
- data/lib/playwright_api/api_request.rb +3 -3
- data/lib/playwright_api/api_request_context.rb +15 -2
- data/lib/playwright_api/browser.rb +15 -2
- data/lib/playwright_api/browser_context.rb +17 -7
- data/lib/playwright_api/browser_type.rb +7 -3
- data/lib/playwright_api/console_message.rb +20 -1
- data/lib/playwright_api/element_handle.rb +53 -49
- data/lib/playwright_api/file_chooser.rb +1 -1
- data/lib/playwright_api/frame.rb +30 -23
- data/lib/playwright_api/frame_locator.rb +1 -1
- data/lib/playwright_api/locator.rb +58 -38
- data/lib/playwright_api/page.rb +52 -32
- data/lib/playwright_api/playwright.rb +1 -1
- data/lib/playwright_api/request.rb +8 -1
- data/lib/playwright_api/response.rb +14 -1
- data/lib/playwright_api/route.rb +63 -2
- data/lib/playwright_api/selectors.rb +1 -1
- data/lib/playwright_api/tracing.rb +1 -1
- metadata +7 -4
- data/lib/playwright_api/local_utils.rb +0 -9
@@ -2,7 +2,7 @@ module Playwright
|
|
2
2
|
# Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way
|
3
3
|
# to find element(s) on the page at any moment. Locator can be created with the [`method: Page.locator`] method.
|
4
4
|
#
|
5
|
-
# [Learn more about locators](
|
5
|
+
# [Learn more about locators](../locators.md).
|
6
6
|
class Locator < PlaywrightApi
|
7
7
|
|
8
8
|
# Returns an array of `node.innerText` values for all matching nodes.
|
@@ -39,7 +39,7 @@ module Playwright
|
|
39
39
|
# This method checks the element by performing the following steps:
|
40
40
|
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked,
|
41
41
|
# this method returns immediately.
|
42
|
-
# 1. Wait for [actionability](
|
42
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
43
43
|
# 1. Scroll the element into view if needed.
|
44
44
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
45
45
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
@@ -59,7 +59,7 @@ module Playwright
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# This method clicks the element by performing the following steps:
|
62
|
-
# 1. Wait for [actionability](
|
62
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
63
63
|
# 1. Scroll the element into view if needed.
|
64
64
|
# 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
|
65
65
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
@@ -87,7 +87,7 @@ module Playwright
|
|
87
87
|
end
|
88
88
|
|
89
89
|
# This method double clicks the element by performing the following steps:
|
90
|
-
# 1. Wait for [actionability](
|
90
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
91
91
|
# 1. Scroll the element into view if needed.
|
92
92
|
# 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
|
93
93
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
|
@@ -211,7 +211,7 @@ module Playwright
|
|
211
211
|
wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg), timeout: unwrap_impl(timeout)))
|
212
212
|
end
|
213
213
|
|
214
|
-
# This method waits for [actionability](
|
214
|
+
# This method waits for [actionability](../actionability.md) checks, focuses the element, fills it and triggers an `input`
|
215
215
|
# event after filling. Note that you can pass an empty string to clear the input field.
|
216
216
|
#
|
217
217
|
# If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
|
@@ -224,6 +224,21 @@ module Playwright
|
|
224
224
|
wrap_impl(@impl.fill(unwrap_impl(value), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
225
225
|
end
|
226
226
|
|
227
|
+
# This method narrows existing locator according to the options, for example filters by text. It can be chained to filter
|
228
|
+
# multiple times.
|
229
|
+
#
|
230
|
+
# ```python sync
|
231
|
+
# row_locator = page.lsocator("tr")
|
232
|
+
# # ...
|
233
|
+
# row_locator
|
234
|
+
# .filter(has_text="text in column 1")
|
235
|
+
# .filter(has=page.locator("tr", has_text="column 2 button"))
|
236
|
+
# .screenshot()
|
237
|
+
# ```
|
238
|
+
def filter(has: nil, hasText: nil)
|
239
|
+
wrap_impl(@impl.filter(has: unwrap_impl(has), hasText: unwrap_impl(hasText)))
|
240
|
+
end
|
241
|
+
|
227
242
|
# Returns locator to the first matching element.
|
228
243
|
def first
|
229
244
|
wrap_impl(@impl.first)
|
@@ -257,7 +272,7 @@ module Playwright
|
|
257
272
|
end
|
258
273
|
|
259
274
|
# This method hovers over the element by performing the following steps:
|
260
|
-
# 1. Wait for [actionability](
|
275
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
261
276
|
# 1. Scroll the element into view if needed.
|
262
277
|
# 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
|
263
278
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
@@ -285,7 +300,10 @@ module Playwright
|
|
285
300
|
wrap_impl(@impl.inner_text(timeout: unwrap_impl(timeout)))
|
286
301
|
end
|
287
302
|
|
288
|
-
# Returns `input.value` for `<input>` or `<textarea>` or `<select>` element.
|
303
|
+
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
304
|
+
#
|
305
|
+
# Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
|
306
|
+
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
289
307
|
def input_value(timeout: nil)
|
290
308
|
wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
|
291
309
|
end
|
@@ -295,27 +313,27 @@ module Playwright
|
|
295
313
|
wrap_impl(@impl.checked?(timeout: unwrap_impl(timeout)))
|
296
314
|
end
|
297
315
|
|
298
|
-
# Returns whether the element is disabled, the opposite of [enabled](
|
316
|
+
# Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
|
299
317
|
def disabled?(timeout: nil)
|
300
318
|
wrap_impl(@impl.disabled?(timeout: unwrap_impl(timeout)))
|
301
319
|
end
|
302
320
|
|
303
|
-
# Returns whether the element is [editable](
|
321
|
+
# Returns whether the element is [editable](../actionability.md#editable).
|
304
322
|
def editable?(timeout: nil)
|
305
323
|
wrap_impl(@impl.editable?(timeout: unwrap_impl(timeout)))
|
306
324
|
end
|
307
325
|
|
308
|
-
# Returns whether the element is [enabled](
|
326
|
+
# Returns whether the element is [enabled](../actionability.md#enabled).
|
309
327
|
def enabled?(timeout: nil)
|
310
328
|
wrap_impl(@impl.enabled?(timeout: unwrap_impl(timeout)))
|
311
329
|
end
|
312
330
|
|
313
|
-
# Returns whether the element is hidden, the opposite of [visible](
|
331
|
+
# Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible).
|
314
332
|
def hidden?(timeout: nil)
|
315
333
|
wrap_impl(@impl.hidden?(timeout: unwrap_impl(timeout)))
|
316
334
|
end
|
317
335
|
|
318
|
-
# Returns whether the element is [visible](
|
336
|
+
# Returns whether the element is [visible](../actionability.md#visible).
|
319
337
|
def visible?(timeout: nil)
|
320
338
|
wrap_impl(@impl.visible?(timeout: unwrap_impl(timeout)))
|
321
339
|
end
|
@@ -325,12 +343,13 @@ module Playwright
|
|
325
343
|
wrap_impl(@impl.last)
|
326
344
|
end
|
327
345
|
|
328
|
-
# The method finds an element matching the specified selector in the `Locator`'s subtree.
|
346
|
+
# The method finds an element matching the specified selector in the `Locator`'s subtree. It also accepts filter options,
|
347
|
+
# similar to [`method: Locator.filter`] method.
|
329
348
|
def locator(selector, has: nil, hasText: nil)
|
330
349
|
wrap_impl(@impl.locator(unwrap_impl(selector), has: unwrap_impl(has), hasText: unwrap_impl(hasText)))
|
331
350
|
end
|
332
351
|
|
333
|
-
# Returns locator to the n-th matching element.
|
352
|
+
# Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
|
334
353
|
def nth(index)
|
335
354
|
wrap_impl(@impl.nth(unwrap_impl(index)))
|
336
355
|
end
|
@@ -362,29 +381,35 @@ module Playwright
|
|
362
381
|
wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
363
382
|
end
|
364
383
|
|
365
|
-
#
|
384
|
+
# This method captures a screenshot of the page, clipped to the size and position of a particular element matching the
|
385
|
+
# locator. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element
|
386
|
+
# is a scrollable container, only the currently scrolled content will be visible on the screenshot.
|
366
387
|
#
|
367
|
-
# This method waits for the [actionability](
|
388
|
+
# This method waits for the [actionability](../actionability.md) checks, then scrolls element into view before taking a
|
368
389
|
# screenshot. If the element is detached from DOM, the method throws an error.
|
390
|
+
#
|
391
|
+
# Returns the buffer with the captured screenshot.
|
369
392
|
def screenshot(
|
370
393
|
animations: nil,
|
394
|
+
caret: nil,
|
371
395
|
mask: nil,
|
372
396
|
omitBackground: nil,
|
373
397
|
path: nil,
|
374
398
|
quality: nil,
|
399
|
+
scale: nil,
|
375
400
|
timeout: nil,
|
376
401
|
type: nil)
|
377
|
-
wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
402
|
+
wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
378
403
|
end
|
379
404
|
|
380
|
-
# This method waits for [actionability](
|
405
|
+
# This method waits for [actionability](../actionability.md) checks, then tries to scroll element into view, unless it is
|
381
406
|
# completely visible as defined by
|
382
407
|
# [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`.
|
383
408
|
def scroll_into_view_if_needed(timeout: nil)
|
384
409
|
wrap_impl(@impl.scroll_into_view_if_needed(timeout: unwrap_impl(timeout)))
|
385
410
|
end
|
386
411
|
|
387
|
-
# This method waits for [actionability](
|
412
|
+
# This method waits for [actionability](../actionability.md) checks, waits until all specified options are present in the
|
388
413
|
# `<select>` element and selects these options.
|
389
414
|
#
|
390
415
|
# If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
|
@@ -403,17 +428,6 @@ module Playwright
|
|
403
428
|
# # multiple selection
|
404
429
|
# element.select_option(value=["red", "green", "blue"])
|
405
430
|
# ```
|
406
|
-
#
|
407
|
-
# ```python sync
|
408
|
-
# # single selection matching the value
|
409
|
-
# element.select_option("blue")
|
410
|
-
# # single selection matching both the value and the label
|
411
|
-
# element.select_option(label="blue")
|
412
|
-
# # multiple selection
|
413
|
-
# element.select_option("red", "green", "blue")
|
414
|
-
# # multiple selection for blue, red and second option
|
415
|
-
# element.select_option(value="blue", { index: 2 }, "red")
|
416
|
-
# ```
|
417
431
|
def select_option(
|
418
432
|
element: nil,
|
419
433
|
index: nil,
|
@@ -425,8 +439,12 @@ module Playwright
|
|
425
439
|
wrap_impl(@impl.select_option(element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
426
440
|
end
|
427
441
|
|
428
|
-
# This method waits for [actionability](
|
442
|
+
# This method waits for [actionability](../actionability.md) checks, then focuses the element and selects all its text
|
429
443
|
# content.
|
444
|
+
#
|
445
|
+
# If the element is inside the `<label>` element that has an associated
|
446
|
+
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the
|
447
|
+
# control instead.
|
430
448
|
def select_text(force: nil, timeout: nil)
|
431
449
|
wrap_impl(@impl.select_text(force: unwrap_impl(force), timeout: unwrap_impl(timeout)))
|
432
450
|
end
|
@@ -434,7 +452,7 @@ module Playwright
|
|
434
452
|
# This method checks or unchecks an element by performing the following steps:
|
435
453
|
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
|
436
454
|
# 1. If the element already has the right checked state, this method returns immediately.
|
437
|
-
# 1. Wait for [actionability](
|
455
|
+
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
438
456
|
# element is detached during the checks, the whole action is retried.
|
439
457
|
# 1. Scroll the element into view if needed.
|
440
458
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
@@ -454,18 +472,20 @@ module Playwright
|
|
454
472
|
end
|
455
473
|
alias_method :checked=, :set_checked
|
456
474
|
|
457
|
-
# This method expects `element` to point to an
|
458
|
-
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
459
|
-
#
|
460
475
|
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
461
|
-
# are resolved relative to the
|
476
|
+
# are resolved relative to the current working directory. For empty array, clears the selected files.
|
477
|
+
#
|
478
|
+
# This method expects `Locator` to point to an
|
479
|
+
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
|
480
|
+
# `<label>` element that has an associated
|
481
|
+
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
462
482
|
def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
463
483
|
wrap_impl(@impl.set_input_files(unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
464
484
|
end
|
465
485
|
alias_method :input_files=, :set_input_files
|
466
486
|
|
467
487
|
# This method taps the element by performing the following steps:
|
468
|
-
# 1. Wait for [actionability](
|
488
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
469
489
|
# 1. Scroll the element into view if needed.
|
470
490
|
# 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
|
471
491
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
@@ -514,7 +534,7 @@ module Playwright
|
|
514
534
|
# This method checks the element by performing the following steps:
|
515
535
|
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
|
516
536
|
# unchecked, this method returns immediately.
|
517
|
-
# 1. Wait for [actionability](
|
537
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
518
538
|
# 1. Scroll the element into view if needed.
|
519
539
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
520
540
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
data/lib/playwright_api/page.rb
CHANGED
@@ -56,7 +56,8 @@ module Playwright
|
|
56
56
|
wrap_impl(@impl.mouse)
|
57
57
|
end
|
58
58
|
|
59
|
-
# API testing helper associated with this page.
|
59
|
+
# API testing helper associated with this page. This method returns the same instance as
|
60
|
+
# [`property: BrowserContext.request`] on the page's context. See [`property: BrowserContext.request`] for more details.
|
60
61
|
def request # property
|
61
62
|
wrap_impl(@impl.request)
|
62
63
|
end
|
@@ -111,7 +112,7 @@ module Playwright
|
|
111
112
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
112
113
|
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
|
113
114
|
# checked, this method returns immediately.
|
114
|
-
# 1. Wait for [actionability](
|
115
|
+
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
115
116
|
# element is detached during the checks, the whole action is retried.
|
116
117
|
# 1. Scroll the element into view if needed.
|
117
118
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
@@ -135,7 +136,7 @@ module Playwright
|
|
135
136
|
|
136
137
|
# This method clicks an element matching `selector` by performing the following steps:
|
137
138
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
138
|
-
# 1. Wait for [actionability](
|
139
|
+
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
139
140
|
# element is detached during the checks, the whole action is retried.
|
140
141
|
# 1. Scroll the element into view if needed.
|
141
142
|
# 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
|
@@ -183,7 +184,7 @@ module Playwright
|
|
183
184
|
|
184
185
|
# This method double clicks an element matching `selector` by performing the following steps:
|
185
186
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
186
|
-
# 1. Wait for [actionability](
|
187
|
+
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
187
188
|
# element is detached during the checks, the whole action is retried.
|
188
189
|
# 1. Scroll the element into view if needed.
|
189
190
|
# 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
|
@@ -501,7 +502,7 @@ module Playwright
|
|
501
502
|
wrap_impl(@impl.expose_function(unwrap_impl(name), unwrap_impl(callback)))
|
502
503
|
end
|
503
504
|
|
504
|
-
# This method waits for an element matching `selector`, waits for [actionability](
|
505
|
+
# This method waits for an element matching `selector`, waits for [actionability](../actionability.md) checks, focuses the
|
505
506
|
# element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
|
506
507
|
# field.
|
507
508
|
#
|
@@ -582,8 +583,8 @@ module Playwright
|
|
582
583
|
wrap_impl(@impl.go_forward(timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
583
584
|
end
|
584
585
|
|
585
|
-
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the
|
586
|
-
#
|
586
|
+
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the first
|
587
|
+
# non-redirect response.
|
587
588
|
#
|
588
589
|
# The method will throw an error if:
|
589
590
|
# - there's an SSL error (e.g. in case of self-signed certificates).
|
@@ -608,7 +609,7 @@ module Playwright
|
|
608
609
|
|
609
610
|
# This method hovers over an element matching `selector` by performing the following steps:
|
610
611
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
611
|
-
# 1. Wait for [actionability](
|
612
|
+
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
612
613
|
# element is detached during the checks, the whole action is retried.
|
613
614
|
# 1. Scroll the element into view if needed.
|
614
615
|
# 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
|
@@ -639,7 +640,10 @@ module Playwright
|
|
639
640
|
wrap_impl(@impl.inner_text(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
640
641
|
end
|
641
642
|
|
642
|
-
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
643
|
+
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
644
|
+
#
|
645
|
+
# Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
|
646
|
+
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
643
647
|
def input_value(selector, strict: nil, timeout: nil)
|
644
648
|
wrap_impl(@impl.input_value(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
645
649
|
end
|
@@ -654,28 +658,28 @@ module Playwright
|
|
654
658
|
wrap_impl(@impl.closed?)
|
655
659
|
end
|
656
660
|
|
657
|
-
# Returns whether the element is disabled, the opposite of [enabled](
|
661
|
+
# Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
|
658
662
|
def disabled?(selector, strict: nil, timeout: nil)
|
659
663
|
wrap_impl(@impl.disabled?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
660
664
|
end
|
661
665
|
|
662
|
-
# Returns whether the element is [editable](
|
666
|
+
# Returns whether the element is [editable](../actionability.md#editable).
|
663
667
|
def editable?(selector, strict: nil, timeout: nil)
|
664
668
|
wrap_impl(@impl.editable?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
665
669
|
end
|
666
670
|
|
667
|
-
# Returns whether the element is [enabled](
|
671
|
+
# Returns whether the element is [enabled](../actionability.md#enabled).
|
668
672
|
def enabled?(selector, strict: nil, timeout: nil)
|
669
673
|
wrap_impl(@impl.enabled?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
670
674
|
end
|
671
675
|
|
672
|
-
# Returns whether the element is hidden, the opposite of [visible](
|
676
|
+
# Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible). `selector` that does not
|
673
677
|
# match any elements is considered hidden.
|
674
678
|
def hidden?(selector, strict: nil, timeout: nil)
|
675
679
|
wrap_impl(@impl.hidden?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
676
680
|
end
|
677
681
|
|
678
|
-
# Returns whether the element is [visible](
|
682
|
+
# Returns whether the element is [visible](../actionability.md#visible). `selector` that does not match any elements is
|
679
683
|
# considered not visible.
|
680
684
|
def visible?(selector, strict: nil, timeout: nil)
|
681
685
|
wrap_impl(@impl.visible?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
@@ -685,6 +689,8 @@ module Playwright
|
|
685
689
|
# element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
686
690
|
# different DOM elements. That would happen if the DOM structure between those actions has changed.
|
687
691
|
#
|
692
|
+
# [Learn more about locators](../locators.md).
|
693
|
+
#
|
688
694
|
# Shortcut for main frame's [`method: Frame.locator`].
|
689
695
|
def locator(selector, has: nil, hasText: nil)
|
690
696
|
wrap_impl(@impl.locator(unwrap_impl(selector), has: unwrap_impl(has), hasText: unwrap_impl(hasText)))
|
@@ -847,7 +853,7 @@ module Playwright
|
|
847
853
|
# > NOTE: The handler will only be called for the first url if the response is a redirect.
|
848
854
|
# > NOTE: [`method: Page.route`] will not intercept requests intercepted by Service Worker. See
|
849
855
|
# [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
|
850
|
-
# request interception
|
856
|
+
# request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
|
851
857
|
#
|
852
858
|
# An example of a naive handler that aborts all image requests:
|
853
859
|
#
|
@@ -889,21 +895,33 @@ module Playwright
|
|
889
895
|
wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler), times: unwrap_impl(times)))
|
890
896
|
end
|
891
897
|
|
898
|
+
# If specified the network requests that are made in the page will be served from the HAR file. Read more about
|
899
|
+
# [Replaying from HAR](../network.md#replaying-from-har).
|
900
|
+
#
|
901
|
+
# Playwright will not serve requests intercepted by Service Worker from the HAR file. See
|
902
|
+
# [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
|
903
|
+
# request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
|
904
|
+
def route_from_har(har, notFound: nil, update: nil, url: nil)
|
905
|
+
wrap_impl(@impl.route_from_har(unwrap_impl(har), notFound: unwrap_impl(notFound), update: unwrap_impl(update), url: unwrap_impl(url)))
|
906
|
+
end
|
907
|
+
|
892
908
|
# Returns the buffer with the captured screenshot.
|
893
909
|
def screenshot(
|
894
910
|
animations: nil,
|
911
|
+
caret: nil,
|
895
912
|
clip: nil,
|
896
913
|
fullPage: nil,
|
897
914
|
mask: nil,
|
898
915
|
omitBackground: nil,
|
899
916
|
path: nil,
|
900
917
|
quality: nil,
|
918
|
+
scale: nil,
|
901
919
|
timeout: nil,
|
902
920
|
type: nil)
|
903
|
-
wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), clip: unwrap_impl(clip), fullPage: unwrap_impl(fullPage), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
921
|
+
wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), clip: unwrap_impl(clip), fullPage: unwrap_impl(fullPage), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
904
922
|
end
|
905
923
|
|
906
|
-
# This method waits for an element matching `selector`, waits for [actionability](
|
924
|
+
# This method waits for an element matching `selector`, waits for [actionability](../actionability.md) checks, waits until
|
907
925
|
# all specified options are present in the `<select>` element and selects these options.
|
908
926
|
#
|
909
927
|
# If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
|
@@ -941,7 +959,7 @@ module Playwright
|
|
941
959
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
942
960
|
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
|
943
961
|
# 1. If the element already has the right checked state, this method returns immediately.
|
944
|
-
# 1. Wait for [actionability](
|
962
|
+
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
945
963
|
# element is detached during the checks, the whole action is retried.
|
946
964
|
# 1. Scroll the element into view if needed.
|
947
965
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
@@ -1001,11 +1019,13 @@ module Playwright
|
|
1001
1019
|
end
|
1002
1020
|
alias_method :extra_http_headers=, :set_extra_http_headers
|
1003
1021
|
|
1004
|
-
# This method expects `selector` to point to an
|
1005
|
-
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
1006
|
-
#
|
1007
1022
|
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
1008
|
-
# are resolved relative to the
|
1023
|
+
# are resolved relative to the current working directory. For empty array, clears the selected files.
|
1024
|
+
#
|
1025
|
+
# This method expects `selector` to point to an
|
1026
|
+
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
|
1027
|
+
# `<label>` element that has an associated
|
1028
|
+
# [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
1009
1029
|
def set_input_files(
|
1010
1030
|
selector,
|
1011
1031
|
files,
|
@@ -1035,7 +1055,7 @@ module Playwright
|
|
1035
1055
|
|
1036
1056
|
# This method taps an element matching `selector` by performing the following steps:
|
1037
1057
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
1038
|
-
# 1. Wait for [actionability](
|
1058
|
+
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
1039
1059
|
# element is detached during the checks, the whole action is retried.
|
1040
1060
|
# 1. Scroll the element into view if needed.
|
1041
1061
|
# 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
|
@@ -1094,7 +1114,7 @@ module Playwright
|
|
1094
1114
|
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
1095
1115
|
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
|
1096
1116
|
# unchecked, this method returns immediately.
|
1097
|
-
# 1. Wait for [actionability](
|
1117
|
+
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the
|
1098
1118
|
# element is detached during the checks, the whole action is retried.
|
1099
1119
|
# 1. Scroll the element into view if needed.
|
1100
1120
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
@@ -1252,7 +1272,7 @@ module Playwright
|
|
1252
1272
|
wrap_impl(@impl.expect_popup(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
1253
1273
|
end
|
1254
1274
|
|
1255
|
-
# Waits for the matching request and returns it. See [waiting for event](
|
1275
|
+
# Waits for the matching request and returns it. See [waiting for event](../events.md#waiting-for-event) for more details
|
1256
1276
|
# about events.
|
1257
1277
|
#
|
1258
1278
|
# ```python sync
|
@@ -1276,7 +1296,7 @@ module Playwright
|
|
1276
1296
|
wrap_impl(@impl.expect_request_finished(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
1277
1297
|
end
|
1278
1298
|
|
1279
|
-
# Returns the matched response. See [waiting for event](
|
1299
|
+
# Returns the matched response. See [waiting for event](../events.md#waiting-for-event) for more details about events.
|
1280
1300
|
#
|
1281
1301
|
# ```python sync
|
1282
1302
|
# with page.expect_response("https://example.com/resource") as response_info:
|
@@ -1395,8 +1415,8 @@ module Playwright
|
|
1395
1415
|
end
|
1396
1416
|
|
1397
1417
|
# @nodoc
|
1398
|
-
def
|
1399
|
-
wrap_impl(@impl.
|
1418
|
+
def guid
|
1419
|
+
wrap_impl(@impl.guid)
|
1400
1420
|
end
|
1401
1421
|
|
1402
1422
|
# @nodoc
|
@@ -1405,13 +1425,13 @@ module Playwright
|
|
1405
1425
|
end
|
1406
1426
|
|
1407
1427
|
# @nodoc
|
1408
|
-
def
|
1409
|
-
wrap_impl(@impl.
|
1428
|
+
def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
|
1429
|
+
wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
|
1410
1430
|
end
|
1411
1431
|
|
1412
1432
|
# @nodoc
|
1413
|
-
def
|
1414
|
-
wrap_impl(@impl.
|
1433
|
+
def stop_css_coverage
|
1434
|
+
wrap_impl(@impl.stop_css_coverage)
|
1415
1435
|
end
|
1416
1436
|
|
1417
1437
|
# -- inherited from EventEmitter --
|
@@ -55,7 +55,7 @@ module Playwright
|
|
55
55
|
raise NotImplementedError.new('request is not implemented yet.')
|
56
56
|
end
|
57
57
|
|
58
|
-
# Selectors can be used to install custom selector engines. See [Working with selectors](
|
58
|
+
# Selectors can be used to install custom selector engines. See [Working with selectors](../selectors.md) for more
|
59
59
|
# information.
|
60
60
|
def selectors # property
|
61
61
|
wrap_impl(@impl.selectors)
|
@@ -35,7 +35,9 @@ module Playwright
|
|
35
35
|
wrap_impl(@impl.frame)
|
36
36
|
end
|
37
37
|
|
38
|
-
#
|
38
|
+
# An object with the request HTTP headers. The header names are lower-cased. Note that this method does not return
|
39
|
+
# security-related headers, including cookie-related ones. You can use [`method: Request.allHeaders`] for complete list of
|
40
|
+
# headers that include `cookie` information.
|
39
41
|
def headers
|
40
42
|
wrap_impl(@impl.headers)
|
41
43
|
end
|
@@ -149,6 +151,11 @@ module Playwright
|
|
149
151
|
wrap_impl(@impl.url)
|
150
152
|
end
|
151
153
|
|
154
|
+
# @nodoc
|
155
|
+
def apply_fallback_overrides(overrides)
|
156
|
+
wrap_impl(@impl.apply_fallback_overrides(unwrap_impl(overrides)))
|
157
|
+
end
|
158
|
+
|
152
159
|
# @nodoc
|
153
160
|
def header_values(name)
|
154
161
|
wrap_impl(@impl.header_values(unwrap_impl(name)))
|
@@ -22,7 +22,15 @@ module Playwright
|
|
22
22
|
wrap_impl(@impl.frame)
|
23
23
|
end
|
24
24
|
|
25
|
-
#
|
25
|
+
# Indicates whether this Response was fullfilled by a Service Worker's Fetch Handler (i.e. via
|
26
|
+
# [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).
|
27
|
+
def from_service_worker
|
28
|
+
wrap_impl(@impl.from_service_worker)
|
29
|
+
end
|
30
|
+
|
31
|
+
# An object with the response HTTP headers. The header names are lower-cased. Note that this method does not return
|
32
|
+
# security-related headers, including cookie-related ones. You can use [`method: Response.allHeaders`] for complete list
|
33
|
+
# of headers that include `cookie` information.
|
26
34
|
def headers
|
27
35
|
wrap_impl(@impl.headers)
|
28
36
|
end
|
@@ -92,6 +100,11 @@ module Playwright
|
|
92
100
|
wrap_impl(@impl.url)
|
93
101
|
end
|
94
102
|
|
103
|
+
# @nodoc
|
104
|
+
def from_service_worker?
|
105
|
+
wrap_impl(@impl.from_service_worker?)
|
106
|
+
end
|
107
|
+
|
95
108
|
# @nodoc
|
96
109
|
def ok?
|
97
110
|
wrap_impl(@impl.ok?)
|
data/lib/playwright_api/route.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Playwright
|
2
2
|
# Whenever a network route is set up with [`method: Page.route`] or [`method: BrowserContext.route`], the `Route` object
|
3
3
|
# allows to handle the route.
|
4
|
+
#
|
5
|
+
# Learn more about [networking](../network.md).
|
4
6
|
class Route < PlaywrightApi
|
5
7
|
|
6
8
|
# Aborts the route's request.
|
@@ -15,8 +17,8 @@ module Playwright
|
|
15
17
|
# # override headers
|
16
18
|
# headers = {
|
17
19
|
# **request.headers,
|
18
|
-
# "foo": "
|
19
|
-
# "
|
20
|
+
# "foo": "foo-value" # set "foo" header
|
21
|
+
# "bar": None # remove "bar" header
|
20
22
|
# }
|
21
23
|
# route.continue_(headers=headers)
|
22
24
|
# }
|
@@ -26,6 +28,60 @@ module Playwright
|
|
26
28
|
wrap_impl(@impl.continue(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
|
27
29
|
end
|
28
30
|
|
31
|
+
# When several routes match the given pattern, they run in the order opposite to their registration. That way the last
|
32
|
+
# registered route can always override all the previos ones. In the example below, request will be handled by the
|
33
|
+
# bottom-most handler first, then it'll fall back to the previous one and in the end will be aborted by the first
|
34
|
+
# registered route.
|
35
|
+
#
|
36
|
+
# ```python sync
|
37
|
+
# page.route("**/*", lambda route: route.abort()) # Runs last.
|
38
|
+
# page.route("**/*", lambda route: route.fallback()) # Runs second.
|
39
|
+
# page.route("**/*", lambda route: route.fallback()) # Runs first.
|
40
|
+
# ```
|
41
|
+
#
|
42
|
+
# Registering multiple routes is useful when you want separate handlers to handle different kinds of requests, for example
|
43
|
+
# API calls vs page resources or GET requests vs POST requests as in the example below.
|
44
|
+
#
|
45
|
+
# ```python sync
|
46
|
+
# # Handle GET requests.
|
47
|
+
# def handle_post(route):
|
48
|
+
# if route.request.method != "GET":
|
49
|
+
# route.fallback()
|
50
|
+
# return
|
51
|
+
# # Handling GET only.
|
52
|
+
# # ...
|
53
|
+
#
|
54
|
+
# # Handle POST requests.
|
55
|
+
# def handle_post(route):
|
56
|
+
# if route.request.method != "POST":
|
57
|
+
# route.fallback()
|
58
|
+
# return
|
59
|
+
# # Handling POST only.
|
60
|
+
# # ...
|
61
|
+
#
|
62
|
+
# page.route("**/*", handle_get)
|
63
|
+
# page.route("**/*", handle_post)
|
64
|
+
# ```
|
65
|
+
#
|
66
|
+
# One can also modify request while falling back to the subsequent handler, that way intermediate route handler can modify
|
67
|
+
# url, method, headers and postData of the request.
|
68
|
+
#
|
69
|
+
# ```python sync
|
70
|
+
# def handle(route, request):
|
71
|
+
# # override headers
|
72
|
+
# headers = {
|
73
|
+
# **request.headers,
|
74
|
+
# "foo": "foo-value" # set "foo" header
|
75
|
+
# "bar": None # remove "bar" header
|
76
|
+
# }
|
77
|
+
# route.fallback(headers=headers)
|
78
|
+
# }
|
79
|
+
# page.route("**/*", handle)
|
80
|
+
# ```
|
81
|
+
def fallback(headers: nil, method: nil, postData: nil, url: nil)
|
82
|
+
wrap_impl(@impl.fallback(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
|
83
|
+
end
|
84
|
+
|
29
85
|
# Fulfills route's request with given response.
|
30
86
|
#
|
31
87
|
# An example of fulfilling all requests with 404 responses:
|
@@ -57,6 +113,11 @@ module Playwright
|
|
57
113
|
wrap_impl(@impl.request)
|
58
114
|
end
|
59
115
|
|
116
|
+
# @nodoc
|
117
|
+
def redirect_navigation_request(url)
|
118
|
+
wrap_impl(@impl.redirect_navigation_request(unwrap_impl(url)))
|
119
|
+
end
|
120
|
+
|
60
121
|
# -- inherited from EventEmitter --
|
61
122
|
# @nodoc
|
62
123
|
def off(event, callback)
|