playwright-ruby-client 1.28.1 → 1.29.1.alpha1

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/accessibility.md +9 -14
  3. data/documentation/docs/api/api_request_context.md +44 -41
  4. data/documentation/docs/api/api_response.md +13 -3
  5. data/documentation/docs/api/browser.md +24 -23
  6. data/documentation/docs/api/browser_context.md +71 -45
  7. data/documentation/docs/api/browser_type.md +21 -14
  8. data/documentation/docs/api/cdp_session.md +3 -5
  9. data/documentation/docs/api/console_message.md +7 -4
  10. data/documentation/docs/api/dialog.md +9 -5
  11. data/documentation/docs/api/download.md +19 -11
  12. data/documentation/docs/api/element_handle.md +125 -116
  13. data/documentation/docs/api/experimental/android.md +4 -5
  14. data/documentation/docs/api/experimental/android_device.md +11 -2
  15. data/documentation/docs/api/experimental/android_input.md +5 -0
  16. data/documentation/docs/api/file_chooser.md +6 -3
  17. data/documentation/docs/api/frame.md +182 -171
  18. data/documentation/docs/api/frame_locator.md +27 -38
  19. data/documentation/docs/api/js_handle.md +16 -10
  20. data/documentation/docs/api/keyboard.md +29 -16
  21. data/documentation/docs/api/locator.md +189 -140
  22. data/documentation/docs/api/mouse.md +9 -4
  23. data/documentation/docs/api/page.md +304 -289
  24. data/documentation/docs/api/playwright.md +8 -5
  25. data/documentation/docs/api/request.md +34 -15
  26. data/documentation/docs/api/response.md +27 -10
  27. data/documentation/docs/api/route.md +44 -12
  28. data/documentation/docs/api/selectors.md +5 -3
  29. data/documentation/docs/api/touchscreen.md +2 -0
  30. data/documentation/docs/api/tracing.md +11 -11
  31. data/documentation/docs/api/web_socket.md +9 -4
  32. data/documentation/docs/api/worker.md +12 -11
  33. data/documentation/docs/include/api_coverage.md +2 -0
  34. data/lib/playwright/channel_owners/api_request_context.rb +37 -2
  35. data/lib/playwright/channel_owners/browser_context.rb +22 -26
  36. data/lib/playwright/channel_owners/page.rb +35 -25
  37. data/lib/playwright/channel_owners/route.rb +28 -8
  38. data/lib/playwright/event_emitter.rb +6 -1
  39. data/lib/playwright/locator_impl.rb +8 -0
  40. data/lib/playwright/select_option_values.rb +2 -0
  41. data/lib/playwright/version.rb +2 -2
  42. data/lib/playwright_api/accessibility.rb +9 -13
  43. data/lib/playwright_api/android.rb +14 -12
  44. data/lib/playwright_api/android_device.rb +38 -13
  45. data/lib/playwright_api/android_input.rb +5 -0
  46. data/lib/playwright_api/android_socket.rb +4 -2
  47. data/lib/playwright_api/android_web_view.rb +5 -2
  48. data/lib/playwright_api/api_request.rb +6 -3
  49. data/lib/playwright_api/api_request_context.rb +52 -42
  50. data/lib/playwright_api/api_response.rb +13 -2
  51. data/lib/playwright_api/browser.rb +30 -22
  52. data/lib/playwright_api/browser_context.rb +82 -45
  53. data/lib/playwright_api/browser_type.rb +29 -19
  54. data/lib/playwright_api/cdp_session.rb +9 -10
  55. data/lib/playwright_api/console_message.rb +13 -8
  56. data/lib/playwright_api/dialog.rb +14 -10
  57. data/lib/playwright_api/download.rb +19 -9
  58. data/lib/playwright_api/element_handle.rb +122 -99
  59. data/lib/playwright_api/file_chooser.rb +6 -1
  60. data/lib/playwright_api/frame.rb +186 -141
  61. data/lib/playwright_api/frame_locator.rb +29 -32
  62. data/lib/playwright_api/js_handle.rb +22 -12
  63. data/lib/playwright_api/keyboard.rb +29 -14
  64. data/lib/playwright_api/locator.rb +183 -112
  65. data/lib/playwright_api/mouse.rb +9 -2
  66. data/lib/playwright_api/page.rb +307 -259
  67. data/lib/playwright_api/playwright.rb +17 -10
  68. data/lib/playwright_api/request.rb +40 -13
  69. data/lib/playwright_api/response.rb +33 -16
  70. data/lib/playwright_api/route.rb +50 -17
  71. data/lib/playwright_api/selectors.rb +12 -7
  72. data/lib/playwright_api/touchscreen.rb +2 -0
  73. data/lib/playwright_api/tracing.rb +17 -11
  74. data/lib/playwright_api/web_socket.rb +15 -10
  75. data/lib/playwright_api/worker.rb +20 -17
  76. data/playwright.gemspec +2 -2
  77. data/sig/playwright.rbs +559 -0
  78. metadata +10 -9
@@ -1,4 +1,5 @@
1
1
  module Playwright
2
+ #
2
3
  # Playwright module provides a method to launch a browser instance. The following is a typical example of using Playwright
3
4
  # to drive automation:
4
5
  #
@@ -18,11 +19,13 @@ module Playwright
18
19
  # ```
19
20
  class Playwright < PlaywrightApi
20
21
 
22
+ #
21
23
  # This object can be used to launch or connect to Chromium, returning instances of `Browser`.
22
24
  def chromium # property
23
25
  wrap_impl(@impl.chromium)
24
26
  end
25
27
 
28
+ #
26
29
  # Returns a dictionary of devices to be used with [`method: Browser.newContext`] or [`method: Browser.newPage`].
27
30
  #
28
31
  # ```python sync
@@ -45,29 +48,33 @@ module Playwright
45
48
  wrap_impl(@impl.devices)
46
49
  end
47
50
 
51
+ #
48
52
  # This object can be used to launch or connect to Firefox, returning instances of `Browser`.
49
53
  def firefox # property
50
54
  wrap_impl(@impl.firefox)
51
55
  end
52
56
 
57
+ #
53
58
  # Exposes API that can be used for the Web API testing.
54
59
  def request # property
55
60
  raise NotImplementedError.new('request is not implemented yet.')
56
61
  end
57
62
 
58
- # Selectors can be used to install custom selector engines. See [Working with selectors](../selectors.md) for more
59
- # information.
63
+ #
64
+ # Selectors can be used to install custom selector engines. See
65
+ # [extensibility](../extensibility.md) for more information.
60
66
  def selectors # property
61
67
  wrap_impl(@impl.selectors)
62
68
  end
63
69
 
70
+ #
64
71
  # This object can be used to launch or connect to WebKit, returning instances of `Browser`.
65
72
  def webkit # property
66
73
  wrap_impl(@impl.webkit)
67
74
  end
68
75
 
69
- # Terminates this instance of Playwright in case it was created bypassing the Python context manager. This is useful in
70
- # REPL applications.
76
+ #
77
+ # Terminates this instance of Playwright in case it was created bypassing the Python context manager. This is useful in REPL applications.
71
78
  #
72
79
  # ```py
73
80
  # >>> from playwright.sync_api import sync_playwright
@@ -98,20 +105,20 @@ module Playwright
98
105
 
99
106
  # -- inherited from EventEmitter --
100
107
  # @nodoc
101
- def once(event, callback)
102
- event_emitter_proxy.once(event, callback)
108
+ def off(event, callback)
109
+ event_emitter_proxy.off(event, callback)
103
110
  end
104
111
 
105
112
  # -- inherited from EventEmitter --
106
113
  # @nodoc
107
- def on(event, callback)
108
- event_emitter_proxy.on(event, callback)
114
+ def once(event, callback)
115
+ event_emitter_proxy.once(event, callback)
109
116
  end
110
117
 
111
118
  # -- inherited from EventEmitter --
112
119
  # @nodoc
113
- def off(event, callback)
114
- event_emitter_proxy.off(event, callback)
120
+ def on(event, callback)
121
+ event_emitter_proxy.on(event, callback)
115
122
  end
116
123
 
117
124
  private def event_emitter_proxy
@@ -1,4 +1,5 @@
1
1
  module Playwright
2
+ #
2
3
  # Whenever the page sends a request for a network resource the following sequence of events are emitted by `Page`:
3
4
  # - [`event: Page.request`] emitted when the request is issued by the page.
4
5
  # - [`event: Page.response`] emitted when/if the response status and headers are received for the request.
@@ -7,20 +8,24 @@ module Playwright
7
8
  # If request fails at some point, then instead of `'requestfinished'` event (and possibly instead of 'response' event),
8
9
  # the [`event: Page.requestFailed`] event is emitted.
9
10
  #
10
- # > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
11
- # complete with `'requestfinished'` event.
11
+ # **NOTE**: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete
12
+ # with `'requestfinished'` event.
12
13
  #
13
14
  # If request gets a 'redirect' response, the request is successfully finished with the `requestfinished` event, and a new
14
15
  # request is issued to a redirected url.
15
16
  class Request < PlaywrightApi
16
17
 
18
+ #
17
19
  # An object with all the request HTTP headers associated with this request. The header names are lower-cased.
18
20
  def all_headers
19
21
  wrap_impl(@impl.all_headers)
20
22
  end
21
23
 
24
+ #
22
25
  # The method returns `null` unless this request has failed, as reported by `requestfailed` event.
23
26
  #
27
+ # **Usage**
28
+ #
24
29
  # Example of logging of all the failed requests:
25
30
  #
26
31
  # ```py
@@ -30,49 +35,58 @@ module Playwright
30
35
  wrap_impl(@impl.failure)
31
36
  end
32
37
 
38
+ #
33
39
  # Returns the `Frame` that initiated this request.
34
40
  def frame
35
41
  wrap_impl(@impl.frame)
36
42
  end
37
43
 
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.
44
+ #
45
+ # An object with the request HTTP headers. The header names are lower-cased.
46
+ # Note that this method does not return security-related headers, including cookie-related ones.
47
+ # You can use [`method: Request.allHeaders`] for complete list of headers that include `cookie` information.
41
48
  def headers
42
49
  wrap_impl(@impl.headers)
43
50
  end
44
51
 
45
- # An array with all the request HTTP headers associated with this request. Unlike [`method: Request.allHeaders`], header
46
- # names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
52
+ #
53
+ # An array with all the request HTTP headers associated with this request. Unlike [`method: Request.allHeaders`], header names are NOT lower-cased.
54
+ # Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
47
55
  def headers_array
48
56
  wrap_impl(@impl.headers_array)
49
57
  end
50
58
 
59
+ #
51
60
  # Returns the value of the header matching the name. The name is case insensitive.
52
61
  def header_value(name)
53
62
  wrap_impl(@impl.header_value(unwrap_impl(name)))
54
63
  end
55
64
 
65
+ #
56
66
  # Whether this request is driving frame's navigation.
57
67
  def navigation_request?
58
68
  wrap_impl(@impl.navigation_request?)
59
69
  end
60
70
 
71
+ #
61
72
  # Request's method (GET, POST, etc.)
62
73
  def method
63
74
  wrap_impl(@impl.method)
64
75
  end
65
76
 
77
+ #
66
78
  # Request's post body, if any.
67
79
  def post_data
68
80
  wrap_impl(@impl.post_data)
69
81
  end
70
82
 
83
+ #
71
84
  # Request's post body in a binary form, if any.
72
85
  def post_data_buffer
73
86
  wrap_impl(@impl.post_data_buffer)
74
87
  end
75
88
 
89
+ #
76
90
  # Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any.
77
91
  #
78
92
  # When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned.
@@ -81,12 +95,15 @@ module Playwright
81
95
  wrap_impl(@impl.post_data_json)
82
96
  end
83
97
 
98
+ #
84
99
  # Request that was redirected by the server to this one, if any.
85
100
  #
86
101
  # When the server responds with a redirect, Playwright creates a new `Request` object. The two requests are connected by
87
102
  # `redirectedFrom()` and `redirectedTo()` methods. When multiple server redirects has happened, it is possible to
88
103
  # construct the whole redirect chain by repeatedly calling `redirectedFrom()`.
89
104
  #
105
+ # **Usage**
106
+ #
90
107
  # For example, if the website `http://example.com` redirects to `https://example.com`:
91
108
  #
92
109
  # ```python sync
@@ -104,8 +121,11 @@ module Playwright
104
121
  wrap_impl(@impl.redirected_from)
105
122
  end
106
123
 
124
+ #
107
125
  # New request issued by the browser if the server responded with redirect.
108
126
  #
127
+ # **Usage**
128
+ #
109
129
  # This method is the opposite of [`method: Request.redirectedFrom`]:
110
130
  #
111
131
  # ```py
@@ -115,6 +135,7 @@ module Playwright
115
135
  wrap_impl(@impl.redirected_to)
116
136
  end
117
137
 
138
+ #
118
139
  # Contains the request's resource type as it was perceived by the rendering engine. ResourceType will be one of the
119
140
  # following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`,
120
141
  # `websocket`, `manifest`, `other`.
@@ -122,20 +143,25 @@ module Playwright
122
143
  wrap_impl(@impl.resource_type)
123
144
  end
124
145
 
146
+ #
125
147
  # Returns the matching `Response` object, or `null` if the response was not received due to error.
126
148
  def response
127
149
  wrap_impl(@impl.response)
128
150
  end
129
151
 
152
+ #
130
153
  # Returns resource size information for given request.
131
154
  def sizes
132
155
  wrap_impl(@impl.sizes)
133
156
  end
134
157
 
158
+ #
135
159
  # Returns resource timing information for given request. Most of the timing values become available upon the response,
136
160
  # `responseEnd` becomes available when request finishes. Find more information at
137
161
  # [Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).
138
162
  #
163
+ # **Usage**
164
+ #
139
165
  # ```python sync
140
166
  # with page.expect_event("requestfinished") as request_info:
141
167
  # page.goto("http://example.com")
@@ -146,6 +172,7 @@ module Playwright
146
172
  wrap_impl(@impl.timing)
147
173
  end
148
174
 
175
+ #
149
176
  # URL of the request.
150
177
  def url
151
178
  wrap_impl(@impl.url)
@@ -163,20 +190,20 @@ module Playwright
163
190
 
164
191
  # -- inherited from EventEmitter --
165
192
  # @nodoc
166
- def once(event, callback)
167
- event_emitter_proxy.once(event, callback)
193
+ def off(event, callback)
194
+ event_emitter_proxy.off(event, callback)
168
195
  end
169
196
 
170
197
  # -- inherited from EventEmitter --
171
198
  # @nodoc
172
- def on(event, callback)
173
- event_emitter_proxy.on(event, callback)
199
+ def once(event, callback)
200
+ event_emitter_proxy.once(event, callback)
174
201
  end
175
202
 
176
203
  # -- inherited from EventEmitter --
177
204
  # @nodoc
178
- def off(event, callback)
179
- event_emitter_proxy.off(event, callback)
205
+ def on(event, callback)
206
+ event_emitter_proxy.on(event, callback)
180
207
  end
181
208
 
182
209
  private def event_emitter_proxy
@@ -1,58 +1,67 @@
1
1
  module Playwright
2
+ #
2
3
  # `Response` class represents responses which are received by page.
3
4
  class Response < PlaywrightApi
4
5
 
6
+ #
5
7
  # An object with all the response HTTP headers associated with this response.
6
8
  def all_headers
7
9
  wrap_impl(@impl.all_headers)
8
10
  end
9
11
 
12
+ #
10
13
  # Returns the buffer with response body.
11
14
  def body
12
15
  wrap_impl(@impl.body)
13
16
  end
14
17
 
18
+ #
15
19
  # Waits for this response to finish, returns always `null`.
16
20
  def finished
17
21
  wrap_impl(@impl.finished)
18
22
  end
19
23
 
24
+ #
20
25
  # Returns the `Frame` that initiated this response.
21
26
  def frame
22
27
  wrap_impl(@impl.frame)
23
28
  end
24
29
 
25
- # Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via
26
- # [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).
30
+ #
31
+ # Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).
27
32
  def from_service_worker
28
33
  wrap_impl(@impl.from_service_worker)
29
34
  end
30
35
 
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.
36
+ #
37
+ # An object with the response HTTP headers. The header names are lower-cased.
38
+ # Note that this method does not return security-related headers, including cookie-related ones.
39
+ # You can use [`method: Response.allHeaders`] for complete list of headers that include `cookie` information.
34
40
  def headers
35
41
  wrap_impl(@impl.headers)
36
42
  end
37
43
 
38
- # An array with all the request HTTP headers associated with this response. Unlike [`method: Response.allHeaders`], header
39
- # names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
44
+ #
45
+ # An array with all the request HTTP headers associated with this response. Unlike [`method: Response.allHeaders`], header names are NOT lower-cased.
46
+ # Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
40
47
  def headers_array
41
48
  wrap_impl(@impl.headers_array)
42
49
  end
43
50
 
44
- # Returns the value of the header matching the name. The name is case insensitive. If multiple headers have the same name
45
- # (except `set-cookie`), they are returned as a list separated by `, `. For `set-cookie`, the `\n` separator is used. If
46
- # no headers are found, `null` is returned.
51
+ #
52
+ # Returns the value of the header matching the name. The name is case insensitive. If multiple headers have
53
+ # the same name (except `set-cookie`), they are returned as a list separated by `, `. For `set-cookie`, the `\n` separator is used. If no headers are found, `null` is returned.
47
54
  def header_value(name)
48
55
  wrap_impl(@impl.header_value(unwrap_impl(name)))
49
56
  end
50
57
 
58
+ #
51
59
  # Returns all values of the headers matching the name, for example `set-cookie`. The name is case insensitive.
52
60
  def header_values(name)
53
61
  wrap_impl(@impl.header_values(unwrap_impl(name)))
54
62
  end
55
63
 
64
+ #
56
65
  # Returns the JSON representation of response body.
57
66
  #
58
67
  # This method will throw if the response body is not parsable via `JSON.parse`.
@@ -60,41 +69,49 @@ module Playwright
60
69
  wrap_impl(@impl.json)
61
70
  end
62
71
 
72
+ #
63
73
  # Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
64
74
  def ok
65
75
  wrap_impl(@impl.ok)
66
76
  end
67
77
 
78
+ #
68
79
  # Returns the matching `Request` object.
69
80
  def request
70
81
  wrap_impl(@impl.request)
71
82
  end
72
83
 
84
+ #
73
85
  # Returns SSL and other security information.
74
86
  def security_details
75
87
  wrap_impl(@impl.security_details)
76
88
  end
77
89
 
90
+ #
78
91
  # Returns the IP address and port of the server.
79
92
  def server_addr
80
93
  wrap_impl(@impl.server_addr)
81
94
  end
82
95
 
96
+ #
83
97
  # Contains the status code of the response (e.g., 200 for a success).
84
98
  def status
85
99
  wrap_impl(@impl.status)
86
100
  end
87
101
 
102
+ #
88
103
  # Contains the status text of the response (e.g. usually an "OK" for a success).
89
104
  def status_text
90
105
  wrap_impl(@impl.status_text)
91
106
  end
92
107
 
108
+ #
93
109
  # Returns the text representation of response body.
94
110
  def text
95
111
  wrap_impl(@impl.text)
96
112
  end
97
113
 
114
+ #
98
115
  # Contains the URL of the response.
99
116
  def url
100
117
  wrap_impl(@impl.url)
@@ -112,20 +129,20 @@ module Playwright
112
129
 
113
130
  # -- inherited from EventEmitter --
114
131
  # @nodoc
115
- def once(event, callback)
116
- event_emitter_proxy.once(event, callback)
132
+ def off(event, callback)
133
+ event_emitter_proxy.off(event, callback)
117
134
  end
118
135
 
119
136
  # -- inherited from EventEmitter --
120
137
  # @nodoc
121
- def on(event, callback)
122
- event_emitter_proxy.on(event, callback)
138
+ def once(event, callback)
139
+ event_emitter_proxy.once(event, callback)
123
140
  end
124
141
 
125
142
  # -- inherited from EventEmitter --
126
143
  # @nodoc
127
- def off(event, callback)
128
- event_emitter_proxy.off(event, callback)
144
+ def on(event, callback)
145
+ event_emitter_proxy.on(event, callback)
129
146
  end
130
147
 
131
148
  private def event_emitter_proxy
@@ -1,17 +1,22 @@
1
1
  module Playwright
2
+ #
2
3
  # Whenever a network route is set up with [`method: Page.route`] or [`method: BrowserContext.route`], the `Route` object
3
4
  # allows to handle the route.
4
5
  #
5
6
  # Learn more about [networking](../network.md).
6
7
  class Route < PlaywrightApi
7
8
 
9
+ #
8
10
  # Aborts the route's request.
9
11
  def abort(errorCode: nil)
10
12
  wrap_impl(@impl.abort(errorCode: unwrap_impl(errorCode)))
11
13
  end
12
14
 
15
+ #
13
16
  # Continues route's request with optional overrides.
14
17
  #
18
+ # **Usage**
19
+ #
15
20
  # ```python sync
16
21
  # def handle(route, request):
17
22
  # # override headers
@@ -21,17 +26,20 @@ module Playwright
21
26
  # "bar": None # remove "bar" header
22
27
  # }
23
28
  # route.continue_(headers=headers)
24
- # }
29
+ #
25
30
  # page.route("**/*", handle)
26
31
  # ```
27
32
  def continue(headers: nil, method: nil, postData: nil, url: nil)
28
33
  wrap_impl(@impl.continue(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
29
34
  end
30
35
 
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.
36
+ #
37
+ # When several routes match the given pattern, they run in the order opposite to their registration.
38
+ # That way the last registered route can always override all the previous ones. In the example below,
39
+ # request will be handled by the bottom-most handler first, then it'll fall back to the previous one and
40
+ # in the end will be aborted by the first registered route.
41
+ #
42
+ # **Usage**
35
43
  #
36
44
  # ```python sync
37
45
  # page.route("**/*", lambda route: route.abort()) # Runs last.
@@ -39,8 +47,9 @@ module Playwright
39
47
  # page.route("**/*", lambda route: route.fallback()) # Runs first.
40
48
  # ```
41
49
  #
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.
50
+ # Registering multiple routes is useful when you want separate handlers to
51
+ # handle different kinds of requests, for example API calls vs page resources or
52
+ # GET requests vs POST requests as in the example below.
44
53
  #
45
54
  # ```python sync
46
55
  # # Handle GET requests.
@@ -63,8 +72,8 @@ module Playwright
63
72
  # page.route("**/*", handle_post)
64
73
  # ```
65
74
  #
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.
75
+ # One can also modify request while falling back to the subsequent handler, that way intermediate
76
+ # route handler can modify url, method, headers and postData of the request.
68
77
  #
69
78
  # ```python sync
70
79
  # def handle(route, request):
@@ -75,15 +84,37 @@ module Playwright
75
84
  # "bar": None # remove "bar" header
76
85
  # }
77
86
  # route.fallback(headers=headers)
78
- # }
87
+ #
79
88
  # page.route("**/*", handle)
80
89
  # ```
81
90
  def fallback(headers: nil, method: nil, postData: nil, url: nil)
82
91
  wrap_impl(@impl.fallback(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
83
92
  end
84
93
 
94
+ #
95
+ # Performs the request and fetches result without fulfilling it, so that the response
96
+ # could be modified and then fulfilled.
97
+ #
98
+ # **Usage**
99
+ #
100
+ # ```python sync
101
+ # def handle(route):
102
+ # response = route.fulfill()
103
+ # json = response.json()
104
+ # json["message"]["big_red_dog"] = []
105
+ # route.fulfill(response=response, json=json)
106
+ #
107
+ # page.route("https://dog.ceo/api/breeds/list/all", handle)
108
+ # ```
109
+ def fetch(headers: nil, method: nil, postData: nil, url: nil)
110
+ wrap_impl(@impl.fetch(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
111
+ end
112
+
113
+ #
85
114
  # Fulfills route's request with given response.
86
115
  #
116
+ # **Usage**
117
+ #
87
118
  # An example of fulfilling all requests with 404 responses:
88
119
  #
89
120
  # ```python sync
@@ -102,12 +133,14 @@ module Playwright
102
133
  body: nil,
103
134
  contentType: nil,
104
135
  headers: nil,
136
+ json: nil,
105
137
  path: nil,
106
138
  response: nil,
107
139
  status: nil)
108
- wrap_impl(@impl.fulfill(body: unwrap_impl(body), contentType: unwrap_impl(contentType), headers: unwrap_impl(headers), path: unwrap_impl(path), response: unwrap_impl(response), status: unwrap_impl(status)))
140
+ wrap_impl(@impl.fulfill(body: unwrap_impl(body), contentType: unwrap_impl(contentType), headers: unwrap_impl(headers), json: unwrap_impl(json), path: unwrap_impl(path), response: unwrap_impl(response), status: unwrap_impl(status)))
109
141
  end
110
142
 
143
+ #
111
144
  # A request to be routed.
112
145
  def request
113
146
  wrap_impl(@impl.request)
@@ -120,20 +153,20 @@ module Playwright
120
153
 
121
154
  # -- inherited from EventEmitter --
122
155
  # @nodoc
123
- def once(event, callback)
124
- event_emitter_proxy.once(event, callback)
156
+ def off(event, callback)
157
+ event_emitter_proxy.off(event, callback)
125
158
  end
126
159
 
127
160
  # -- inherited from EventEmitter --
128
161
  # @nodoc
129
- def on(event, callback)
130
- event_emitter_proxy.on(event, callback)
162
+ def once(event, callback)
163
+ event_emitter_proxy.once(event, callback)
131
164
  end
132
165
 
133
166
  # -- inherited from EventEmitter --
134
167
  # @nodoc
135
- def off(event, callback)
136
- event_emitter_proxy.off(event, callback)
168
+ def on(event, callback)
169
+ event_emitter_proxy.on(event, callback)
137
170
  end
138
171
 
139
172
  private def event_emitter_proxy
@@ -1,8 +1,12 @@
1
1
  module Playwright
2
- # Selectors can be used to install custom selector engines. See [Working with selectors](../selectors.md) for more
2
+ #
3
+ # Selectors can be used to install custom selector engines. See [extensibility](../extensibility.md) for more
3
4
  # information.
4
5
  class Selectors < PlaywrightApi
5
6
 
7
+ #
8
+ # **Usage**
9
+ #
6
10
  # An example of registering selector engine that queries elements based on a tag name:
7
11
  #
8
12
  # ```python sync
@@ -43,6 +47,7 @@ module Playwright
43
47
  wrap_impl(@impl.register(unwrap_impl(name), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path), script: unwrap_impl(script)))
44
48
  end
45
49
 
50
+ #
46
51
  # Defines custom attribute name to be used in [`method: Page.getByTestId`]. `data-testid` is used by default.
47
52
  def set_test_id_attribute(attributeName)
48
53
  raise NotImplementedError.new('set_test_id_attribute is not implemented yet.')
@@ -56,20 +61,20 @@ module Playwright
56
61
 
57
62
  # -- inherited from EventEmitter --
58
63
  # @nodoc
59
- def once(event, callback)
60
- event_emitter_proxy.once(event, callback)
64
+ def off(event, callback)
65
+ event_emitter_proxy.off(event, callback)
61
66
  end
62
67
 
63
68
  # -- inherited from EventEmitter --
64
69
  # @nodoc
65
- def on(event, callback)
66
- event_emitter_proxy.on(event, callback)
70
+ def once(event, callback)
71
+ event_emitter_proxy.once(event, callback)
67
72
  end
68
73
 
69
74
  # -- inherited from EventEmitter --
70
75
  # @nodoc
71
- def off(event, callback)
72
- event_emitter_proxy.off(event, callback)
76
+ def on(event, callback)
77
+ event_emitter_proxy.on(event, callback)
73
78
  end
74
79
 
75
80
  private def event_emitter_proxy
@@ -1,8 +1,10 @@
1
1
  module Playwright
2
+ #
2
3
  # The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the
3
4
  # touchscreen can only be used in browser contexts that have been initialized with `hasTouch` set to true.
4
5
  class Touchscreen < PlaywrightApi
5
6
 
7
+ #
6
8
  # Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`).
7
9
  def tap_point(x, y)
8
10
  wrap_impl(@impl.tap_point(unwrap_impl(x), unwrap_impl(y)))