playwright-ruby-client 1.21.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/browser.md +30 -5
  3. data/documentation/docs/api/browser_context.md +20 -7
  4. data/documentation/docs/api/browser_type.md +4 -0
  5. data/documentation/docs/api/download.md +1 -1
  6. data/documentation/docs/api/element_handle.md +20 -12
  7. data/documentation/docs/api/experimental/android.md +1 -1
  8. data/documentation/docs/api/experimental/android_device.md +4 -0
  9. data/documentation/docs/api/file_chooser.md +2 -2
  10. data/documentation/docs/api/frame.md +12 -5
  11. data/documentation/docs/api/locator.md +43 -13
  12. data/documentation/docs/api/page.md +31 -11
  13. data/documentation/docs/api/request.md +3 -1
  14. data/documentation/docs/api/response.md +12 -1
  15. data/documentation/docs/api/route.md +67 -0
  16. data/documentation/docs/api/selectors.md +2 -2
  17. data/documentation/docs/api/tracing.md +1 -1
  18. data/documentation/docs/include/api_coverage.md +6 -3
  19. data/documentation/package.json +4 -4
  20. data/documentation/yarn.lock +1876 -1304
  21. data/lib/playwright/channel.rb +1 -3
  22. data/lib/playwright/channel_owners/browser.rb +13 -0
  23. data/lib/playwright/channel_owners/browser_context.rb +81 -13
  24. data/lib/playwright/channel_owners/browser_type.rb +4 -0
  25. data/lib/playwright/channel_owners/frame.rb +16 -2
  26. data/lib/playwright/channel_owners/local_utils.rb +29 -0
  27. data/lib/playwright/channel_owners/page.rb +43 -15
  28. data/lib/playwright/channel_owners/request.rb +31 -6
  29. data/lib/playwright/channel_owners/response.rb +6 -0
  30. data/lib/playwright/channel_owners/route.rb +104 -45
  31. data/lib/playwright/connection.rb +6 -1
  32. data/lib/playwright/har_router.rb +82 -0
  33. data/lib/playwright/http_headers.rb +1 -1
  34. data/lib/playwright/javascript/regex.rb +23 -0
  35. data/lib/playwright/javascript/value_parser.rb +21 -2
  36. data/lib/playwright/javascript/value_serializer.rb +18 -6
  37. data/lib/playwright/javascript/visitor_info.rb +26 -0
  38. data/lib/playwright/javascript.rb +1 -0
  39. data/lib/playwright/locator_impl.rb +13 -5
  40. data/lib/playwright/playwright_api.rb +26 -6
  41. data/lib/playwright/route_handler.rb +2 -6
  42. data/lib/playwright/utils.rb +31 -6
  43. data/lib/playwright/version.rb +2 -2
  44. data/lib/playwright.rb +2 -0
  45. data/lib/playwright_api/android.rb +8 -8
  46. data/lib/playwright_api/android_device.rb +11 -7
  47. data/lib/playwright_api/api_request_context.rb +6 -6
  48. data/lib/playwright_api/browser.rb +34 -8
  49. data/lib/playwright_api/browser_context.rb +21 -11
  50. data/lib/playwright_api/browser_type.rb +11 -7
  51. data/lib/playwright_api/cdp_session.rb +6 -6
  52. data/lib/playwright_api/console_message.rb +6 -6
  53. data/lib/playwright_api/dialog.rb +6 -6
  54. data/lib/playwright_api/download.rb +1 -1
  55. data/lib/playwright_api/element_handle.rb +26 -24
  56. data/lib/playwright_api/file_chooser.rb +2 -2
  57. data/lib/playwright_api/frame.rb +18 -11
  58. data/lib/playwright_api/js_handle.rb +6 -6
  59. data/lib/playwright_api/locator.rb +38 -19
  60. data/lib/playwright_api/page.rb +33 -16
  61. data/lib/playwright_api/playwright.rb +8 -8
  62. data/lib/playwright_api/request.rb +14 -7
  63. data/lib/playwright_api/response.rb +20 -7
  64. data/lib/playwright_api/route.rb +69 -8
  65. data/lib/playwright_api/selectors.rb +7 -7
  66. data/lib/playwright_api/tracing.rb +7 -7
  67. data/lib/playwright_api/web_socket.rb +6 -6
  68. data/lib/playwright_api/worker.rb +8 -8
  69. metadata +6 -4
  70. data/lib/playwright_api/local_utils.rb +0 -9
@@ -18,7 +18,7 @@ module Playwright
18
18
  # This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
19
19
  # calculated relative to the main frame viewport - which is usually the same as the browser window.
20
20
  #
21
- # Scrolling affects the returned bonding box, similarly to
21
+ # Scrolling affects the returned bounding box, similarly to
22
22
  # [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
23
23
  # means `x` and/or `y` may be negative.
24
24
  #
@@ -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.locator("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)
@@ -249,6 +264,7 @@ module Playwright
249
264
  def get_attribute(name, timeout: nil)
250
265
  wrap_impl(@impl.get_attribute(unwrap_impl(name), timeout: unwrap_impl(timeout)))
251
266
  end
267
+ alias_method :[], :get_attribute
252
268
 
253
269
  # Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses
254
270
  # [`method: Locator.highlight`].
@@ -285,7 +301,10 @@ module Playwright
285
301
  wrap_impl(@impl.inner_text(timeout: unwrap_impl(timeout)))
286
302
  end
287
303
 
288
- # Returns `input.value` for `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
304
+ # Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
305
+ #
306
+ # Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
307
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
289
308
  def input_value(timeout: nil)
290
309
  wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
291
310
  end
@@ -325,7 +344,8 @@ module Playwright
325
344
  wrap_impl(@impl.last)
326
345
  end
327
346
 
328
- # The method finds an element matching the specified selector in the `Locator`'s subtree.
347
+ # The method finds an element matching the specified selector in the `Locator`'s subtree. It also accepts filter options,
348
+ # similar to [`method: Locator.filter`] method.
329
349
  def locator(selector, has: nil, hasText: nil)
330
350
  wrap_impl(@impl.locator(unwrap_impl(selector), has: unwrap_impl(has), hasText: unwrap_impl(hasText)))
331
351
  end
@@ -362,10 +382,14 @@ module Playwright
362
382
  wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
363
383
  end
364
384
 
365
- # Returns the buffer with the captured screenshot.
385
+ # This method captures a screenshot of the page, clipped to the size and position of a particular element matching the
386
+ # locator. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element
387
+ # is a scrollable container, only the currently scrolled content will be visible on the screenshot.
366
388
  #
367
389
  # This method waits for the [actionability](../actionability.md) checks, then scrolls element into view before taking a
368
390
  # screenshot. If the element is detached from DOM, the method throws an error.
391
+ #
392
+ # Returns the buffer with the captured screenshot.
369
393
  def screenshot(
370
394
  animations: nil,
371
395
  caret: nil,
@@ -405,17 +429,6 @@ module Playwright
405
429
  # # multiple selection
406
430
  # element.select_option(value=["red", "green", "blue"])
407
431
  # ```
408
- #
409
- # ```python sync
410
- # # single selection matching the value
411
- # element.select_option("blue")
412
- # # single selection matching both the value and the label
413
- # element.select_option(label="blue")
414
- # # multiple selection
415
- # element.select_option("red", "green", "blue")
416
- # # multiple selection for blue, red and second option
417
- # element.select_option(value="blue", { index: 2 }, "red")
418
- # ```
419
432
  def select_option(
420
433
  element: nil,
421
434
  index: nil,
@@ -429,6 +442,10 @@ module Playwright
429
442
 
430
443
  # This method waits for [actionability](../actionability.md) checks, then focuses the element and selects all its text
431
444
  # content.
445
+ #
446
+ # If the element is inside the `<label>` element that has an associated
447
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the
448
+ # control instead.
432
449
  def select_text(force: nil, timeout: nil)
433
450
  wrap_impl(@impl.select_text(force: unwrap_impl(force), timeout: unwrap_impl(timeout)))
434
451
  end
@@ -456,11 +473,13 @@ module Playwright
456
473
  end
457
474
  alias_method :checked=, :set_checked
458
475
 
459
- # This method expects `element` to point to an
460
- # [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
461
- #
462
476
  # Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
463
- # are resolved relative to the the current working directory. For empty array, clears the selected files.
477
+ # are resolved relative to the current working directory. For empty array, clears the selected files.
478
+ #
479
+ # This method expects `Locator` to point to an
480
+ # [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the
481
+ # `<label>` element that has an associated
482
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
464
483
  def set_input_files(files, noWaitAfter: nil, timeout: nil)
465
484
  wrap_impl(@impl.set_input_files(unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
466
485
  end
@@ -583,8 +583,8 @@ module Playwright
583
583
  wrap_impl(@impl.go_forward(timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
584
584
  end
585
585
 
586
- # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
587
- # last redirect.
586
+ # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the first
587
+ # non-redirect response.
588
588
  #
589
589
  # The method will throw an error if:
590
590
  # - there's an SSL error (e.g. in case of self-signed certificates).
@@ -640,7 +640,10 @@ module Playwright
640
640
  wrap_impl(@impl.inner_text(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
641
641
  end
642
642
 
643
- # Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
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.
644
647
  def input_value(selector, strict: nil, timeout: nil)
645
648
  wrap_impl(@impl.input_value(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
646
649
  end
@@ -686,6 +689,8 @@ module Playwright
686
689
  # element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
687
690
  # different DOM elements. That would happen if the DOM structure between those actions has changed.
688
691
  #
692
+ # [Learn more about locators](../locators.md).
693
+ #
689
694
  # Shortcut for main frame's [`method: Frame.locator`].
690
695
  def locator(selector, has: nil, hasText: nil)
691
696
  wrap_impl(@impl.locator(unwrap_impl(selector), has: unwrap_impl(has), hasText: unwrap_impl(hasText)))
@@ -848,7 +853,7 @@ module Playwright
848
853
  # > NOTE: The handler will only be called for the first url if the response is a redirect.
849
854
  # > NOTE: [`method: Page.route`] will not intercept requests intercepted by Service Worker. See
850
855
  # [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
851
- # request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);`
856
+ # request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
852
857
  #
853
858
  # An example of a naive handler that aborts all image requests:
854
859
  #
@@ -890,6 +895,16 @@ module Playwright
890
895
  wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler), times: unwrap_impl(times)))
891
896
  end
892
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
+
893
908
  # Returns the buffer with the captured screenshot.
894
909
  def screenshot(
895
910
  animations: nil,
@@ -1004,11 +1019,13 @@ module Playwright
1004
1019
  end
1005
1020
  alias_method :extra_http_headers=, :set_extra_http_headers
1006
1021
 
1007
- # This method expects `selector` to point to an
1008
- # [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
1009
- #
1010
1022
  # Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
1011
- # are resolved relative to the the current working directory. For empty array, clears the selected files.
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.
1012
1029
  def set_input_files(
1013
1030
  selector,
1014
1031
  files,
@@ -1397,6 +1414,11 @@ module Playwright
1397
1414
  wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1398
1415
  end
1399
1416
 
1417
+ # @nodoc
1418
+ def guid
1419
+ wrap_impl(@impl.guid)
1420
+ end
1421
+
1400
1422
  # @nodoc
1401
1423
  def stop_js_coverage
1402
1424
  wrap_impl(@impl.stop_js_coverage)
@@ -1412,9 +1434,10 @@ module Playwright
1412
1434
  wrap_impl(@impl.stop_css_coverage)
1413
1435
  end
1414
1436
 
1437
+ # -- inherited from EventEmitter --
1415
1438
  # @nodoc
1416
- def guid
1417
- wrap_impl(@impl.guid)
1439
+ def off(event, callback)
1440
+ event_emitter_proxy.off(event, callback)
1418
1441
  end
1419
1442
 
1420
1443
  # -- inherited from EventEmitter --
@@ -1429,12 +1452,6 @@ module Playwright
1429
1452
  event_emitter_proxy.on(event, callback)
1430
1453
  end
1431
1454
 
1432
- # -- inherited from EventEmitter --
1433
- # @nodoc
1434
- def off(event, callback)
1435
- event_emitter_proxy.off(event, callback)
1436
- end
1437
-
1438
1455
  private def event_emitter_proxy
1439
1456
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
1440
1457
  end
@@ -86,14 +86,20 @@ module Playwright
86
86
  raise NotImplementedError.new('stop is not implemented yet.')
87
87
  end
88
88
 
89
+ # @nodoc
90
+ def android
91
+ wrap_impl(@impl.android)
92
+ end
93
+
89
94
  # @nodoc
90
95
  def electron
91
96
  wrap_impl(@impl.electron)
92
97
  end
93
98
 
99
+ # -- inherited from EventEmitter --
94
100
  # @nodoc
95
- def android
96
- wrap_impl(@impl.android)
101
+ def off(event, callback)
102
+ event_emitter_proxy.off(event, callback)
97
103
  end
98
104
 
99
105
  # -- inherited from EventEmitter --
@@ -108,12 +114,6 @@ module Playwright
108
114
  event_emitter_proxy.on(event, callback)
109
115
  end
110
116
 
111
- # -- inherited from EventEmitter --
112
- # @nodoc
113
- def off(event, callback)
114
- event_emitter_proxy.off(event, callback)
115
- end
116
-
117
117
  private def event_emitter_proxy
118
118
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
119
119
  end
@@ -35,7 +35,9 @@ module Playwright
35
35
  wrap_impl(@impl.frame)
36
36
  end
37
37
 
38
- # **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [`method: Request.allHeaders`] instead.
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)))
@@ -156,20 +163,20 @@ module Playwright
156
163
 
157
164
  # -- inherited from EventEmitter --
158
165
  # @nodoc
159
- def once(event, callback)
160
- event_emitter_proxy.once(event, callback)
166
+ def off(event, callback)
167
+ event_emitter_proxy.off(event, callback)
161
168
  end
162
169
 
163
170
  # -- inherited from EventEmitter --
164
171
  # @nodoc
165
- def on(event, callback)
166
- event_emitter_proxy.on(event, callback)
172
+ def once(event, callback)
173
+ event_emitter_proxy.once(event, callback)
167
174
  end
168
175
 
169
176
  # -- inherited from EventEmitter --
170
177
  # @nodoc
171
- def off(event, callback)
172
- event_emitter_proxy.off(event, callback)
178
+ def on(event, callback)
179
+ event_emitter_proxy.on(event, callback)
173
180
  end
174
181
 
175
182
  private def event_emitter_proxy
@@ -22,7 +22,15 @@ module Playwright
22
22
  wrap_impl(@impl.frame)
23
23
  end
24
24
 
25
- # **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [`method: Response.allHeaders`] instead.
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?)
@@ -99,20 +112,20 @@ module Playwright
99
112
 
100
113
  # -- inherited from EventEmitter --
101
114
  # @nodoc
102
- def once(event, callback)
103
- event_emitter_proxy.once(event, callback)
115
+ def off(event, callback)
116
+ event_emitter_proxy.off(event, callback)
104
117
  end
105
118
 
106
119
  # -- inherited from EventEmitter --
107
120
  # @nodoc
108
- def on(event, callback)
109
- event_emitter_proxy.on(event, callback)
121
+ def once(event, callback)
122
+ event_emitter_proxy.once(event, callback)
110
123
  end
111
124
 
112
125
  # -- inherited from EventEmitter --
113
126
  # @nodoc
114
- def off(event, callback)
115
- event_emitter_proxy.off(event, callback)
127
+ def on(event, callback)
128
+ event_emitter_proxy.on(event, callback)
116
129
  end
117
130
 
118
131
  private def event_emitter_proxy
@@ -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": "bar" # set "foo" header
19
- # "origin": None # remove "origin" header
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 previous 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,22 +113,27 @@ 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
- def once(event, callback)
63
- event_emitter_proxy.once(event, callback)
123
+ def off(event, callback)
124
+ event_emitter_proxy.off(event, callback)
64
125
  end
65
126
 
66
127
  # -- inherited from EventEmitter --
67
128
  # @nodoc
68
- def on(event, callback)
69
- event_emitter_proxy.on(event, callback)
129
+ def once(event, callback)
130
+ event_emitter_proxy.once(event, callback)
70
131
  end
71
132
 
72
133
  # -- inherited from EventEmitter --
73
134
  # @nodoc
74
- def off(event, callback)
75
- event_emitter_proxy.off(event, callback)
135
+ def on(event, callback)
136
+ event_emitter_proxy.on(event, callback)
76
137
  end
77
138
 
78
139
  private def event_emitter_proxy
@@ -30,7 +30,7 @@ module Playwright
30
30
  # # Use the selector prefixed with its name.
31
31
  # button = page.locator('tag=button')
32
32
  # # Combine it with other selector engines.
33
- # page.click('tag=div >> text="Click me"')
33
+ # page.locator('tag=div >> text="Click me"').click()
34
34
  # # Can use it in any methods supporting selectors.
35
35
  # button_count = page.locator('tag=button').count()
36
36
  # print(button_count)
@@ -45,20 +45,20 @@ module Playwright
45
45
 
46
46
  # -- inherited from EventEmitter --
47
47
  # @nodoc
48
- def once(event, callback)
49
- event_emitter_proxy.once(event, callback)
48
+ def off(event, callback)
49
+ event_emitter_proxy.off(event, callback)
50
50
  end
51
51
 
52
52
  # -- inherited from EventEmitter --
53
53
  # @nodoc
54
- def on(event, callback)
55
- event_emitter_proxy.on(event, callback)
54
+ def once(event, callback)
55
+ event_emitter_proxy.once(event, callback)
56
56
  end
57
57
 
58
58
  # -- inherited from EventEmitter --
59
59
  # @nodoc
60
- def off(event, callback)
61
- event_emitter_proxy.off(event, callback)
60
+ def on(event, callback)
61
+ event_emitter_proxy.on(event, callback)
62
62
  end
63
63
 
64
64
  private def event_emitter_proxy
@@ -41,7 +41,7 @@ module Playwright
41
41
  # page.goto("https://playwright.dev")
42
42
  #
43
43
  # context.tracing.start_chunk()
44
- # page.click("text=Get Started")
44
+ # page.locator("text=Get Started").click()
45
45
  # # Everything between start_chunk and stop_chunk will be recorded in the trace.
46
46
  # context.tracing.stop_chunk(path = "trace1.zip")
47
47
  #
@@ -66,20 +66,20 @@ module Playwright
66
66
 
67
67
  # -- inherited from EventEmitter --
68
68
  # @nodoc
69
- def once(event, callback)
70
- event_emitter_proxy.once(event, callback)
69
+ def off(event, callback)
70
+ event_emitter_proxy.off(event, callback)
71
71
  end
72
72
 
73
73
  # -- inherited from EventEmitter --
74
74
  # @nodoc
75
- def on(event, callback)
76
- event_emitter_proxy.on(event, callback)
75
+ def once(event, callback)
76
+ event_emitter_proxy.once(event, callback)
77
77
  end
78
78
 
79
79
  # -- inherited from EventEmitter --
80
80
  # @nodoc
81
- def off(event, callback)
82
- event_emitter_proxy.off(event, callback)
81
+ def on(event, callback)
82
+ event_emitter_proxy.on(event, callback)
83
83
  end
84
84
 
85
85
  private def event_emitter_proxy
@@ -29,20 +29,20 @@ module Playwright
29
29
 
30
30
  # -- inherited from EventEmitter --
31
31
  # @nodoc
32
- def once(event, callback)
33
- event_emitter_proxy.once(event, callback)
32
+ def off(event, callback)
33
+ event_emitter_proxy.off(event, callback)
34
34
  end
35
35
 
36
36
  # -- inherited from EventEmitter --
37
37
  # @nodoc
38
- def on(event, callback)
39
- event_emitter_proxy.on(event, callback)
38
+ def once(event, callback)
39
+ event_emitter_proxy.once(event, callback)
40
40
  end
41
41
 
42
42
  # -- inherited from EventEmitter --
43
43
  # @nodoc
44
- def off(event, callback)
45
- event_emitter_proxy.off(event, callback)
44
+ def on(event, callback)
45
+ event_emitter_proxy.on(event, callback)
46
46
  end
47
47
 
48
48
  private def event_emitter_proxy
@@ -43,14 +43,20 @@ module Playwright
43
43
  wrap_impl(@impl.url)
44
44
  end
45
45
 
46
+ # @nodoc
47
+ def context=(req)
48
+ wrap_impl(@impl.context=(unwrap_impl(req)))
49
+ end
50
+
46
51
  # @nodoc
47
52
  def page=(req)
48
53
  wrap_impl(@impl.page=(unwrap_impl(req)))
49
54
  end
50
55
 
56
+ # -- inherited from EventEmitter --
51
57
  # @nodoc
52
- def context=(req)
53
- wrap_impl(@impl.context=(unwrap_impl(req)))
58
+ def off(event, callback)
59
+ event_emitter_proxy.off(event, callback)
54
60
  end
55
61
 
56
62
  # -- inherited from EventEmitter --
@@ -65,12 +71,6 @@ module Playwright
65
71
  event_emitter_proxy.on(event, callback)
66
72
  end
67
73
 
68
- # -- inherited from EventEmitter --
69
- # @nodoc
70
- def off(event, callback)
71
- event_emitter_proxy.off(event, callback)
72
- end
73
-
74
74
  private def event_emitter_proxy
75
75
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
76
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playwright-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.0
4
+ version: 1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-30 00:00:00.000000000 Z
11
+ date: 2022-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -316,12 +316,15 @@ files:
316
316
  - lib/playwright/events.rb
317
317
  - lib/playwright/file_chooser_impl.rb
318
318
  - lib/playwright/frame_locator_impl.rb
319
+ - lib/playwright/har_router.rb
319
320
  - lib/playwright/http_headers.rb
320
321
  - lib/playwright/input_files.rb
321
322
  - lib/playwright/javascript.rb
322
323
  - lib/playwright/javascript/expression.rb
324
+ - lib/playwright/javascript/regex.rb
323
325
  - lib/playwright/javascript/value_parser.rb
324
326
  - lib/playwright/javascript/value_serializer.rb
327
+ - lib/playwright/javascript/visitor_info.rb
325
328
  - lib/playwright/keyboard_impl.rb
326
329
  - lib/playwright/locator_impl.rb
327
330
  - lib/playwright/mouse_impl.rb
@@ -361,7 +364,6 @@ files:
361
364
  - lib/playwright_api/frame_locator.rb
362
365
  - lib/playwright_api/js_handle.rb
363
366
  - lib/playwright_api/keyboard.rb
364
- - lib/playwright_api/local_utils.rb
365
367
  - lib/playwright_api/locator.rb
366
368
  - lib/playwright_api/mouse.rb
367
369
  - lib/playwright_api/page.rb
@@ -397,5 +399,5 @@ requirements: []
397
399
  rubygems_version: 3.3.7
398
400
  signing_key:
399
401
  specification_version: 4
400
- summary: The Ruby binding of playwright driver 1.21.1
402
+ summary: The Ruby binding of playwright driver 1.24.2
401
403
  test_files: []