playwright-ruby-client 1.51.0 → 1.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +5 -0
  3. data/README.md +4 -0
  4. data/documentation/docs/api/browser_context.md +7 -3
  5. data/documentation/docs/api/console_message.md +0 -3
  6. data/documentation/docs/api/experimental/android.md +10 -0
  7. data/documentation/docs/api/frame.md +1 -0
  8. data/documentation/docs/api/frame_locator.md +1 -0
  9. data/documentation/docs/api/locator.md +24 -0
  10. data/documentation/docs/api/locator_assertions.md +47 -1
  11. data/documentation/docs/api/mouse.md +2 -0
  12. data/documentation/docs/api/page.md +34 -2
  13. data/documentation/docs/api/route.md +2 -0
  14. data/documentation/docs/api/selectors.md +10 -0
  15. data/documentation/docs/api/tracing.md +8 -0
  16. data/documentation/docs/article/guides/inspector.md +1 -1
  17. data/documentation/docs/article/guides/playwright_on_alpine_linux.md +9 -69
  18. data/documentation/docs/include/api_coverage.md +8 -2
  19. data/documentation/package.json +3 -3
  20. data/documentation/yarn.lock +12372 -8623
  21. data/lib/playwright/channel.rb +6 -3
  22. data/lib/playwright/channel_owners/android.rb +12 -0
  23. data/lib/playwright/channel_owners/android_device.rb +6 -5
  24. data/lib/playwright/channel_owners/api_request_context.rb +6 -1
  25. data/lib/playwright/channel_owners/browser.rb +37 -6
  26. data/lib/playwright/channel_owners/browser_context.rb +47 -38
  27. data/lib/playwright/channel_owners/browser_type.rb +43 -14
  28. data/lib/playwright/channel_owners/element_handle.rb +22 -17
  29. data/lib/playwright/channel_owners/frame.rb +65 -34
  30. data/lib/playwright/channel_owners/page.rb +39 -9
  31. data/lib/playwright/channel_owners/playwright.rb +10 -4
  32. data/lib/playwright/channel_owners/web_socket.rb +1 -1
  33. data/lib/playwright/connection.rb +3 -0
  34. data/lib/playwright/console_message_impl.rb +3 -2
  35. data/lib/playwright/file_chooser_impl.rb +3 -2
  36. data/lib/playwright/frame_locator_impl.rb +5 -8
  37. data/lib/playwright/javascript/value_parser.rb +54 -2
  38. data/lib/playwright/locator_assertions_impl.rb +100 -34
  39. data/lib/playwright/locator_impl.rb +26 -36
  40. data/lib/playwright/page_assertions_impl.rb +16 -11
  41. data/lib/playwright/selectors_impl.rb +45 -0
  42. data/lib/playwright/test.rb +21 -3
  43. data/lib/playwright/timeout_settings.rb +5 -0
  44. data/lib/playwright/transport.rb +1 -1
  45. data/lib/playwright/utils.rb +0 -33
  46. data/lib/playwright/version.rb +2 -2
  47. data/lib/playwright/web_socket_client.rb +4 -1
  48. data/lib/playwright/web_socket_transport.rb +3 -1
  49. data/lib/playwright.rb +14 -14
  50. data/lib/playwright_api/android.rb +12 -7
  51. data/lib/playwright_api/android_device.rb +8 -8
  52. data/lib/playwright_api/api_request.rb +1 -0
  53. data/lib/playwright_api/api_request_context.rb +6 -6
  54. data/lib/playwright_api/browser.rb +6 -6
  55. data/lib/playwright_api/browser_context.rb +17 -17
  56. data/lib/playwright_api/browser_type.rb +6 -6
  57. data/lib/playwright_api/cdp_session.rb +6 -6
  58. data/lib/playwright_api/console_message.rb +0 -4
  59. data/lib/playwright_api/dialog.rb +6 -6
  60. data/lib/playwright_api/element_handle.rb +6 -6
  61. data/lib/playwright_api/frame.rb +12 -6
  62. data/lib/playwright_api/frame_locator.rb +1 -0
  63. data/lib/playwright_api/js_handle.rb +6 -6
  64. data/lib/playwright_api/locator.rb +30 -3
  65. data/lib/playwright_api/locator_assertions.rb +47 -3
  66. data/lib/playwright_api/mouse.rb +2 -0
  67. data/lib/playwright_api/page.rb +41 -13
  68. data/lib/playwright_api/playwright.rb +6 -6
  69. data/lib/playwright_api/request.rb +6 -6
  70. data/lib/playwright_api/response.rb +6 -6
  71. data/lib/playwright_api/route.rb +8 -6
  72. data/lib/playwright_api/selectors.rb +1 -28
  73. data/lib/playwright_api/tracing.rb +14 -6
  74. data/lib/playwright_api/web_socket.rb +6 -6
  75. data/lib/playwright_api/worker.rb +8 -8
  76. data/sig/playwright.rbs +15 -1
  77. metadata +6 -5
  78. data/lib/playwright/channel_owners/selectors.rb +0 -26
@@ -61,7 +61,7 @@ module Playwright
61
61
  # The following example finds a button with a specific title.
62
62
  #
63
63
  # ```python sync
64
- # button = page.get_by_role("button").and_(page.getByTitle("Subscribe"))
64
+ # button = page.get_by_role("button").and_(page.get_by_title("Subscribe"))
65
65
  # ```
66
66
  def and(locator)
67
67
  wrap_impl(@impl.and(unwrap_impl(locator)))
@@ -274,6 +274,20 @@ module Playwright
274
274
  wrap_impl(@impl.dblclick(button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
275
275
  end
276
276
 
277
+ #
278
+ # Describes the locator, description is used in the trace viewer and reports.
279
+ # Returns the locator pointing to the same element.
280
+ #
281
+ # **Usage**
282
+ #
283
+ # ```python sync
284
+ # button = page.get_by_test_id("btn-sub").describe("Subscribe button")
285
+ # button.click()
286
+ # ```
287
+ def describe(description)
288
+ wrap_impl(@impl.describe(unwrap_impl(description)))
289
+ end
290
+
277
291
  #
278
292
  # Programmatically dispatch an event on the matching element.
279
293
  #
@@ -393,6 +407,13 @@ module Playwright
393
407
  # If `expression` throws or rejects, this method throws.
394
408
  #
395
409
  # **Usage**
410
+ #
411
+ # Passing argument to `expression`:
412
+ #
413
+ # ```python sync
414
+ # result = page.get_by_testid("myId").evaluate("(element, [x, y]) => element.textContent + ' ' + x * y", [7, 8])
415
+ # print(result) # prints "myId text 56"
416
+ # ```
396
417
  def evaluate(expression, arg: nil, timeout: nil)
397
418
  wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg), timeout: unwrap_impl(timeout)))
398
419
  end
@@ -640,6 +661,7 @@ module Playwright
640
661
  def get_by_test_id(testId)
641
662
  wrap_impl(@impl.get_by_test_id(unwrap_impl(testId)))
642
663
  end
664
+ alias_method :get_by_testid, :get_by_test_id
643
665
 
644
666
  #
645
667
  # Allows locating elements that contain given text.
@@ -1246,8 +1268,13 @@ module Playwright
1246
1268
  end
1247
1269
 
1248
1270
  # @nodoc
1249
- def expect(expression, options)
1250
- wrap_impl(@impl.expect(unwrap_impl(expression), unwrap_impl(options)))
1271
+ def expect(expression, options, title)
1272
+ wrap_impl(@impl.expect(unwrap_impl(expression), unwrap_impl(options), unwrap_impl(title)))
1273
+ end
1274
+
1275
+ # @nodoc
1276
+ def resolve_selector
1277
+ wrap_impl(@impl.resolve_selector)
1251
1278
  end
1252
1279
 
1253
1280
  # @nodoc
@@ -72,6 +72,12 @@ module Playwright
72
72
  wrap_impl(@impl.not_to_be_visible(timeout: unwrap_impl(timeout), visible: unwrap_impl(visible)))
73
73
  end
74
74
 
75
+ #
76
+ # The opposite of [`method: LocatorAssertions.toContainClass`].
77
+ def not_to_contain_class(expected, timeout: nil)
78
+ wrap_impl(@impl.not_to_contain_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
79
+ end
80
+
75
81
  #
76
82
  # The opposite of [`method: LocatorAssertions.toContainText`].
77
83
  def not_to_contain_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
@@ -328,6 +334,44 @@ module Playwright
328
334
  wrap_impl(@impl.to_be_visible(timeout: unwrap_impl(timeout), visible: unwrap_impl(visible)))
329
335
  end
330
336
 
337
+ #
338
+ # Ensures the `Locator` points to an element with given CSS classes. All classes from the asserted value, separated by spaces, must be present in the [Element.classList](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList) in any order.
339
+ #
340
+ # **Usage**
341
+ #
342
+ # ```html
343
+ # <div class='middle selected row' id='component'></div>
344
+ # ```
345
+ #
346
+ # ```python sync
347
+ # from playwright.sync_api import expect
348
+ #
349
+ # locator = page.locator("#component")
350
+ # expect(locator).to_contain_class("middle selected row")
351
+ # expect(locator).to_contain_class("selected")
352
+ # expect(locator).to_contain_class("row middle")
353
+ # ```
354
+ #
355
+ # When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class lists. Each element's class attribute is matched against the corresponding class in the array:
356
+ #
357
+ # ```html
358
+ # <div class='list'>
359
+ # <div class='component inactive'></div>
360
+ # <div class='component active'></div>
361
+ # <div class='component inactive'></div>
362
+ # </div>
363
+ # ```
364
+ #
365
+ # ```python sync
366
+ # from playwright.sync_api import expect
367
+ #
368
+ # locator = page.locator(".list > .component")
369
+ # await expect(locator).to_contain_class(["inactive", "active", "inactive"])
370
+ # ```
371
+ def to_contain_class(expected, timeout: nil)
372
+ wrap_impl(@impl.to_contain_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
373
+ end
374
+
331
375
  #
332
376
  # Ensures the `Locator` points to an element that contains the given text. All nested elements will be considered when computing the text content of the element. You can use regular expressions for the value as well.
333
377
  #
@@ -439,7 +483,7 @@ module Playwright
439
483
  end
440
484
 
441
485
  #
442
- # Ensures the `Locator` points to an element with given CSS classes. When a string is provided, it must fully match the element's `class` attribute. To match individual classes or perform partial matches, use a regular expression:
486
+ # Ensures the `Locator` points to an element with given CSS classes. When a string is provided, it must fully match the element's `class` attribute. To match individual classes use [`method: LocatorAssertions.toContainClass`].
443
487
  #
444
488
  # **Usage**
445
489
  #
@@ -451,8 +495,8 @@ module Playwright
451
495
  # from playwright.sync_api import expect
452
496
  #
453
497
  # locator = page.locator("#component")
454
- # expect(locator).to_have_class(re.compile(r"(^|\\s)selected(\\s|$)"))
455
498
  # expect(locator).to_have_class("middle selected row")
499
+ # expect(locator).to_have_class(re.compile(r"(^|\\s)selected(\\s|$)"))
456
500
  # ```
457
501
  #
458
502
  # When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class values. Each element's class attribute is matched against the corresponding string or regular expression in the array:
@@ -460,7 +504,7 @@ module Playwright
460
504
  # ```python sync
461
505
  # from playwright.sync_api import expect
462
506
  #
463
- # locator = page.locator("list > .component")
507
+ # locator = page.locator(".list > .component")
464
508
  # expect(locator).to_have_class(["component", "component selected", "component"])
465
509
  # ```
466
510
  def to_have_class(expected, timeout: nil)
@@ -2,6 +2,8 @@ module Playwright
2
2
  #
3
3
  # The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
4
4
  #
5
+ # **NOTE**: If you want to debug where the mouse moved, you can use the [Trace viewer](../trace-viewer-intro.md) or [Playwright Inspector](../running-tests.md). A red dot showing the location of the mouse will be shown for every mouse action.
6
+ #
5
7
  # Every `page` object has its own Mouse, accessible with [`property: Page.mouse`].
6
8
  #
7
9
  # ```python sync
@@ -716,6 +716,7 @@ module Playwright
716
716
  def get_by_test_id(testId)
717
717
  wrap_impl(@impl.get_by_test_id(unwrap_impl(testId)))
718
718
  end
719
+ alias_method :get_by_testid, :get_by_test_id
719
720
 
720
721
  #
721
722
  # Allows locating elements that contain given text.
@@ -921,6 +922,18 @@ module Playwright
921
922
  wrap_impl(@impl.visible?(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
922
923
  end
923
924
 
925
+ #
926
+ # Returns up to (currently) 200 last console messages from this page. See [`event: Page.console`] for more details.
927
+ def console_messages
928
+ wrap_impl(@impl.console_messages)
929
+ end
930
+
931
+ #
932
+ # Returns up to (currently) 200 last page errors from this page. See [`event: Page.pageError`] for more details.
933
+ def page_errors
934
+ wrap_impl(@impl.page_errors)
935
+ end
936
+
924
937
  #
925
938
  # The method returns an element locator that can be used to perform actions on this page / frame.
926
939
  # Locator is resolved to the element immediately before performing an action, so a series of actions on the same locator can in fact be performed on different DOM elements. That would happen if the DOM structure between those actions has changed.
@@ -948,7 +961,7 @@ module Playwright
948
961
  end
949
962
 
950
963
  #
951
- # Pauses script execution. Playwright will stop executing the script and wait for the user to either press 'Resume'
964
+ # Pauses script execution. Playwright will stop executing the script and wait for the user to either press the 'Resume'
952
965
  # button in the page overlay or to call `playwright.resume()` in the DevTools console.
953
966
  #
954
967
  # User can inspect selectors or perform manual steps while paused. Resume will continue running the original script from
@@ -1084,6 +1097,16 @@ module Playwright
1084
1097
  wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
1085
1098
  end
1086
1099
 
1100
+ #
1101
+ # Returns up to (currently) 100 last network request from this page. See [`event: Page.request`] for more details.
1102
+ #
1103
+ # Returned requests should be accessed immediately, otherwise they might be collected to prevent unbounded memory growth as new requests come in. Once collected, retrieving most information about the request is impossible.
1104
+ #
1105
+ # Note that requests reported through the [`event: Page.request`] request are not collected, so there is a trade off between efficient memory usage with [`method: Page.requests`] and the amount of available information reported through [`event: Page.request`].
1106
+ def requests
1107
+ wrap_impl(@impl.requests)
1108
+ end
1109
+
1087
1110
  #
1088
1111
  # When testing a web page, sometimes unexpected overlays like a "Sign up" dialog appear and block actions you want to automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time, making them tricky to handle in automated tests.
1089
1112
  #
@@ -1793,13 +1816,13 @@ module Playwright
1793
1816
  end
1794
1817
 
1795
1818
  # @nodoc
1796
- def owned_context=(req)
1797
- wrap_impl(@impl.owned_context=(unwrap_impl(req)))
1819
+ def guid
1820
+ wrap_impl(@impl.guid)
1798
1821
  end
1799
1822
 
1800
1823
  # @nodoc
1801
- def guid
1802
- wrap_impl(@impl.guid)
1824
+ def snapshot_for_ai(timeout: nil)
1825
+ wrap_impl(@impl.snapshot_for_ai(timeout: unwrap_impl(timeout)))
1803
1826
  end
1804
1827
 
1805
1828
  # @nodoc
@@ -1812,14 +1835,25 @@ module Playwright
1812
1835
  wrap_impl(@impl.stop_js_coverage)
1813
1836
  end
1814
1837
 
1838
+ # @nodoc
1839
+ def stop_css_coverage
1840
+ wrap_impl(@impl.stop_css_coverage)
1841
+ end
1842
+
1843
+ # @nodoc
1844
+ def owned_context=(req)
1845
+ wrap_impl(@impl.owned_context=(unwrap_impl(req)))
1846
+ end
1847
+
1815
1848
  # @nodoc
1816
1849
  def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1817
1850
  wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1818
1851
  end
1819
1852
 
1853
+ # -- inherited from EventEmitter --
1820
1854
  # @nodoc
1821
- def stop_css_coverage
1822
- wrap_impl(@impl.stop_css_coverage)
1855
+ def once(event, callback)
1856
+ event_emitter_proxy.once(event, callback)
1823
1857
  end
1824
1858
 
1825
1859
  # -- inherited from EventEmitter --
@@ -1834,12 +1868,6 @@ module Playwright
1834
1868
  event_emitter_proxy.off(event, callback)
1835
1869
  end
1836
1870
 
1837
- # -- inherited from EventEmitter --
1838
- # @nodoc
1839
- def once(event, callback)
1840
- event_emitter_proxy.once(event, callback)
1841
- end
1842
-
1843
1871
  private def event_emitter_proxy
1844
1872
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
1845
1873
  end
@@ -105,20 +105,20 @@ module Playwright
105
105
 
106
106
  # -- inherited from EventEmitter --
107
107
  # @nodoc
108
- def on(event, callback)
109
- event_emitter_proxy.on(event, callback)
108
+ def once(event, callback)
109
+ event_emitter_proxy.once(event, callback)
110
110
  end
111
111
 
112
112
  # -- inherited from EventEmitter --
113
113
  # @nodoc
114
- def off(event, callback)
115
- event_emitter_proxy.off(event, callback)
114
+ def on(event, callback)
115
+ event_emitter_proxy.on(event, callback)
116
116
  end
117
117
 
118
118
  # -- inherited from EventEmitter --
119
119
  # @nodoc
120
- def once(event, callback)
121
- event_emitter_proxy.once(event, callback)
120
+ def off(event, callback)
121
+ event_emitter_proxy.off(event, callback)
122
122
  end
123
123
 
124
124
  private def event_emitter_proxy
@@ -207,20 +207,20 @@ module Playwright
207
207
 
208
208
  # -- inherited from EventEmitter --
209
209
  # @nodoc
210
- def on(event, callback)
211
- event_emitter_proxy.on(event, callback)
210
+ def once(event, callback)
211
+ event_emitter_proxy.once(event, callback)
212
212
  end
213
213
 
214
214
  # -- inherited from EventEmitter --
215
215
  # @nodoc
216
- def off(event, callback)
217
- event_emitter_proxy.off(event, callback)
216
+ def on(event, callback)
217
+ event_emitter_proxy.on(event, callback)
218
218
  end
219
219
 
220
220
  # -- inherited from EventEmitter --
221
221
  # @nodoc
222
- def once(event, callback)
223
- event_emitter_proxy.once(event, callback)
222
+ def off(event, callback)
223
+ event_emitter_proxy.off(event, callback)
224
224
  end
225
225
 
226
226
  private def event_emitter_proxy
@@ -129,20 +129,20 @@ module Playwright
129
129
 
130
130
  # -- inherited from EventEmitter --
131
131
  # @nodoc
132
- def on(event, callback)
133
- event_emitter_proxy.on(event, callback)
132
+ def once(event, callback)
133
+ event_emitter_proxy.once(event, callback)
134
134
  end
135
135
 
136
136
  # -- inherited from EventEmitter --
137
137
  # @nodoc
138
- def off(event, callback)
139
- event_emitter_proxy.off(event, callback)
138
+ def on(event, callback)
139
+ event_emitter_proxy.on(event, callback)
140
140
  end
141
141
 
142
142
  # -- inherited from EventEmitter --
143
143
  # @nodoc
144
- def once(event, callback)
145
- event_emitter_proxy.once(event, callback)
144
+ def off(event, callback)
145
+ event_emitter_proxy.off(event, callback)
146
146
  end
147
147
 
148
148
  private def event_emitter_proxy
@@ -35,6 +35,8 @@ module Playwright
35
35
  # 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.
36
36
  #
37
37
  # [`method: Route.continue`] will immediately send the request to the network, other matching handlers won't be invoked. Use [`method: Route.fallback`] If you want next matching handler in the chain to be invoked.
38
+ #
39
+ # **NOTE**: The `Cookie` header cannot be overridden using this method. If a value is provided, it will be ignored, and the cookie will be loaded from the browser's cookie store. To set custom cookies, use [`method: BrowserContext.addCookies`].
38
40
  def continue(headers: nil, method: nil, postData: nil, url: nil)
39
41
  wrap_impl(@impl.continue(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
40
42
  end
@@ -174,20 +176,20 @@ module Playwright
174
176
 
175
177
  # -- inherited from EventEmitter --
176
178
  # @nodoc
177
- def on(event, callback)
178
- event_emitter_proxy.on(event, callback)
179
+ def once(event, callback)
180
+ event_emitter_proxy.once(event, callback)
179
181
  end
180
182
 
181
183
  # -- inherited from EventEmitter --
182
184
  # @nodoc
183
- def off(event, callback)
184
- event_emitter_proxy.off(event, callback)
185
+ def on(event, callback)
186
+ event_emitter_proxy.on(event, callback)
185
187
  end
186
188
 
187
189
  # -- inherited from EventEmitter --
188
190
  # @nodoc
189
- def once(event, callback)
190
- event_emitter_proxy.once(event, callback)
191
+ def off(event, callback)
192
+ event_emitter_proxy.off(event, callback)
191
193
  end
192
194
 
193
195
  private def event_emitter_proxy
@@ -52,35 +52,8 @@ module Playwright
52
52
  #
53
53
  # Defines custom attribute name to be used in [`method: Page.getByTestId`]. `data-testid` is used by default.
54
54
  def set_test_id_attribute(attributeName)
55
- raise NotImplementedError.new('set_test_id_attribute is not implemented yet.')
55
+ wrap_impl(@impl.set_test_id_attribute(unwrap_impl(attributeName)))
56
56
  end
57
57
  alias_method :test_id_attribute=, :set_test_id_attribute
58
-
59
- # @nodoc
60
- def text_id_attribute=(attribute_name)
61
- wrap_impl(@impl.text_id_attribute=(unwrap_impl(attribute_name)))
62
- end
63
-
64
- # -- inherited from EventEmitter --
65
- # @nodoc
66
- def on(event, callback)
67
- event_emitter_proxy.on(event, callback)
68
- end
69
-
70
- # -- inherited from EventEmitter --
71
- # @nodoc
72
- def off(event, callback)
73
- event_emitter_proxy.off(event, callback)
74
- end
75
-
76
- # -- inherited from EventEmitter --
77
- # @nodoc
78
- def once(event, callback)
79
- event_emitter_proxy.once(event, callback)
80
- end
81
-
82
- private def event_emitter_proxy
83
- @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
84
- end
85
58
  end
86
59
  end
@@ -2,6 +2,10 @@ module Playwright
2
2
  #
3
3
  # API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](../trace-viewer.md) after Playwright script runs.
4
4
  #
5
+ # **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`.
6
+ #
7
+ # 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.
8
+ #
5
9
  # Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
6
10
  #
7
11
  # ```python sync
@@ -17,6 +21,10 @@ module Playwright
17
21
  #
18
22
  # Start tracing.
19
23
  #
24
+ # **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`.
25
+ #
26
+ # 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.
27
+ #
20
28
  # **Usage**
21
29
  #
22
30
  # ```python sync
@@ -97,20 +105,20 @@ module Playwright
97
105
 
98
106
  # -- inherited from EventEmitter --
99
107
  # @nodoc
100
- def on(event, callback)
101
- event_emitter_proxy.on(event, callback)
108
+ def once(event, callback)
109
+ event_emitter_proxy.once(event, callback)
102
110
  end
103
111
 
104
112
  # -- inherited from EventEmitter --
105
113
  # @nodoc
106
- def off(event, callback)
107
- event_emitter_proxy.off(event, callback)
114
+ def on(event, callback)
115
+ event_emitter_proxy.on(event, callback)
108
116
  end
109
117
 
110
118
  # -- inherited from EventEmitter --
111
119
  # @nodoc
112
- def once(event, callback)
113
- event_emitter_proxy.once(event, callback)
120
+ def off(event, callback)
121
+ event_emitter_proxy.off(event, callback)
114
122
  end
115
123
 
116
124
  private def event_emitter_proxy
@@ -36,20 +36,20 @@ module Playwright
36
36
 
37
37
  # -- inherited from EventEmitter --
38
38
  # @nodoc
39
- def on(event, callback)
40
- event_emitter_proxy.on(event, callback)
39
+ def once(event, callback)
40
+ event_emitter_proxy.once(event, callback)
41
41
  end
42
42
 
43
43
  # -- inherited from EventEmitter --
44
44
  # @nodoc
45
- def off(event, callback)
46
- event_emitter_proxy.off(event, callback)
45
+ def on(event, callback)
46
+ event_emitter_proxy.on(event, callback)
47
47
  end
48
48
 
49
49
  # -- inherited from EventEmitter --
50
50
  # @nodoc
51
- def once(event, callback)
52
- event_emitter_proxy.once(event, callback)
51
+ def off(event, callback)
52
+ event_emitter_proxy.off(event, callback)
53
53
  end
54
54
 
55
55
  private def event_emitter_proxy
@@ -46,14 +46,20 @@ module Playwright
46
46
  wrap_impl(@impl.url)
47
47
  end
48
48
 
49
+ # @nodoc
50
+ def context=(req)
51
+ wrap_impl(@impl.context=(unwrap_impl(req)))
52
+ end
53
+
49
54
  # @nodoc
50
55
  def page=(req)
51
56
  wrap_impl(@impl.page=(unwrap_impl(req)))
52
57
  end
53
58
 
59
+ # -- inherited from EventEmitter --
54
60
  # @nodoc
55
- def context=(req)
56
- wrap_impl(@impl.context=(unwrap_impl(req)))
61
+ def once(event, callback)
62
+ event_emitter_proxy.once(event, callback)
57
63
  end
58
64
 
59
65
  # -- inherited from EventEmitter --
@@ -68,12 +74,6 @@ module Playwright
68
74
  event_emitter_proxy.off(event, callback)
69
75
  end
70
76
 
71
- # -- inherited from EventEmitter --
72
- # @nodoc
73
- def once(event, callback)
74
- event_emitter_proxy.once(event, callback)
75
- end
76
-
77
77
  private def event_emitter_proxy
78
78
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
79
79
  end
data/sig/playwright.rbs CHANGED
@@ -170,6 +170,7 @@ module Playwright
170
170
  def get_by_placeholder: ((String | Regexp) text, ?exact: bool) -> Locator
171
171
  def get_by_role: (("alert" | "alertdialog" | "application" | "article" | "banner" | "blockquote" | "button" | "caption" | "cell" | "checkbox" | "code" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "deletion" | "dialog" | "directory" | "document" | "emphasis" | "feed" | "figure" | "form" | "generic" | "grid" | "gridcell" | "group" | "heading" | "img" | "insertion" | "link" | "list" | "listbox" | "listitem" | "log" | "main" | "marquee" | "math" | "meter" | "menu" | "menubar" | "menuitem" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "none" | "note" | "option" | "paragraph" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "search" | "searchbox" | "separator" | "slider" | "spinbutton" | "status" | "strong" | "subscript" | "superscript" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "textbox" | "time" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem") role, ?checked: bool, ?disabled: bool, ?exact: bool, ?expanded: bool, ?includeHidden: bool, ?level: Integer, ?name: (String | Regexp), ?pressed: bool, ?selected: bool) -> Locator
172
172
  def get_by_test_id: ((String | Regexp) testId) -> Locator
173
+ def get_by_testid: ((String | Regexp) testId) -> Locator
173
174
  def get_by_text: ((String | Regexp) text, ?exact: bool) -> Locator
174
175
  def get_by_title: ((String | Regexp) text, ?exact: bool) -> Locator
175
176
  def goto: (String url, ?referer: String, ?timeout: Float, ?waitUntil: ("load" | "domcontentloaded" | "networkidle" | "commit")) -> (nil | Response)
@@ -218,6 +219,8 @@ module Playwright
218
219
 
219
220
  class Selectors
220
221
  def register: (String name, ?script: String, ?contentScript: bool, ?path: (String | File)) -> void
222
+ def set_test_id_attribute: (String attributeName) -> void
223
+ def test_id_attribute=: (String attributeName) -> void
221
224
  end
222
225
 
223
226
  class Clock
@@ -237,7 +240,7 @@ module Playwright
237
240
  def location: -> Hash[untyped, untyped]
238
241
  def page: -> (nil | Page)
239
242
  def text: -> String
240
- def type: -> String
243
+ def type: -> ("log" | "debug" | "info" | "error" | "warning" | "dir" | "dirxml" | "table" | "trace" | "clear" | "startGroup" | "startGroupCollapsed" | "endGroup" | "assert" | "profile" | "profileEnd" | "count" | "timeEnd")
241
244
  end
242
245
 
243
246
  class Dialog
@@ -291,6 +294,7 @@ module Playwright
291
294
  def get_by_placeholder: ((String | Regexp) text, ?exact: bool) -> Locator
292
295
  def get_by_role: (("alert" | "alertdialog" | "application" | "article" | "banner" | "blockquote" | "button" | "caption" | "cell" | "checkbox" | "code" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "deletion" | "dialog" | "directory" | "document" | "emphasis" | "feed" | "figure" | "form" | "generic" | "grid" | "gridcell" | "group" | "heading" | "img" | "insertion" | "link" | "list" | "listbox" | "listitem" | "log" | "main" | "marquee" | "math" | "meter" | "menu" | "menubar" | "menuitem" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "none" | "note" | "option" | "paragraph" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "search" | "searchbox" | "separator" | "slider" | "spinbutton" | "status" | "strong" | "subscript" | "superscript" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "textbox" | "time" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem") role, ?checked: bool, ?disabled: bool, ?exact: bool, ?expanded: bool, ?includeHidden: bool, ?level: Integer, ?name: (String | Regexp), ?pressed: bool, ?selected: bool) -> Locator
293
296
  def get_by_test_id: ((String | Regexp) testId) -> Locator
297
+ def get_by_testid: ((String | Regexp) testId) -> Locator
294
298
  def get_by_text: ((String | Regexp) text, ?exact: bool) -> Locator
295
299
  def get_by_title: ((String | Regexp) text, ?exact: bool) -> Locator
296
300
  def go_back: (?timeout: Float, ?waitUntil: ("load" | "domcontentloaded" | "networkidle" | "commit")) -> (nil | Response)
@@ -307,6 +311,8 @@ module Playwright
307
311
  def enabled?: (String selector, ?strict: bool, ?timeout: Float) -> bool
308
312
  def hidden?: (String selector, ?strict: bool, ?timeout: Float) -> bool
309
313
  def visible?: (String selector, ?strict: bool, ?timeout: Float) -> bool
314
+ def console_messages: -> Array[untyped]
315
+ def page_errors: -> Array[untyped]
310
316
  def locator: (String selector, ?has: Locator, ?hasNot: Locator, ?hasNotText: (String | Regexp), ?hasText: (String | Regexp)) -> Locator
311
317
  def main_frame: -> Frame
312
318
  def opener: -> (nil | Page)
@@ -315,6 +321,7 @@ module Playwright
315
321
  def press: (String selector, String key, ?delay: Float, ?noWaitAfter: bool, ?strict: bool, ?timeout: Float) -> void
316
322
  def query_selector: (String selector, ?strict: bool) -> (nil | ElementHandle)
317
323
  def query_selector_all: (String selector) -> Array[untyped]
324
+ def requests: -> Array[untyped]
318
325
  def reload: (?timeout: Float, ?waitUntil: ("load" | "domcontentloaded" | "networkidle" | "commit")) -> (nil | Response)
319
326
  def route: ((String | Regexp | function) url, function handler, ?times: Integer) -> void
320
327
  def route_from_har: ((String | File) har, ?notFound: ("abort" | "fallback"), ?update: bool, ?updateContent: ("embed" | "attach"), ?updateMode: ("full" | "minimal"), ?url: (String | Regexp)) -> void
@@ -464,6 +471,7 @@ module Playwright
464
471
  def click: (?button: ("left" | "right" | "middle"), ?clickCount: Integer, ?delay: Float, ?force: bool, ?modifiers: Array[untyped], ?noWaitAfter: bool, ?position: Hash[untyped, untyped], ?timeout: Float, ?trial: bool) -> void
465
472
  def count: -> Integer
466
473
  def dblclick: (?button: ("left" | "right" | "middle"), ?delay: Float, ?force: bool, ?modifiers: Array[untyped], ?noWaitAfter: bool, ?position: Hash[untyped, untyped], ?timeout: Float, ?trial: bool) -> void
474
+ def describe: (String description) -> Locator
467
475
  def dispatch_event: (String type_, ?eventInit: untyped, ?timeout: Float) -> void
468
476
  def drag_to: (Locator target, ?force: bool, ?noWaitAfter: bool, ?sourcePosition: Hash[untyped, untyped], ?targetPosition: Hash[untyped, untyped], ?timeout: Float, ?trial: bool) -> void
469
477
  def element_handle: (?timeout: Float) -> ElementHandle
@@ -484,6 +492,7 @@ module Playwright
484
492
  def get_by_placeholder: ((String | Regexp) text, ?exact: bool) -> Locator
485
493
  def get_by_role: (("alert" | "alertdialog" | "application" | "article" | "banner" | "blockquote" | "button" | "caption" | "cell" | "checkbox" | "code" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "deletion" | "dialog" | "directory" | "document" | "emphasis" | "feed" | "figure" | "form" | "generic" | "grid" | "gridcell" | "group" | "heading" | "img" | "insertion" | "link" | "list" | "listbox" | "listitem" | "log" | "main" | "marquee" | "math" | "meter" | "menu" | "menubar" | "menuitem" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "none" | "note" | "option" | "paragraph" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "search" | "searchbox" | "separator" | "slider" | "spinbutton" | "status" | "strong" | "subscript" | "superscript" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "textbox" | "time" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem") role, ?checked: bool, ?disabled: bool, ?exact: bool, ?expanded: bool, ?includeHidden: bool, ?level: Integer, ?name: (String | Regexp), ?pressed: bool, ?selected: bool) -> Locator
486
494
  def get_by_test_id: ((String | Regexp) testId) -> Locator
495
+ def get_by_testid: ((String | Regexp) testId) -> Locator
487
496
  def get_by_text: ((String | Regexp) text, ?exact: bool) -> Locator
488
497
  def get_by_title: ((String | Regexp) text, ?exact: bool) -> Locator
489
498
  def highlight: -> void
@@ -527,6 +536,7 @@ module Playwright
527
536
  def get_by_placeholder: ((String | Regexp) text, ?exact: bool) -> Locator
528
537
  def get_by_role: (("alert" | "alertdialog" | "application" | "article" | "banner" | "blockquote" | "button" | "caption" | "cell" | "checkbox" | "code" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "deletion" | "dialog" | "directory" | "document" | "emphasis" | "feed" | "figure" | "form" | "generic" | "grid" | "gridcell" | "group" | "heading" | "img" | "insertion" | "link" | "list" | "listbox" | "listitem" | "log" | "main" | "marquee" | "math" | "meter" | "menu" | "menubar" | "menuitem" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "none" | "note" | "option" | "paragraph" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "search" | "searchbox" | "separator" | "slider" | "spinbutton" | "status" | "strong" | "subscript" | "superscript" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "textbox" | "time" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem") role, ?checked: bool, ?disabled: bool, ?exact: bool, ?expanded: bool, ?includeHidden: bool, ?level: Integer, ?name: (String | Regexp), ?pressed: bool, ?selected: bool) -> Locator
529
538
  def get_by_test_id: ((String | Regexp) testId) -> Locator
539
+ def get_by_testid: ((String | Regexp) testId) -> Locator
530
540
  def get_by_text: ((String | Regexp) text, ?exact: bool) -> Locator
531
541
  def get_by_title: ((String | Regexp) text, ?exact: bool) -> Locator
532
542
  def last: -> FrameLocator
@@ -570,6 +580,7 @@ module Playwright
570
580
  def not_to_be_hidden: (?timeout: Float) -> void
571
581
  def not_to_be_in_viewport: (?ratio: Float, ?timeout: Float) -> void
572
582
  def not_to_be_visible: (?timeout: Float, ?visible: bool) -> void
583
+ def not_to_contain_class: ((String | Array[untyped]) expected, ?timeout: Float) -> void
573
584
  def not_to_contain_text: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?ignoreCase: bool, ?timeout: Float, ?useInnerText: bool) -> void
574
585
  def not_to_have_accessible_description: ((String | Regexp) name, ?ignoreCase: bool, ?timeout: Float) -> void
575
586
  def not_to_have_accessible_error_message: ((String | Regexp) errorMessage, ?ignoreCase: bool, ?timeout: Float) -> void
@@ -595,6 +606,7 @@ module Playwright
595
606
  def to_be_hidden: (?timeout: Float) -> void
596
607
  def to_be_in_viewport: (?ratio: Float, ?timeout: Float) -> void
597
608
  def to_be_visible: (?timeout: Float, ?visible: bool) -> void
609
+ def to_contain_class: ((String | Array[untyped]) expected, ?timeout: Float) -> void
598
610
  def to_contain_text: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?ignoreCase: bool, ?timeout: Float, ?useInnerText: bool) -> void
599
611
  def to_have_accessible_description: ((String | Regexp) description, ?ignoreCase: bool, ?timeout: Float) -> void
600
612
  def to_have_accessible_error_message: ((String | Regexp) errorMessage, ?ignoreCase: bool, ?timeout: Float) -> void
@@ -621,6 +633,8 @@ module Playwright
621
633
 
622
634
  class Android
623
635
  def devices: (?host: String, ?omitDriverInstall: bool, ?port: Integer) -> Array[untyped]
636
+ def set_default_timeout: (Float timeout) -> void
637
+ def default_timeout=: (Float timeout) -> void
624
638
  end
625
639
 
626
640
  class AndroidDevice