playwright-ruby-client 0.0.8 → 1.58.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 (209) hide show
  1. checksums.yaml +4 -4
  2. data/AGENTS.md +4 -0
  3. data/CLAUDE/api_generation.md +28 -0
  4. data/CLAUDE/ci_expectations.md +23 -0
  5. data/CLAUDE/gem_release_flow.md +39 -0
  6. data/CLAUDE/past_upgrade_pr_patterns.md +42 -0
  7. data/CLAUDE/playwright_upgrade_workflow.md +35 -0
  8. data/CLAUDE/rspec_debugging.md +30 -0
  9. data/CLAUDE/unimplemented_examples.md +18 -0
  10. data/CLAUDE.md +32 -0
  11. data/CONTRIBUTING.md +5 -0
  12. data/README.md +60 -16
  13. data/documentation/README.md +33 -0
  14. data/documentation/babel.config.js +3 -0
  15. data/documentation/docs/api/api_request.md +7 -0
  16. data/documentation/docs/api/api_request_context.md +298 -0
  17. data/documentation/docs/api/api_response.md +114 -0
  18. data/documentation/docs/api/browser.md +237 -0
  19. data/documentation/docs/api/browser_context.md +503 -0
  20. data/documentation/docs/api/browser_type.md +184 -0
  21. data/documentation/docs/api/cdp_session.md +44 -0
  22. data/documentation/docs/api/clock.md +154 -0
  23. data/documentation/docs/api/console_message.md +85 -0
  24. data/documentation/docs/api/dialog.md +84 -0
  25. data/documentation/docs/api/download.md +111 -0
  26. data/documentation/docs/api/element_handle.md +694 -0
  27. data/documentation/docs/api/experimental/_category_.yml +3 -0
  28. data/documentation/docs/api/experimental/android.md +42 -0
  29. data/documentation/docs/api/experimental/android_device.md +109 -0
  30. data/documentation/docs/api/experimental/android_input.md +43 -0
  31. data/documentation/docs/api/experimental/android_socket.md +7 -0
  32. data/documentation/docs/api/experimental/android_web_view.md +7 -0
  33. data/documentation/docs/api/file_chooser.md +53 -0
  34. data/documentation/docs/api/frame.md +1218 -0
  35. data/documentation/docs/api/frame_locator.md +348 -0
  36. data/documentation/docs/api/js_handle.md +121 -0
  37. data/documentation/docs/api/keyboard.md +170 -0
  38. data/documentation/docs/api/locator.md +1495 -0
  39. data/documentation/docs/api/locator_assertions.md +827 -0
  40. data/documentation/docs/api/mouse.md +86 -0
  41. data/documentation/docs/api/page.md +1946 -0
  42. data/documentation/docs/api/page_assertions.md +65 -0
  43. data/documentation/docs/api/playwright.md +66 -0
  44. data/documentation/docs/api/request.md +255 -0
  45. data/documentation/docs/api/response.md +176 -0
  46. data/documentation/docs/api/route.md +205 -0
  47. data/documentation/docs/api/selectors.md +63 -0
  48. data/documentation/docs/api/touchscreen.md +22 -0
  49. data/documentation/docs/api/tracing.md +129 -0
  50. data/documentation/docs/api/web_socket.md +51 -0
  51. data/documentation/docs/api/worker.md +83 -0
  52. data/documentation/docs/article/api_coverage.mdx +11 -0
  53. data/documentation/docs/article/getting_started.md +161 -0
  54. data/documentation/docs/article/guides/_category_.yml +3 -0
  55. data/documentation/docs/article/guides/download_playwright_driver.md +55 -0
  56. data/documentation/docs/article/guides/inspector.md +31 -0
  57. data/documentation/docs/article/guides/launch_browser.md +121 -0
  58. data/documentation/docs/article/guides/playwright_on_alpine_linux.md +112 -0
  59. data/documentation/docs/article/guides/rails_integration.md +278 -0
  60. data/documentation/docs/article/guides/rails_integration_with_null_driver.md +145 -0
  61. data/documentation/docs/article/guides/recording_video.md +79 -0
  62. data/documentation/docs/article/guides/rspec_integration.md +59 -0
  63. data/documentation/docs/article/guides/semi_automation.md +71 -0
  64. data/documentation/docs/article/guides/use_storage_state.md +78 -0
  65. data/documentation/docs/include/api_coverage.md +671 -0
  66. data/documentation/docusaurus.config.js +114 -0
  67. data/documentation/package.json +39 -0
  68. data/documentation/sidebars.js +15 -0
  69. data/documentation/src/components/HomepageFeatures.js +61 -0
  70. data/documentation/src/components/HomepageFeatures.module.css +13 -0
  71. data/documentation/src/css/custom.css +44 -0
  72. data/documentation/src/pages/index.js +49 -0
  73. data/documentation/src/pages/index.module.css +41 -0
  74. data/documentation/src/pages/markdown-page.md +7 -0
  75. data/documentation/static/.nojekyll +0 -0
  76. data/documentation/static/img/playwright-logo.svg +9 -0
  77. data/documentation/static/img/playwright-ruby-client.png +0 -0
  78. data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
  79. data/documentation/static/img/undraw_web_development.svg +1 -0
  80. data/documentation/static/img/undraw_windows.svg +1 -0
  81. data/documentation/yarn.lock +9005 -0
  82. data/lib/playwright/{input_types/android_input.rb → android_input_impl.rb} +5 -1
  83. data/lib/playwright/api_implementation.rb +18 -0
  84. data/lib/playwright/api_response_impl.rb +77 -0
  85. data/lib/playwright/channel.rb +62 -1
  86. data/lib/playwright/channel_owner.rb +70 -7
  87. data/lib/playwright/channel_owners/android.rb +16 -3
  88. data/lib/playwright/channel_owners/android_device.rb +22 -66
  89. data/lib/playwright/channel_owners/api_request_context.rb +247 -0
  90. data/lib/playwright/channel_owners/artifact.rb +40 -0
  91. data/lib/playwright/channel_owners/binding_call.rb +70 -0
  92. data/lib/playwright/channel_owners/browser.rb +114 -22
  93. data/lib/playwright/channel_owners/browser_context.rb +589 -15
  94. data/lib/playwright/channel_owners/browser_type.rb +90 -1
  95. data/lib/playwright/channel_owners/cdp_session.rb +19 -0
  96. data/lib/playwright/channel_owners/dialog.rb +32 -0
  97. data/lib/playwright/channel_owners/element_handle.rb +107 -43
  98. data/lib/playwright/channel_owners/fetch_request.rb +8 -0
  99. data/lib/playwright/channel_owners/frame.rb +334 -104
  100. data/lib/playwright/channel_owners/js_handle.rb +9 -13
  101. data/lib/playwright/channel_owners/local_utils.rb +82 -0
  102. data/lib/playwright/channel_owners/page.rb +778 -95
  103. data/lib/playwright/channel_owners/playwright.rb +25 -30
  104. data/lib/playwright/channel_owners/request.rb +120 -18
  105. data/lib/playwright/channel_owners/response.rb +113 -0
  106. data/lib/playwright/channel_owners/route.rb +181 -0
  107. data/lib/playwright/channel_owners/stream.rb +30 -0
  108. data/lib/playwright/channel_owners/tracing.rb +117 -0
  109. data/lib/playwright/channel_owners/web_socket.rb +96 -0
  110. data/lib/playwright/channel_owners/worker.rb +46 -0
  111. data/lib/playwright/channel_owners/writable_stream.rb +14 -0
  112. data/lib/playwright/clock_impl.rb +67 -0
  113. data/lib/playwright/connection.rb +111 -63
  114. data/lib/playwright/console_message_impl.rb +29 -0
  115. data/lib/playwright/download_impl.rb +32 -0
  116. data/lib/playwright/errors.rb +42 -5
  117. data/lib/playwright/event_emitter.rb +17 -3
  118. data/lib/playwright/event_emitter_proxy.rb +49 -0
  119. data/lib/playwright/events.rb +10 -5
  120. data/lib/playwright/file_chooser_impl.rb +24 -0
  121. data/lib/playwright/frame_locator_impl.rb +66 -0
  122. data/lib/playwright/har_router.rb +89 -0
  123. data/lib/playwright/http_headers.rb +14 -0
  124. data/lib/playwright/input_files.rb +102 -15
  125. data/lib/playwright/javascript/expression.rb +7 -11
  126. data/lib/playwright/javascript/regex.rb +23 -0
  127. data/lib/playwright/javascript/source_url.rb +16 -0
  128. data/lib/playwright/javascript/value_parser.rb +108 -19
  129. data/lib/playwright/javascript/value_serializer.rb +47 -8
  130. data/lib/playwright/javascript/visitor_info.rb +26 -0
  131. data/lib/playwright/javascript.rb +2 -10
  132. data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +6 -2
  133. data/lib/playwright/locator_assertions_impl.rb +571 -0
  134. data/lib/playwright/locator_impl.rb +544 -0
  135. data/lib/playwright/locator_utils.rb +136 -0
  136. data/lib/playwright/mouse_impl.rb +57 -0
  137. data/lib/playwright/page_assertions_impl.rb +154 -0
  138. data/lib/playwright/playwright_api.rb +102 -30
  139. data/lib/playwright/raw_headers.rb +61 -0
  140. data/lib/playwright/route_handler.rb +78 -0
  141. data/lib/playwright/select_option_values.rb +34 -13
  142. data/lib/playwright/selectors_impl.rb +45 -0
  143. data/lib/playwright/test.rb +102 -0
  144. data/lib/playwright/timeout_settings.rb +9 -4
  145. data/lib/playwright/touchscreen_impl.rb +14 -0
  146. data/lib/playwright/transport.rb +61 -10
  147. data/lib/playwright/url_matcher.rb +24 -2
  148. data/lib/playwright/utils.rb +48 -13
  149. data/lib/playwright/version.rb +2 -1
  150. data/lib/playwright/video.rb +54 -0
  151. data/lib/playwright/waiter.rb +166 -0
  152. data/lib/playwright/web_socket_client.rb +167 -0
  153. data/lib/playwright/web_socket_transport.rb +116 -0
  154. data/lib/playwright.rb +188 -11
  155. data/lib/playwright_api/android.rb +46 -11
  156. data/lib/playwright_api/android_device.rb +182 -31
  157. data/lib/playwright_api/android_input.rb +22 -13
  158. data/lib/playwright_api/android_socket.rb +18 -0
  159. data/lib/playwright_api/android_web_view.rb +24 -0
  160. data/lib/playwright_api/api_request.rb +26 -0
  161. data/lib/playwright_api/api_request_context.rb +311 -0
  162. data/lib/playwright_api/api_response.rb +92 -0
  163. data/lib/playwright_api/browser.rb +116 -103
  164. data/lib/playwright_api/browser_context.rb +290 -389
  165. data/lib/playwright_api/browser_type.rb +96 -118
  166. data/lib/playwright_api/cdp_session.rb +36 -39
  167. data/lib/playwright_api/clock.rb +121 -0
  168. data/lib/playwright_api/console_message.rb +35 -19
  169. data/lib/playwright_api/dialog.rb +53 -50
  170. data/lib/playwright_api/download.rb +49 -43
  171. data/lib/playwright_api/element_handle.rb +354 -402
  172. data/lib/playwright_api/file_chooser.rb +15 -18
  173. data/lib/playwright_api/frame.rb +703 -603
  174. data/lib/playwright_api/frame_locator.rb +285 -0
  175. data/lib/playwright_api/js_handle.rb +50 -76
  176. data/lib/playwright_api/keyboard.rb +67 -146
  177. data/lib/playwright_api/locator.rb +1304 -0
  178. data/lib/playwright_api/locator_assertions.rb +704 -0
  179. data/lib/playwright_api/mouse.rb +23 -29
  180. data/lib/playwright_api/page.rb +1196 -1176
  181. data/lib/playwright_api/page_assertions.rb +60 -0
  182. data/lib/playwright_api/playwright.rb +54 -122
  183. data/lib/playwright_api/request.rb +112 -74
  184. data/lib/playwright_api/response.rb +92 -20
  185. data/lib/playwright_api/route.rb +152 -62
  186. data/lib/playwright_api/selectors.rb +47 -61
  187. data/lib/playwright_api/touchscreen.rb +8 -2
  188. data/lib/playwright_api/tracing.rb +128 -0
  189. data/lib/playwright_api/web_socket.rb +43 -5
  190. data/lib/playwright_api/worker.rb +74 -34
  191. data/playwright.gemspec +14 -9
  192. data/sig/playwright.rbs +658 -0
  193. metadata +216 -50
  194. data/docs/api_coverage.md +0 -354
  195. data/lib/playwright/channel_owners/chromium_browser.rb +0 -8
  196. data/lib/playwright/channel_owners/chromium_browser_context.rb +0 -8
  197. data/lib/playwright/channel_owners/console_message.rb +0 -21
  198. data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
  199. data/lib/playwright/channel_owners/selectors.rb +0 -4
  200. data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
  201. data/lib/playwright/input_type.rb +0 -19
  202. data/lib/playwright/input_types/mouse.rb +0 -4
  203. data/lib/playwright/input_types/touchscreen.rb +0 -4
  204. data/lib/playwright/javascript/function.rb +0 -67
  205. data/lib/playwright/wait_helper.rb +0 -73
  206. data/lib/playwright_api/accessibility.rb +0 -93
  207. data/lib/playwright_api/binding_call.rb +0 -23
  208. data/lib/playwright_api/chromium_browser_context.rb +0 -57
  209. data/lib/playwright_api/video.rb +0 -24
@@ -0,0 +1,205 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Route
6
+
7
+
8
+ Whenever a network route is set up with [Page#route](./page#route) or [BrowserContext#route](./browser_context#route), the [Route](./route) object
9
+ allows to handle the route.
10
+
11
+ Learn more about [networking](https://playwright.dev/python/docs/network).
12
+
13
+ ## abort
14
+
15
+ ```
16
+ def abort(errorCode: nil)
17
+ ```
18
+
19
+
20
+ Aborts the route's request.
21
+
22
+ ## continue
23
+
24
+ ```
25
+ def continue(headers: nil, method: nil, postData: nil, url: nil)
26
+ ```
27
+
28
+
29
+ Sends route's request to the network with optional overrides.
30
+
31
+ **Usage**
32
+
33
+ ```ruby
34
+ def handle(route, request)
35
+ # override headers
36
+ headers = request.headers
37
+ headers['foo'] = 'bar' # set "foo" header
38
+ headers['user-agent'] = 'Unknown Browser' # modify user-agent
39
+ headers.delete('bar') # remove "bar" header
40
+
41
+ route.continue(headers: headers)
42
+ end
43
+ page.route("**/*", method(:handle))
44
+ ```
45
+
46
+ **Details**
47
+
48
+ The `headers` option applies to both the routed request and any redirects it initiates. However, `url`, `method`, and `postData` only apply to the original request and are not carried over to redirected requests.
49
+
50
+ [Route#continue](./route#continue) will immediately send the request to the network, other matching handlers won't be invoked. Use [Route#fallback](./route#fallback) If you want next matching handler in the chain to be invoked.
51
+
52
+ **NOTE**: Some request headers are **forbidden** and cannot be overridden (for example, `Cookie`, `Host`, `Content-Length` and others, see [this MDN page](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_header) for full list).
53
+ If an override is provided for a forbidden header, it will be ignored and the original request header will be used.
54
+
55
+ To set custom cookies, use [BrowserContext#add_cookies](./browser_context#add_cookies).
56
+
57
+ ## fallback
58
+
59
+ ```
60
+ def fallback(headers: nil, method: nil, postData: nil, url: nil)
61
+ ```
62
+
63
+
64
+ Continues route's request with optional overrides. The method is similar to [Route#continue](./route#continue) with the difference that other matching handlers will be invoked before sending the request.
65
+
66
+ **Usage**
67
+
68
+ When several routes match the given pattern, they run in the order opposite to their registration.
69
+ That way the last registered route can always override all the previous ones. In the example below,
70
+ request will be handled by the bottom-most handler first, then it'll fall back to the previous one and
71
+ in the end will be aborted by the first registered route.
72
+
73
+ ```ruby
74
+ page.route("**/*", -> (route,_) { route.abort }) # Runs last.
75
+ page.route("**/*", -> (route,_) { route.fallback }) # Runs second.
76
+ page.route("**/*", -> (route,_) { route.fallback }) # Runs first.
77
+ ```
78
+
79
+ Registering multiple routes is useful when you want separate handlers to
80
+ handle different kinds of requests, for example API calls vs page resources or
81
+ GET requests vs POST requests as in the example below.
82
+
83
+ ```ruby
84
+ # Handle GET requests.
85
+ def handle_post(route, request)
86
+ if request.method != "GET"
87
+ route.fallback
88
+ return
89
+ end
90
+
91
+ # Handling GET only.
92
+ # ...
93
+ end
94
+
95
+ # Handle POST requests.
96
+ def handle_post(route, request)
97
+ if request.method != "POST"
98
+ route.fallback
99
+ return
100
+ end
101
+
102
+ # Handling POST only.
103
+ # ...
104
+ end
105
+
106
+ page.route("**/*", handle_get)
107
+ page.route("**/*", handle_post)
108
+ ```
109
+
110
+ One can also modify request while falling back to the subsequent handler, that way intermediate
111
+ route handler can modify url, method, headers and postData of the request.
112
+
113
+ ```ruby
114
+ def handle(route, request)
115
+ # override headers
116
+ headers = request.headers
117
+ headers['foo'] = 'bar' # set "foo" header
118
+ headers['user-agent'] = 'Unknown Browser' # modify user-agent
119
+ headers.delete('bar') # remove "bar" header
120
+
121
+ route.fallback(headers: headers)
122
+ end
123
+ page.route("**/*", method(:handle))
124
+ ```
125
+
126
+ Use [Route#continue](./route#continue) to immediately send the request to the network, other matching handlers won't be invoked in that case.
127
+
128
+ ## fetch
129
+
130
+ ```
131
+ def fetch(
132
+ headers: nil,
133
+ maxRedirects: nil,
134
+ maxRetries: nil,
135
+ method: nil,
136
+ postData: nil,
137
+ timeout: nil,
138
+ url: nil)
139
+ ```
140
+
141
+
142
+ Performs the request and fetches result without fulfilling it, so that the response
143
+ could be modified and then fulfilled.
144
+
145
+ **Usage**
146
+
147
+ ```ruby
148
+ def handle(route, request)
149
+ response = route.fetch
150
+ json = response.json
151
+ json["message"]["big_red_dog"] = []
152
+
153
+ route.fulfill(response: response, json: json)
154
+ end
155
+ page.route("https://dog.ceo/api/breeds/list/all", method(:handle))
156
+ ```
157
+
158
+ **Details**
159
+
160
+ Note that `headers` option will apply to the fetched request as well as any redirects initiated by it. If you want to only apply `headers` to the original request, but not to redirects, look into [Route#continue](./route#continue) instead.
161
+
162
+ ## fulfill
163
+
164
+ ```
165
+ def fulfill(
166
+ body: nil,
167
+ contentType: nil,
168
+ headers: nil,
169
+ json: nil,
170
+ path: nil,
171
+ response: nil,
172
+ status: nil)
173
+ ```
174
+
175
+
176
+ Fulfills route's request with given response.
177
+
178
+ **Usage**
179
+
180
+ An example of fulfilling all requests with 404 responses:
181
+
182
+ ```ruby
183
+ page.route("**/*", ->(route, request) {
184
+ route.fulfill(
185
+ status: 404,
186
+ contentType: 'text/plain',
187
+ body: 'not found!!',
188
+ )
189
+ })
190
+ ```
191
+
192
+ An example of serving static file:
193
+
194
+ ```ruby
195
+ page.route("**/xhr_endpoint", ->(route, _) { route.fulfill(path: "mock_data.json") })
196
+ ```
197
+
198
+ ## request
199
+
200
+ ```
201
+ def request
202
+ ```
203
+
204
+
205
+ A request to be routed.
@@ -0,0 +1,63 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Selectors
6
+
7
+
8
+ Selectors can be used to install custom selector engines. See [extensibility](https://playwright.dev/python/docs/extensibility) for more
9
+ information.
10
+
11
+ ## register
12
+
13
+ ```
14
+ def register(name, script: nil, contentScript: nil, path: nil)
15
+ ```
16
+
17
+
18
+ Selectors must be registered before creating the page.
19
+
20
+ **Usage**
21
+
22
+ An example of registering selector engine that queries elements based on a tag name:
23
+
24
+ ```ruby
25
+ tag_selector = <<~JAVASCRIPT
26
+ {
27
+ // Returns the first element matching given selector in the root's subtree.
28
+ query(root, selector) {
29
+ return root.querySelector(selector);
30
+ },
31
+ // Returns all elements matching given selector in the root's subtree.
32
+ queryAll(root, selector) {
33
+ return Array.from(root.querySelectorAll(selector));
34
+ }
35
+ }
36
+ JAVASCRIPT
37
+
38
+ # Register the engine. Selectors will be prefixed with "tag=".
39
+ playwright.selectors.register("tag", script: tag_selector)
40
+ playwright.chromium.launch do |browser|
41
+ page = browser.new_page
42
+ page.content = '<div><button>Click me</button></div>'
43
+
44
+ # Use the selector prefixed with its name.
45
+ button = page.locator('tag=button')
46
+ # Combine it with other selector engines.
47
+ page.locator('tag=div').get_by_text('Click me').click
48
+
49
+ # Can use it in any methods supporting selectors.
50
+ button_count = page.locator('tag=button').count
51
+ button_count # => 1
52
+ end
53
+ ```
54
+
55
+ ## set_test_id_attribute
56
+
57
+ ```
58
+ def set_test_id_attribute(attributeName)
59
+ ```
60
+ alias: `test_id_attribute=`
61
+
62
+
63
+ Defines custom attribute name to be used in [Page#get_by_test_id](./page#get_by_test_id). `data-testid` is used by default.
@@ -0,0 +1,22 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Touchscreen
6
+
7
+
8
+ The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the
9
+ touchscreen can only be used in browser contexts that have been initialized with `hasTouch` set to true.
10
+
11
+ This class is limited to emulating tap gestures. For examples of other gestures simulated by manually dispatching touch events, see the [emulating legacy touch events](https://playwright.dev/python/docs/touch-events) page.
12
+
13
+ ## tap_point
14
+
15
+ ```
16
+ def tap_point(x, y)
17
+ ```
18
+
19
+
20
+ Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`).
21
+
22
+ **NOTE**: [Page#tap_point](./page#tap_point) the method will throw if `hasTouch` option of the browser context is false.
@@ -0,0 +1,129 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Tracing
6
+
7
+
8
+ API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](https://playwright.dev/python/docs/trace-viewer) after Playwright script runs.
9
+
10
+ **NOTE**: You probably want to [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead of using `context.tracing`.
11
+
12
+ The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions (like `expect` calls). We recommend [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace), which includes those assertions and provides a more complete trace for debugging test failures.
13
+
14
+ Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
15
+
16
+ ```ruby
17
+ browser.new_context do |context|
18
+ context.tracing.start(screenshots: true, snapshots: true)
19
+ page = context.new_page
20
+ page.goto('https://playwright.dev')
21
+ context.tracing.stop(path: 'trace.zip')
22
+ end
23
+ ```
24
+
25
+ ## start
26
+
27
+ ```
28
+ def start(
29
+ name: nil,
30
+ screenshots: nil,
31
+ snapshots: nil,
32
+ sources: nil,
33
+ title: nil)
34
+ ```
35
+
36
+
37
+ Start tracing.
38
+
39
+ **NOTE**: You probably want to [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead of using `Tracing.start`.
40
+
41
+ The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions (like `expect` calls). We recommend [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace), which includes those assertions and provides a more complete trace for debugging test failures.
42
+
43
+ **Usage**
44
+
45
+ ```ruby
46
+ context.tracing.start(screenshots: true, snapshots: true)
47
+ page = context.new_page
48
+ page.goto('https://playwright.dev')
49
+ context.tracing.stop(path: 'trace.zip')
50
+ ```
51
+
52
+ ## start_chunk
53
+
54
+ ```
55
+ def start_chunk(name: nil, title: nil)
56
+ ```
57
+
58
+
59
+ Start a new trace chunk. If you'd like to record multiple traces on the same [BrowserContext](./browser_context), use [Tracing#start](./tracing#start) once, and then create multiple trace chunks with [Tracing#start_chunk](./tracing#start_chunk) and [Tracing#stop_chunk](./tracing#stop_chunk).
60
+
61
+ **Usage**
62
+
63
+ ```ruby
64
+ context.tracing.start(screenshots: true, snapshots: true)
65
+ page = context.new_page
66
+ page.goto("https://playwright.dev")
67
+
68
+ context.tracing.start_chunk
69
+ page.get_by_text("Get Started").click
70
+ # Everything between start_chunk and stop_chunk will be recorded in the trace.
71
+ context.tracing.stop_chunk(path: "trace1.zip")
72
+
73
+ context.tracing.start_chunk
74
+ page.goto("http://example.com")
75
+ # Save a second trace file with different actions.
76
+ context.tracing.stop_chunk(path: "trace2.zip")
77
+ ```
78
+
79
+ ## group
80
+
81
+ ```
82
+ def group(name, location: nil)
83
+ ```
84
+
85
+
86
+ **NOTE**: Use `test.step` instead when available.
87
+
88
+ Creates a new group within the trace, assigning any subsequent API calls to this group, until [Tracing#group_end](./tracing#group_end) is called. Groups can be nested and will be visible in the trace viewer.
89
+
90
+ **Usage**
91
+
92
+ ```ruby
93
+ # All actions between group and group_end
94
+ # will be shown in the trace viewer as a group.
95
+ context.tracing.group("Open Playwright.dev > API")
96
+
97
+ page = context.new_page
98
+ page.goto("https://playwright.dev/")
99
+ page.get_by_role("link", name: "API").click
100
+
101
+ context.tracing.group_end
102
+ ```
103
+
104
+ ## group_end
105
+
106
+ ```
107
+ def group_end
108
+ ```
109
+
110
+
111
+ Closes the last group created by [Tracing#group](./tracing#group).
112
+
113
+ ## stop
114
+
115
+ ```
116
+ def stop(path: nil)
117
+ ```
118
+
119
+
120
+ Stop tracing.
121
+
122
+ ## stop_chunk
123
+
124
+ ```
125
+ def stop_chunk(path: nil)
126
+ ```
127
+
128
+
129
+ Stop the trace chunk. See [Tracing#start_chunk](./tracing#start_chunk) for more details about multiple trace chunks.
@@ -0,0 +1,51 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # WebSocket
6
+
7
+
8
+ The [WebSocket](./web_socket) class represents WebSocket connections within a page. It provides the ability to inspect and manipulate the data being transmitted and received.
9
+
10
+ If you want to intercept or modify WebSocket frames, consider using `WebSocketRoute`.
11
+
12
+ ## closed?
13
+
14
+ ```
15
+ def closed?
16
+ ```
17
+
18
+
19
+ Indicates that the web socket has been closed.
20
+
21
+ ## url
22
+
23
+ ```
24
+ def url
25
+ ```
26
+
27
+
28
+ Contains the URL of the WebSocket.
29
+
30
+ ## expect_event
31
+
32
+ ```
33
+ def expect_event(event, predicate: nil, timeout: nil, &block)
34
+ ```
35
+
36
+
37
+ Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
38
+ value. Will throw an error if the webSocket is closed before the event is fired. Returns the event data value.
39
+
40
+ ## wait_for_event
41
+
42
+ ```
43
+ def wait_for_event(event, predicate: nil, timeout: nil, &block)
44
+ ```
45
+
46
+
47
+ **NOTE**: In most cases, you should use [WebSocket#wait_for_event](./web_socket#wait_for_event).
48
+
49
+ Waits for given `event` to fire. If predicate is provided, it passes
50
+ event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
51
+ Will throw an error if the socket is closed before the `event` is fired.
@@ -0,0 +1,83 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Worker
6
+
7
+
8
+ The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). `worker`
9
+ event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the
10
+ worker is gone.
11
+
12
+ ```ruby
13
+ def handle_worker(worker)
14
+ puts "worker created: #{worker.url}"
15
+ worker.once("close", -> (w) { puts "worker destroyed: #{w.url}" })
16
+ end
17
+
18
+ page.on('worker', method(:handle_worker))
19
+
20
+ puts "current workers:"
21
+ page.workers.each do |worker|
22
+ puts " #{worker.url}"
23
+ end
24
+ ```
25
+
26
+ ## evaluate
27
+
28
+ ```
29
+ def evaluate(expression, arg: nil)
30
+ ```
31
+
32
+
33
+ Returns the return value of `expression`.
34
+
35
+ If the function passed to the [Worker#evaluate](./worker#evaluate) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Worker#evaluate](./worker#evaluate) would wait for the promise
36
+ to resolve and return its value.
37
+
38
+ If the function passed to the [Worker#evaluate](./worker#evaluate) returns a non-[Serializable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description) value, then [Worker#evaluate](./worker#evaluate) returns `undefined`. Playwright also supports transferring some
39
+ additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
40
+
41
+ ## evaluate_handle
42
+
43
+ ```
44
+ def evaluate_handle(expression, arg: nil)
45
+ ```
46
+
47
+
48
+ Returns the return value of `expression` as a [JSHandle](./js_handle).
49
+
50
+ The only difference between [Worker#evaluate](./worker#evaluate) and
51
+ [Worker#evaluate_handle](./worker#evaluate_handle) is that [Worker#evaluate_handle](./worker#evaluate_handle)
52
+ returns [JSHandle](./js_handle).
53
+
54
+ If the function passed to the [Worker#evaluate_handle](./worker#evaluate_handle) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Worker#evaluate_handle](./worker#evaluate_handle) would wait for
55
+ the promise to resolve and return its value.
56
+
57
+ ## url
58
+
59
+ ```
60
+ def url
61
+ ```
62
+
63
+
64
+
65
+ ## expect_event
66
+
67
+ ```
68
+ def expect_event(event, predicate: nil, timeout: nil, &block)
69
+ ```
70
+
71
+
72
+ Waits for event to fire and passes its value into the predicate function.
73
+ Returns when the predicate returns truthy value.
74
+ Will throw an error if the page is closed before the event is fired.
75
+ Returns the event data value.
76
+
77
+ **Usage**
78
+
79
+ ```ruby
80
+ message = worker.expect_event("console") do
81
+ worker.evaluate("console.log(42)")
82
+ end
83
+ ```
@@ -0,0 +1,11 @@
1
+ ---
2
+ position: 20
3
+ ---
4
+
5
+ # API Coverages
6
+
7
+ `playwright-ruby-client` doesn't cover all of the Playwright APIs. The APIs listed below without strikethrough are available in `playwright-ruby-client`.
8
+
9
+ import ApiCoverage from '../include/api_coverage.md'
10
+
11
+ <ApiCoverage />