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,45 +1,53 @@
1
1
  module Playwright
2
- # `AndroidDevice` represents a connected device, either real hardware or emulated. Devices can be obtained using
3
- # [`method: Android.devices`].
2
+ #
3
+ # `AndroidDevice` represents a connected device, either real hardware or emulated. Devices can be obtained using [`method: Android.devices`].
4
4
  class AndroidDevice < PlaywrightApi
5
5
 
6
6
  def input # property
7
7
  wrap_impl(@impl.input)
8
8
  end
9
9
 
10
+ #
10
11
  # Disconnects from the device.
11
12
  def close
12
13
  wrap_impl(@impl.close)
13
14
  end
14
15
 
16
+ #
15
17
  # Drags the widget defined by `selector` towards `dest` point.
16
18
  def drag(selector, dest, speed: nil)
17
19
  raise NotImplementedError.new('drag is not implemented yet.')
18
20
  end
19
21
 
22
+ #
20
23
  # Fills the specific `selector` input box with `text`.
21
24
  def fill(selector, text)
22
25
  raise NotImplementedError.new('fill is not implemented yet.')
23
26
  end
24
27
 
28
+ #
25
29
  # Flings the widget defined by `selector` in the specified `direction`.
26
30
  def fling(selector, direction, speed: nil)
27
31
  raise NotImplementedError.new('fling is not implemented yet.')
28
32
  end
29
33
 
34
+ #
30
35
  # Returns information about a widget defined by `selector`.
31
36
  def info(selector)
32
37
  wrap_impl(@impl.info(unwrap_impl(selector)))
33
38
  end
34
39
 
40
+ #
35
41
  # Installs an apk on the device.
36
42
  def install_apk(file, args: nil)
37
43
  raise NotImplementedError.new('install_apk is not implemented yet.')
38
44
  end
39
45
 
46
+ #
40
47
  # Launches Chrome browser on the device, and returns its persistent context.
41
48
  def launch_browser(
42
49
  acceptDownloads: nil,
50
+ args: nil,
43
51
  baseURL: nil,
44
52
  bypassCSP: nil,
45
53
  colorScheme: nil,
@@ -57,6 +65,7 @@ module Playwright
57
65
  noViewport: nil,
58
66
  offline: nil,
59
67
  permissions: nil,
68
+ proxy: nil,
60
69
  record_har_content: nil,
61
70
  record_har_mode: nil,
62
71
  record_har_omit_content: nil,
@@ -72,97 +81,113 @@ module Playwright
72
81
  userAgent: nil,
73
82
  viewport: nil,
74
83
  &block)
75
- wrap_impl(@impl.launch_browser(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), command: unwrap_impl(command), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), record_har_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
84
+ wrap_impl(@impl.launch_browser(acceptDownloads: unwrap_impl(acceptDownloads), args: unwrap_impl(args), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), command: unwrap_impl(command), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
76
85
  end
77
86
 
87
+ #
78
88
  # Performs a long tap on the widget defined by `selector`.
79
89
  def long_tap(selector)
80
90
  raise NotImplementedError.new('long_tap is not implemented yet.')
81
91
  end
82
92
 
93
+ #
83
94
  # Device model.
84
95
  def model
85
96
  wrap_impl(@impl.model)
86
97
  end
87
98
 
99
+ #
88
100
  # Launches a process in the shell on the device and returns a socket to communicate with the launched process.
89
101
  def open(command)
90
102
  raise NotImplementedError.new('open is not implemented yet.')
91
103
  end
92
104
 
105
+ #
93
106
  # Pinches the widget defined by `selector` in the closing direction.
94
107
  def pinch_close(selector, percent, speed: nil)
95
108
  raise NotImplementedError.new('pinch_close is not implemented yet.')
96
109
  end
97
110
 
111
+ #
98
112
  # Pinches the widget defined by `selector` in the open direction.
99
113
  def pinch_open(selector, percent, speed: nil)
100
114
  raise NotImplementedError.new('pinch_open is not implemented yet.')
101
115
  end
102
116
 
117
+ #
103
118
  # Presses the specific `key` in the widget defined by `selector`.
104
119
  def press(selector, key)
105
120
  raise NotImplementedError.new('press is not implemented yet.')
106
121
  end
107
122
 
123
+ #
108
124
  # Copies a file to the device.
109
125
  def push(file, path, mode: nil)
110
126
  raise NotImplementedError.new('push is not implemented yet.')
111
127
  end
112
128
 
129
+ #
113
130
  # Returns the buffer with the captured screenshot of the device.
114
131
  def screenshot(path: nil)
115
132
  wrap_impl(@impl.screenshot(path: unwrap_impl(path)))
116
133
  end
117
134
 
135
+ #
118
136
  # Scrolls the widget defined by `selector` in the specified `direction`.
119
137
  def scroll(selector, direction, percent, speed: nil)
120
138
  raise NotImplementedError.new('scroll is not implemented yet.')
121
139
  end
122
140
 
141
+ #
123
142
  # Device serial number.
124
143
  def serial
125
144
  wrap_impl(@impl.serial)
126
145
  end
127
146
 
147
+ #
128
148
  # This setting will change the default maximum time for all the methods accepting `timeout` option.
129
149
  def set_default_timeout(timeout)
130
150
  raise NotImplementedError.new('set_default_timeout is not implemented yet.')
131
151
  end
132
152
  alias_method :default_timeout=, :set_default_timeout
133
153
 
154
+ #
134
155
  # Executes a shell command on the device and returns its output.
135
156
  def shell(command)
136
157
  wrap_impl(@impl.shell(unwrap_impl(command)))
137
158
  end
138
159
 
160
+ #
139
161
  # Swipes the widget defined by `selector` in the specified `direction`.
140
162
  def swipe(selector, direction, percent, speed: nil)
141
163
  raise NotImplementedError.new('swipe is not implemented yet.')
142
164
  end
143
165
 
166
+ #
144
167
  # Taps on the widget defined by `selector`.
145
168
  def tap_point(selector, duration: nil)
146
169
  raise NotImplementedError.new('tap_point is not implemented yet.')
147
170
  end
148
171
 
172
+ #
149
173
  # Waits for the specific `selector` to either appear or disappear, depending on the `state`.
150
174
  def wait(selector, state: nil)
151
175
  raise NotImplementedError.new('wait is not implemented yet.')
152
176
  end
153
177
 
154
- # Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
155
- # value.
178
+ #
179
+ # Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value.
156
180
  def wait_for_event(event, optionsOrPredicate: nil)
157
181
  raise NotImplementedError.new('wait_for_event is not implemented yet.')
158
182
  end
159
183
 
160
- # This method waits until `AndroidWebView` matching the `selector` is opened and returns it. If there is already an open
161
- # `AndroidWebView` matching the `selector`, returns immediately.
184
+ #
185
+ # This method waits until `AndroidWebView` matching the `selector` is opened and returns it. If there is already an open `AndroidWebView` matching the `selector`, returns immediately.
162
186
  def web_view(selector)
163
187
  raise NotImplementedError.new('web_view is not implemented yet.')
164
188
  end
165
189
 
190
+ #
166
191
  # Currently open WebViews.
167
192
  def web_views
168
193
  raise NotImplementedError.new('web_views is not implemented yet.')
@@ -180,20 +205,20 @@ module Playwright
180
205
 
181
206
  # -- inherited from EventEmitter --
182
207
  # @nodoc
183
- def once(event, callback)
184
- event_emitter_proxy.once(event, callback)
208
+ def off(event, callback)
209
+ event_emitter_proxy.off(event, callback)
185
210
  end
186
211
 
187
212
  # -- inherited from EventEmitter --
188
213
  # @nodoc
189
- def on(event, callback)
190
- event_emitter_proxy.on(event, callback)
214
+ def once(event, callback)
215
+ event_emitter_proxy.once(event, callback)
191
216
  end
192
217
 
193
218
  # -- inherited from EventEmitter --
194
219
  # @nodoc
195
- def off(event, callback)
196
- event_emitter_proxy.off(event, callback)
220
+ def on(event, callback)
221
+ event_emitter_proxy.on(event, callback)
197
222
  end
198
223
 
199
224
  private def event_emitter_proxy
@@ -1,26 +1,31 @@
1
1
  module Playwright
2
2
  class AndroidInput < PlaywrightApi
3
3
 
4
+ #
4
5
  # Performs a drag between `from` and `to` points.
5
6
  def drag(from, to, steps)
6
7
  wrap_impl(@impl.drag(unwrap_impl(from), unwrap_impl(to), unwrap_impl(steps)))
7
8
  end
8
9
 
10
+ #
9
11
  # Presses the `key`.
10
12
  def press(key)
11
13
  wrap_impl(@impl.press(unwrap_impl(key)))
12
14
  end
13
15
 
16
+ #
14
17
  # Swipes following the path defined by `segments`.
15
18
  def swipe(from, segments, steps)
16
19
  raise NotImplementedError.new('swipe is not implemented yet.')
17
20
  end
18
21
 
22
+ #
19
23
  # Taps at the specified `point`.
20
24
  def tap_point(point)
21
25
  wrap_impl(@impl.tap_point(unwrap_impl(point)))
22
26
  end
23
27
 
28
+ #
24
29
  # Types `text` into currently focused widget.
25
30
  def type(text)
26
31
  wrap_impl(@impl.type(unwrap_impl(text)))
@@ -1,13 +1,15 @@
1
1
  module Playwright
2
- # `AndroidSocket` is a way to communicate with a process launched on the `AndroidDevice`. Use
3
- # [`method: AndroidDevice.open`] to open a socket.
2
+ #
3
+ # `AndroidSocket` is a way to communicate with a process launched on the `AndroidDevice`. Use [`method: AndroidDevice.open`] to open a socket.
4
4
  class AndroidSocket < PlaywrightApi
5
5
 
6
+ #
6
7
  # Closes the socket.
7
8
  def close
8
9
  raise NotImplementedError.new('close is not implemented yet.')
9
10
  end
10
11
 
12
+ #
11
13
  # Writes some `data` to the socket.
12
14
  def write(data)
13
15
  raise NotImplementedError.new('write is not implemented yet.')
@@ -1,18 +1,21 @@
1
1
  module Playwright
2
- # `AndroidWebView` represents a WebView open on the `AndroidDevice`. WebView is usually obtained using
3
- # [`method: AndroidDevice.webView`].
2
+ #
3
+ # `AndroidWebView` represents a WebView open on the `AndroidDevice`. WebView is usually obtained using [`method: AndroidDevice.webView`].
4
4
  class AndroidWebView < PlaywrightApi
5
5
 
6
+ #
6
7
  # Connects to the WebView and returns a regular Playwright `Page` to interact with.
7
8
  def page
8
9
  raise NotImplementedError.new('page is not implemented yet.')
9
10
  end
10
11
 
12
+ #
11
13
  # WebView process PID.
12
14
  def pid
13
15
  raise NotImplementedError.new('pid is not implemented yet.')
14
16
  end
15
17
 
18
+ #
16
19
  # WebView package identifier.
17
20
  def pkg
18
21
  raise NotImplementedError.new('pkg is not implemented yet.')
@@ -1,9 +1,12 @@
1
1
  module Playwright
2
- # Exposes API that can be used for the Web API testing. This class is used for creating `APIRequestContext` instance which
3
- # in turn can be used for sending web requests. An instance of this class can be obtained via
4
- # [`property: Playwright.request`]. For more information see `APIRequestContext`.
2
+ #
3
+ # Exposes API that can be used for the Web API testing. This class is used for creating
4
+ # `APIRequestContext` instance which in turn can be used for sending web requests. An instance
5
+ # of this class can be obtained via [`property: Playwright.request`]. For more information
6
+ # see `APIRequestContext`.
5
7
  class APIRequest < PlaywrightApi
6
8
 
9
+ #
7
10
  # Creates new instances of `APIRequestContext`.
8
11
  def new_context(
9
12
  baseURL: nil,
@@ -1,21 +1,23 @@
1
1
  module Playwright
2
+ #
2
3
  # This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
3
4
  # environment or the service to your e2e test.
4
5
  #
5
- # Each Playwright browser context has associated with it `APIRequestContext` instance which shares cookie storage with the
6
- # browser context and can be accessed via [`property: BrowserContext.request`] or [`property: Page.request`]. It is also
7
- # possible to create a new APIRequestContext instance manually by calling [`method: APIRequest.newContext`].
6
+ # Each Playwright browser context has associated with it `APIRequestContext` instance which shares cookie storage with
7
+ # the browser context and can be accessed via [`property: BrowserContext.request`] or [`property: Page.request`].
8
+ # It is also possible to create a new APIRequestContext instance manually by calling [`method: APIRequest.newContext`].
8
9
  #
9
10
  # **Cookie management**
10
11
  #
11
12
  # `APIRequestContext` returned by [`property: BrowserContext.request`] and [`property: Page.request`] shares cookie
12
- # storage with the corresponding `BrowserContext`. Each API request will have `Cookie` header populated with the values
13
- # from the browser context. If the API response contains `Set-Cookie` header it will automatically update `BrowserContext`
14
- # cookies and requests made from the page will pick them up. This means that if you log in using this API, your e2e test
15
- # will be logged in and vice versa.
13
+ # storage with the corresponding `BrowserContext`. Each API request will have `Cookie` header populated with the
14
+ # values from the browser context. If the API response contains `Set-Cookie` header it will automatically update
15
+ # `BrowserContext` cookies and requests made from the page will pick them up. This means that if you log in using
16
+ # this API, your e2e test will be logged in and vice versa.
16
17
  #
17
18
  # If you want API requests to not interfere with the browser cookies you should create a new `APIRequestContext` by
18
- # calling [`method: APIRequest.newContext`]. Such `APIRequestContext` object will have its own isolated cookie storage.
19
+ # calling [`method: APIRequest.newContext`]. Such `APIRequestContext` object will have its own isolated cookie
20
+ # storage.
19
21
  #
20
22
  # ```python sync
21
23
  # import os
@@ -65,9 +67,10 @@ module Playwright
65
67
  # ```
66
68
  class APIRequestContext < PlaywrightApi
67
69
 
68
- # Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its
69
- # response. The method will populate request cookies from the context and update context cookies from the response. The
70
- # method will automatically follow redirects.
70
+ #
71
+ # Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its response.
72
+ # The method will populate request cookies from the context and update
73
+ # context cookies from the response. The method will automatically follow redirects.
71
74
  def delete(
72
75
  url,
73
76
  data: nil,
@@ -82,17 +85,18 @@ module Playwright
82
85
  wrap_impl(@impl.delete(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
83
86
  end
84
87
 
85
- # All responses returned by [`method: APIRequestContext.get`] and similar methods are stored in the memory, so that you
86
- # can later call [`method: APIResponse.body`]. This method discards all stored responses, and makes
87
- # [`method: APIResponse.body`] throw "Response disposed" error.
88
+ #
89
+ # All responses returned by [`method: APIRequestContext.get`] and similar methods are stored in the memory, so that you can later call [`method: APIResponse.body`]. This method
90
+ # discards all stored responses, and makes [`method: APIResponse.body`] throw "Response disposed" error.
88
91
  def dispose
89
92
  wrap_impl(@impl.dispose)
90
93
  end
91
94
 
95
+ #
92
96
  # Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
93
- # context cookies from the response. The method will automatically follow redirects.
97
+ # context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly to the request.
94
98
  #
95
- # JSON objects can be passed directly to the request:
99
+ # **Usage**
96
100
  #
97
101
  # ```python
98
102
  # data = {
@@ -102,8 +106,7 @@ module Playwright
102
106
  # api_request_context.fetch("https://example.com/api/createBook", method="post", data=data)
103
107
  # ```
104
108
  #
105
- # The common way to send file(s) in the body of a request is to encode it as form fields with `multipart/form-data`
106
- # encoding. You can achieve that with Playwright API like this:
109
+ # The common way to send file(s) in the body of a request is to encode it as form fields with `multipart/form-data` encoding. You can achieve that with Playwright API like this:
107
110
  #
108
111
  # ```python
109
112
  # api_request_context.fetch(
@@ -132,9 +135,12 @@ module Playwright
132
135
  wrap_impl(@impl.fetch(unwrap_impl(urlOrRequest), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), method: unwrap_impl(method), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
133
136
  end
134
137
 
135
- # Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response. The
136
- # method will populate request cookies from the context and update context cookies from the response. The method will
137
- # automatically follow redirects.
138
+ #
139
+ # Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response.
140
+ # The method will populate request cookies from the context and update
141
+ # context cookies from the response. The method will automatically follow redirects.
142
+ #
143
+ # **Usage**
138
144
  #
139
145
  # Request parameters can be configured with `params` option, they will be serialized into the URL search parameters:
140
146
  #
@@ -159,9 +165,10 @@ module Playwright
159
165
  wrap_impl(@impl.get(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
160
166
  end
161
167
 
168
+ #
162
169
  # Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response.
163
- # The method will populate request cookies from the context and update context cookies from the response. The method will
164
- # automatically follow redirects.
170
+ # The method will populate request cookies from the context and update
171
+ # context cookies from the response. The method will automatically follow redirects.
165
172
  def head(
166
173
  url,
167
174
  data: nil,
@@ -176,9 +183,10 @@ module Playwright
176
183
  wrap_impl(@impl.head(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
177
184
  end
178
185
 
186
+ #
179
187
  # Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response.
180
- # The method will populate request cookies from the context and update context cookies from the response. The method will
181
- # automatically follow redirects.
188
+ # The method will populate request cookies from the context and update
189
+ # context cookies from the response. The method will automatically follow redirects.
182
190
  def patch(
183
191
  url,
184
192
  data: nil,
@@ -193,9 +201,12 @@ module Playwright
193
201
  wrap_impl(@impl.patch(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
194
202
  end
195
203
 
204
+ #
196
205
  # Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response.
197
- # The method will populate request cookies from the context and update context cookies from the response. The method will
198
- # automatically follow redirects.
206
+ # The method will populate request cookies from the context and update
207
+ # context cookies from the response. The method will automatically follow redirects.
208
+ #
209
+ # **Usage**
199
210
  #
200
211
  # JSON objects can be passed directly to the request:
201
212
  #
@@ -207,8 +218,7 @@ module Playwright
207
218
  # api_request_context.post("https://example.com/api/createBook", data=data)
208
219
  # ```
209
220
  #
210
- # To send form data to the server use `form` option. Its value will be encoded into the request body with
211
- # `application/x-www-form-urlencoded` encoding (see below how to use `multipart/form-data` form encoding to send files):
221
+ # To send form data to the server use `form` option. Its value will be encoded into the request body with `application/x-www-form-urlencoded` encoding (see below how to use `multipart/form-data` form encoding to send files):
212
222
  #
213
223
  # ```python
214
224
  # formData = {
@@ -218,8 +228,7 @@ module Playwright
218
228
  # api_request_context.post("https://example.com/api/findBook", form=formData)
219
229
  # ```
220
230
  #
221
- # The common way to send file(s) in the body of a request is to upload them as form fields with `multipart/form-data`
222
- # encoding. You can achieve that with Playwright API like this:
231
+ # The common way to send file(s) in the body of a request is to upload them as form fields with `multipart/form-data` encoding. You can achieve that with Playwright API like this:
223
232
  #
224
233
  # ```python
225
234
  # api_request_context.post(
@@ -246,9 +255,10 @@ module Playwright
246
255
  wrap_impl(@impl.post(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
247
256
  end
248
257
 
249
- # Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response. The
250
- # method will populate request cookies from the context and update context cookies from the response. The method will
251
- # automatically follow redirects.
258
+ #
259
+ # Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response.
260
+ # The method will populate request cookies from the context and update
261
+ # context cookies from the response. The method will automatically follow redirects.
252
262
  def put(
253
263
  url,
254
264
  data: nil,
@@ -263,28 +273,28 @@ module Playwright
263
273
  wrap_impl(@impl.put(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
264
274
  end
265
275
 
266
- # Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to
267
- # the constructor.
276
+ #
277
+ # Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to the constructor.
268
278
  def storage_state(path: nil)
269
279
  raise NotImplementedError.new('storage_state is not implemented yet.')
270
280
  end
271
281
 
272
282
  # -- inherited from EventEmitter --
273
283
  # @nodoc
274
- def once(event, callback)
275
- event_emitter_proxy.once(event, callback)
284
+ def off(event, callback)
285
+ event_emitter_proxy.off(event, callback)
276
286
  end
277
287
 
278
288
  # -- inherited from EventEmitter --
279
289
  # @nodoc
280
- def on(event, callback)
281
- event_emitter_proxy.on(event, callback)
290
+ def once(event, callback)
291
+ event_emitter_proxy.once(event, callback)
282
292
  end
283
293
 
284
294
  # -- inherited from EventEmitter --
285
295
  # @nodoc
286
- def off(event, callback)
287
- event_emitter_proxy.off(event, callback)
296
+ def on(event, callback)
297
+ event_emitter_proxy.on(event, callback)
288
298
  end
289
299
 
290
300
  private def event_emitter_proxy
@@ -1,4 +1,5 @@
1
1
  module Playwright
2
+ #
2
3
  # `APIResponse` class represents responses returned by [`method: APIRequestContext.get`] and similar methods.
3
4
  #
4
5
  # ```python sync
@@ -15,27 +16,32 @@ module Playwright
15
16
  # ```
16
17
  class APIResponse < PlaywrightApi
17
18
 
19
+ #
18
20
  # Returns the buffer with response body.
19
21
  def body
20
22
  wrap_impl(@impl.body)
21
23
  end
22
24
 
25
+ #
23
26
  # Disposes the body of this response. If not called then the body will stay in memory until the context closes.
24
27
  def dispose
25
28
  wrap_impl(@impl.dispose)
26
29
  end
27
30
 
31
+ #
28
32
  # An object with all the response HTTP headers associated with this response.
29
33
  def headers
30
34
  wrap_impl(@impl.headers)
31
35
  end
32
36
 
33
- # An array with all the request HTTP headers associated with this response. Header names are not lower-cased. Headers with
34
- # multiple entries, such as `Set-Cookie`, appear in the array multiple times.
37
+ #
38
+ # An array with all the request HTTP headers associated with this response. Header names are not lower-cased.
39
+ # Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
35
40
  def headers_array
36
41
  wrap_impl(@impl.headers_array)
37
42
  end
38
43
 
44
+ #
39
45
  # Returns the JSON representation of response body.
40
46
  #
41
47
  # This method will throw if the response body is not parsable via `JSON.parse`.
@@ -43,26 +49,31 @@ module Playwright
43
49
  wrap_impl(@impl.json)
44
50
  end
45
51
 
52
+ #
46
53
  # Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
47
54
  def ok
48
55
  wrap_impl(@impl.ok)
49
56
  end
50
57
 
58
+ #
51
59
  # Contains the status code of the response (e.g., 200 for a success).
52
60
  def status
53
61
  wrap_impl(@impl.status)
54
62
  end
55
63
 
64
+ #
56
65
  # Contains the status text of the response (e.g. usually an "OK" for a success).
57
66
  def status_text
58
67
  wrap_impl(@impl.status_text)
59
68
  end
60
69
 
70
+ #
61
71
  # Returns the text representation of response body.
62
72
  def text
63
73
  wrap_impl(@impl.text)
64
74
  end
65
75
 
76
+ #
66
77
  # Contains the URL of the response.
67
78
  def url
68
79
  wrap_impl(@impl.url)