playwright-ruby-client 1.14.beta3 → 1.15.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -14
  3. data/documentation/docs/api/browser.md +4 -0
  4. data/documentation/docs/api/browser_context.md +5 -1
  5. data/documentation/docs/api/browser_type.md +2 -0
  6. data/documentation/docs/api/element_handle.md +30 -5
  7. data/documentation/docs/api/experimental/android_device.md +2 -0
  8. data/documentation/docs/api/frame.md +32 -6
  9. data/documentation/docs/api/locator.md +67 -38
  10. data/documentation/docs/api/mouse.md +11 -0
  11. data/documentation/docs/api/page.md +38 -7
  12. data/documentation/docs/api/request.md +34 -1
  13. data/documentation/docs/api/response.md +37 -2
  14. data/documentation/docs/api/selectors.md +29 -3
  15. data/documentation/docs/api/tracing.md +42 -8
  16. data/documentation/docs/api/worker.md +12 -11
  17. data/documentation/docs/article/getting_started.md +10 -1
  18. data/documentation/docs/article/guides/download_playwright_driver.md +9 -0
  19. data/documentation/docs/article/guides/inspector.md +1 -1
  20. data/documentation/docs/article/guides/playwright_on_alpine_linux.md +56 -3
  21. data/documentation/docs/article/guides/rails_integration.md +4 -2
  22. data/documentation/docs/article/guides/rails_integration_with_null_driver.md +86 -0
  23. data/documentation/docs/article/guides/recording_video.md +1 -1
  24. data/documentation/docs/article/guides/semi_automation.md +2 -2
  25. data/documentation/docs/article/guides/use_storage_state.md +78 -0
  26. data/documentation/docs/include/api_coverage.md +15 -0
  27. data/documentation/docusaurus.config.js +1 -0
  28. data/documentation/package.json +2 -2
  29. data/documentation/src/pages/index.js +0 -1
  30. data/documentation/static/img/playwright-ruby-client.png +0 -0
  31. data/documentation/yarn.lock +625 -549
  32. data/lib/playwright/channel.rb +36 -2
  33. data/lib/playwright/channel_owners/artifact.rb +6 -2
  34. data/lib/playwright/channel_owners/browser.rb +4 -0
  35. data/lib/playwright/channel_owners/browser_context.rb +21 -14
  36. data/lib/playwright/channel_owners/browser_type.rb +0 -1
  37. data/lib/playwright/channel_owners/element_handle.rb +10 -2
  38. data/lib/playwright/channel_owners/frame.rb +8 -0
  39. data/lib/playwright/channel_owners/page.rb +20 -4
  40. data/lib/playwright/channel_owners/playwright.rb +9 -0
  41. data/lib/playwright/channel_owners/request.rb +53 -17
  42. data/lib/playwright/channel_owners/response.rb +48 -5
  43. data/lib/playwright/connection.rb +8 -11
  44. data/lib/playwright/http_headers.rb +0 -6
  45. data/lib/playwright/locator_impl.rb +8 -0
  46. data/lib/playwright/mouse_impl.rb +9 -0
  47. data/lib/playwright/raw_headers.rb +61 -0
  48. data/lib/playwright/{route_handler_entry.rb → route_handler.rb} +30 -2
  49. data/lib/playwright/tracing_impl.rb +18 -7
  50. data/lib/playwright/transport.rb +2 -0
  51. data/lib/playwright/utils.rb +8 -1
  52. data/lib/playwright/version.rb +2 -2
  53. data/lib/playwright/web_socket_transport.rb +2 -0
  54. data/lib/playwright.rb +46 -5
  55. data/lib/playwright_api/android.rb +6 -6
  56. data/lib/playwright_api/android_device.rb +11 -9
  57. data/lib/playwright_api/browser.rb +12 -8
  58. data/lib/playwright_api/browser_context.rb +12 -8
  59. data/lib/playwright_api/browser_type.rb +9 -7
  60. data/lib/playwright_api/cdp_session.rb +7 -7
  61. data/lib/playwright_api/console_message.rb +6 -6
  62. data/lib/playwright_api/dialog.rb +6 -6
  63. data/lib/playwright_api/element_handle.rb +31 -8
  64. data/lib/playwright_api/frame.rb +35 -12
  65. data/lib/playwright_api/js_handle.rb +6 -6
  66. data/lib/playwright_api/locator.rb +39 -0
  67. data/lib/playwright_api/mouse.rb +8 -0
  68. data/lib/playwright_api/page.rb +43 -15
  69. data/lib/playwright_api/playwright.rb +6 -6
  70. data/lib/playwright_api/request.rb +33 -7
  71. data/lib/playwright_api/response.rb +31 -8
  72. data/lib/playwright_api/route.rb +6 -6
  73. data/lib/playwright_api/selectors.rb +38 -7
  74. data/lib/playwright_api/tracing.rb +33 -4
  75. data/lib/playwright_api/web_socket.rb +6 -6
  76. data/lib/playwright_api/worker.rb +8 -8
  77. metadata +8 -4
@@ -45,5 +45,13 @@ module Playwright
45
45
  def up(button: nil, clickCount: nil)
46
46
  wrap_impl(@impl.up(button: unwrap_impl(button), clickCount: unwrap_impl(clickCount)))
47
47
  end
48
+
49
+ # Dispatches a `wheel` event.
50
+ #
51
+ # > NOTE: Wheel events may cause scrolling if they are not handled, and this method does not wait for the scrolling to
52
+ # finish before returning.
53
+ def wheel(deltaX, deltaY)
54
+ wrap_impl(@impl.wheel(unwrap_impl(deltaX), unwrap_impl(deltaY)))
55
+ end
48
56
  end
49
57
  end
@@ -284,8 +284,8 @@ module Playwright
284
284
  # # → False
285
285
  # page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches")
286
286
  # ```
287
- def emulate_media(colorScheme: nil, media: nil, reducedMotion: nil)
288
- wrap_impl(@impl.emulate_media(colorScheme: unwrap_impl(colorScheme), media: unwrap_impl(media), reducedMotion: unwrap_impl(reducedMotion)))
287
+ def emulate_media(colorScheme: nil, forcedColors: nil, media: nil, reducedMotion: nil)
288
+ wrap_impl(@impl.emulate_media(colorScheme: unwrap_impl(colorScheme), forcedColors: unwrap_impl(forcedColors), media: unwrap_impl(media), reducedMotion: unwrap_impl(reducedMotion)))
289
289
  end
290
290
 
291
291
  # The method finds an element matching the specified selector within the page and passes it as a first argument to
@@ -562,18 +562,18 @@ module Playwright
562
562
  # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
563
563
  # last redirect.
564
564
  #
565
- # `page.goto` will throw an error if:
565
+ # The method will throw an error if:
566
566
  # - there's an SSL error (e.g. in case of self-signed certificates).
567
567
  # - target URL is invalid.
568
568
  # - the `timeout` is exceeded during navigation.
569
569
  # - the remote server does not respond or is unreachable.
570
570
  # - the main resource failed to load.
571
571
  #
572
- # `page.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not
572
+ # The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not
573
573
  # Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
574
574
  # [`method: Response.status`].
575
575
  #
576
- # > NOTE: `page.goto` either throws an error or returns a main resource response. The only exceptions are navigation to
576
+ # > NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to
577
577
  # `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
578
578
  # > NOTE: Headless mode doesn't support navigation to a PDF document. See the
579
579
  # [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
@@ -662,8 +662,6 @@ module Playwright
662
662
  # element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
663
663
  # different DOM elements. That would happen if the DOM structure between those actions has changed.
664
664
  #
665
- # Note that locator always implies visibility, so it will always be locating visible elements.
666
- #
667
665
  # Shortcut for main frame's [`method: Frame.locator`].
668
666
  def locator(selector)
669
667
  wrap_impl(@impl.locator(unwrap_impl(selector)))
@@ -820,6 +818,9 @@ module Playwright
820
818
  # Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
821
819
  #
822
820
  # > NOTE: The handler will only be called for the first url if the response is a redirect.
821
+ # > NOTE: [`method: Page.route`] will not intercept requests intercepted by Service Worker. See
822
+ # [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
823
+ # request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);`
823
824
  #
824
825
  # An example of a naive handler that aborts all image requests:
825
826
  #
@@ -857,8 +858,8 @@ module Playwright
857
858
  # To remove a route with its handler you can use [`method: Page.unroute`].
858
859
  #
859
860
  # > NOTE: Enabling routing disables http cache.
860
- def route(url, handler)
861
- wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler)))
861
+ def route(url, handler, times: nil)
862
+ wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler), times: unwrap_impl(times)))
862
863
  end
863
864
 
864
865
  # Returns the buffer with the captured screenshot.
@@ -907,6 +908,33 @@ module Playwright
907
908
  wrap_impl(@impl.select_option(unwrap_impl(selector), element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
908
909
  end
909
910
 
911
+ # This method checks or unchecks an element matching `selector` by performing the following steps:
912
+ # 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
913
+ # 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
914
+ # 1. If the element already has the right checked state, this method returns immediately.
915
+ # 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
916
+ # element is detached during the checks, the whole action is retried.
917
+ # 1. Scroll the element into view if needed.
918
+ # 1. Use [`property: Page.mouse`] to click in the center of the element.
919
+ # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
920
+ # 1. Ensure that the element is now checked or unchecked. If not, this method throws.
921
+ #
922
+ # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
923
+ # zero timeout disables this.
924
+ #
925
+ # Shortcut for main frame's [`method: Frame.setChecked`].
926
+ def set_checked(
927
+ selector,
928
+ checked,
929
+ force: nil,
930
+ noWaitAfter: nil,
931
+ position: nil,
932
+ strict: nil,
933
+ timeout: nil,
934
+ trial: nil)
935
+ wrap_impl(@impl.set_checked(unwrap_impl(selector), unwrap_impl(checked), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
936
+ end
937
+
910
938
  def set_content(html, timeout: nil, waitUntil: nil)
911
939
  wrap_impl(@impl.set_content(unwrap_impl(html), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
912
940
  end
@@ -1354,20 +1382,20 @@ module Playwright
1354
1382
 
1355
1383
  # -- inherited from EventEmitter --
1356
1384
  # @nodoc
1357
- def once(event, callback)
1358
- event_emitter_proxy.once(event, callback)
1385
+ def off(event, callback)
1386
+ event_emitter_proxy.off(event, callback)
1359
1387
  end
1360
1388
 
1361
1389
  # -- inherited from EventEmitter --
1362
1390
  # @nodoc
1363
- def on(event, callback)
1364
- event_emitter_proxy.on(event, callback)
1391
+ def once(event, callback)
1392
+ event_emitter_proxy.once(event, callback)
1365
1393
  end
1366
1394
 
1367
1395
  # -- inherited from EventEmitter --
1368
1396
  # @nodoc
1369
- def off(event, callback)
1370
- event_emitter_proxy.off(event, callback)
1397
+ def on(event, callback)
1398
+ event_emitter_proxy.on(event, callback)
1371
1399
  end
1372
1400
 
1373
1401
  private def event_emitter_proxy
@@ -93,20 +93,20 @@ module Playwright
93
93
 
94
94
  # -- inherited from EventEmitter --
95
95
  # @nodoc
96
- def once(event, callback)
97
- event_emitter_proxy.once(event, callback)
96
+ def off(event, callback)
97
+ event_emitter_proxy.off(event, callback)
98
98
  end
99
99
 
100
100
  # -- inherited from EventEmitter --
101
101
  # @nodoc
102
- def on(event, callback)
103
- event_emitter_proxy.on(event, callback)
102
+ def once(event, callback)
103
+ event_emitter_proxy.once(event, callback)
104
104
  end
105
105
 
106
106
  # -- inherited from EventEmitter --
107
107
  # @nodoc
108
- def off(event, callback)
109
- event_emitter_proxy.off(event, callback)
108
+ def on(event, callback)
109
+ event_emitter_proxy.on(event, callback)
110
110
  end
111
111
 
112
112
  private def event_emitter_proxy
@@ -14,6 +14,11 @@ module Playwright
14
14
  # request is issued to a redirected url.
15
15
  class Request < PlaywrightApi
16
16
 
17
+ # An object with all the request HTTP headers associated with this request. The header names are lower-cased.
18
+ def all_headers
19
+ wrap_impl(@impl.all_headers)
20
+ end
21
+
17
22
  # The method returns `null` unless this request has failed, as reported by `requestfailed` event.
18
23
  #
19
24
  # Example of logging of all the failed requests:
@@ -30,11 +35,22 @@ module Playwright
30
35
  wrap_impl(@impl.frame)
31
36
  end
32
37
 
33
- # An object with HTTP headers associated with the request. All header names are lower-case.
38
+ # **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [`method: Request.allHeaders`] instead.
34
39
  def headers
35
40
  wrap_impl(@impl.headers)
36
41
  end
37
42
 
43
+ # An array with all the request HTTP headers associated with this request. Unlike [`method: Request.allHeaders`], header
44
+ # names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
45
+ def headers_array
46
+ wrap_impl(@impl.headers_array)
47
+ end
48
+
49
+ # Returns the value of the header matching the name. The name is case insensitive.
50
+ def header_value(name)
51
+ wrap_impl(@impl.header_value(unwrap_impl(name)))
52
+ end
53
+
38
54
  # Whether this request is driving frame's navigation.
39
55
  def navigation_request?
40
56
  wrap_impl(@impl.navigation_request?)
@@ -109,6 +125,11 @@ module Playwright
109
125
  wrap_impl(@impl.response)
110
126
  end
111
127
 
128
+ # Returns resource size information for given request.
129
+ def sizes
130
+ wrap_impl(@impl.sizes)
131
+ end
132
+
112
133
  # Returns resource timing information for given request. Most of the timing values become available upon the response,
113
134
  # `responseEnd` becomes available when request finishes. Find more information at
114
135
  # [Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).
@@ -128,22 +149,27 @@ module Playwright
128
149
  wrap_impl(@impl.url)
129
150
  end
130
151
 
152
+ # @nodoc
153
+ def header_values(name)
154
+ wrap_impl(@impl.header_values(unwrap_impl(name)))
155
+ end
156
+
131
157
  # -- inherited from EventEmitter --
132
158
  # @nodoc
133
- def once(event, callback)
134
- event_emitter_proxy.once(event, callback)
159
+ def off(event, callback)
160
+ event_emitter_proxy.off(event, callback)
135
161
  end
136
162
 
137
163
  # -- inherited from EventEmitter --
138
164
  # @nodoc
139
- def on(event, callback)
140
- event_emitter_proxy.on(event, callback)
165
+ def once(event, callback)
166
+ event_emitter_proxy.once(event, callback)
141
167
  end
142
168
 
143
169
  # -- inherited from EventEmitter --
144
170
  # @nodoc
145
- def off(event, callback)
146
- event_emitter_proxy.off(event, callback)
171
+ def on(event, callback)
172
+ event_emitter_proxy.on(event, callback)
147
173
  end
148
174
 
149
175
  private def event_emitter_proxy
@@ -2,12 +2,17 @@ module Playwright
2
2
  # `Response` class represents responses which are received by page.
3
3
  class Response < PlaywrightApi
4
4
 
5
+ # An object with all the response HTTP headers associated with this response.
6
+ def all_headers
7
+ wrap_impl(@impl.all_headers)
8
+ end
9
+
5
10
  # Returns the buffer with response body.
6
11
  def body
7
12
  wrap_impl(@impl.body)
8
13
  end
9
14
 
10
- # Waits for this response to finish, returns failure error if request failed.
15
+ # Waits for this response to finish, returns always `null`.
11
16
  def finished
12
17
  wrap_impl(@impl.finished)
13
18
  end
@@ -17,11 +22,29 @@ module Playwright
17
22
  wrap_impl(@impl.frame)
18
23
  end
19
24
 
20
- # Returns the object with HTTP headers associated with the response. All header names are lower-case.
25
+ # **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [`method: Response.allHeaders`] instead.
21
26
  def headers
22
27
  wrap_impl(@impl.headers)
23
28
  end
24
29
 
30
+ # An array with all the request HTTP headers associated with this response. Unlike [`method: Response.allHeaders`], header
31
+ # names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
32
+ def headers_array
33
+ wrap_impl(@impl.headers_array)
34
+ end
35
+
36
+ # Returns the value of the header matching the name. The name is case insensitive. If multiple headers have the same name
37
+ # (except `set-cookie`), they are returned as a list separated by `, `. For `set-cookie`, the `\n` separator is used. If
38
+ # no headers are found, `null` is returned.
39
+ def header_value(name)
40
+ wrap_impl(@impl.header_value(unwrap_impl(name)))
41
+ end
42
+
43
+ # Returns all values of the headers matching the name, for example `set-cookie`. The name is case insensitive.
44
+ def header_values(name)
45
+ wrap_impl(@impl.header_values(unwrap_impl(name)))
46
+ end
47
+
25
48
  # Returns the JSON representation of response body.
26
49
  #
27
50
  # This method will throw if the response body is not parsable via `JSON.parse`.
@@ -76,20 +99,20 @@ module Playwright
76
99
 
77
100
  # -- inherited from EventEmitter --
78
101
  # @nodoc
79
- def once(event, callback)
80
- event_emitter_proxy.once(event, callback)
102
+ def off(event, callback)
103
+ event_emitter_proxy.off(event, callback)
81
104
  end
82
105
 
83
106
  # -- inherited from EventEmitter --
84
107
  # @nodoc
85
- def on(event, callback)
86
- event_emitter_proxy.on(event, callback)
108
+ def once(event, callback)
109
+ event_emitter_proxy.once(event, callback)
87
110
  end
88
111
 
89
112
  # -- inherited from EventEmitter --
90
113
  # @nodoc
91
- def off(event, callback)
92
- event_emitter_proxy.off(event, callback)
114
+ def on(event, callback)
115
+ event_emitter_proxy.on(event, callback)
93
116
  end
94
117
 
95
118
  private def event_emitter_proxy
@@ -58,20 +58,20 @@ module Playwright
58
58
 
59
59
  # -- inherited from EventEmitter --
60
60
  # @nodoc
61
- def once(event, callback)
62
- event_emitter_proxy.once(event, callback)
61
+ def off(event, callback)
62
+ event_emitter_proxy.off(event, callback)
63
63
  end
64
64
 
65
65
  # -- inherited from EventEmitter --
66
66
  # @nodoc
67
- def on(event, callback)
68
- event_emitter_proxy.on(event, callback)
67
+ def once(event, callback)
68
+ event_emitter_proxy.once(event, callback)
69
69
  end
70
70
 
71
71
  # -- inherited from EventEmitter --
72
72
  # @nodoc
73
- def off(event, callback)
74
- event_emitter_proxy.off(event, callback)
73
+ def on(event, callback)
74
+ event_emitter_proxy.on(event, callback)
75
75
  end
76
76
 
77
77
  private def event_emitter_proxy
@@ -6,7 +6,38 @@ module Playwright
6
6
  # An example of registering selector engine that queries elements based on a tag name:
7
7
  #
8
8
  # ```python sync
9
- # # FIXME: add snippet
9
+ # from playwright.sync_api import sync_playwright
10
+ #
11
+ # def run(playwright):
12
+ # tag_selector = """
13
+ # {
14
+ # // Returns the first element matching given selector in the root's subtree.
15
+ # query(root, selector) {
16
+ # return root.querySelector(selector);
17
+ # },
18
+ # // Returns all elements matching given selector in the root's subtree.
19
+ # queryAll(root, selector) {
20
+ # return Array.from(root.querySelectorAll(selector));
21
+ # }
22
+ # }"""
23
+ #
24
+ # # Register the engine. Selectors will be prefixed with "tag=".
25
+ # playwright.selectors.register("tag", tag_selector)
26
+ # browser = playwright.chromium.launch()
27
+ # page = browser.new_page()
28
+ # page.set_content('<div><button>Click me</button></div>')
29
+ #
30
+ # # Use the selector prefixed with its name.
31
+ # button = page.query_selector('tag=button')
32
+ # # Combine it with other selector engines.
33
+ # page.click('tag=div >> text="Click me"')
34
+ # # Can use it in any methods supporting selectors.
35
+ # button_count = page.eval_on_selector_all('tag=button', 'buttons => buttons.length')
36
+ # print(button_count)
37
+ # browser.close()
38
+ #
39
+ # with sync_playwright() as playwright:
40
+ # run(playwright)
10
41
  # ```
11
42
  def register(name, contentScript: nil, path: nil, script: nil)
12
43
  wrap_impl(@impl.register(unwrap_impl(name), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path), script: unwrap_impl(script)))
@@ -14,20 +45,20 @@ module Playwright
14
45
 
15
46
  # -- inherited from EventEmitter --
16
47
  # @nodoc
17
- def once(event, callback)
18
- event_emitter_proxy.once(event, callback)
48
+ def off(event, callback)
49
+ event_emitter_proxy.off(event, callback)
19
50
  end
20
51
 
21
52
  # -- inherited from EventEmitter --
22
53
  # @nodoc
23
- def on(event, callback)
24
- event_emitter_proxy.on(event, callback)
54
+ def once(event, callback)
55
+ event_emitter_proxy.once(event, callback)
25
56
  end
26
57
 
27
58
  # -- inherited from EventEmitter --
28
59
  # @nodoc
29
- def off(event, callback)
30
- event_emitter_proxy.off(event, callback)
60
+ def on(event, callback)
61
+ event_emitter_proxy.on(event, callback)
31
62
  end
32
63
 
33
64
  private def event_emitter_proxy
@@ -1,13 +1,14 @@
1
1
  module Playwright
2
- # API for collecting and saving Playwright traces. Playwright traces can be opened using the Playwright CLI after
3
- # Playwright script runs.
2
+ # API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](./trace-viewer.md)
3
+ # after Playwright script runs.
4
4
  #
5
- # Start with specifying the folder traces will be stored in:
5
+ # Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
6
6
  #
7
7
  # ```python sync
8
8
  # browser = chromium.launch()
9
9
  # context = browser.new_context()
10
10
  # context.tracing.start(screenshots=True, snapshots=True)
11
+ # page = context.new_page()
11
12
  # page.goto("https://playwright.dev")
12
13
  # context.tracing.stop(path = "trace.zip")
13
14
  # ```
@@ -17,17 +18,45 @@ module Playwright
17
18
  #
18
19
  # ```python sync
19
20
  # context.tracing.start(name="trace", screenshots=True, snapshots=True)
21
+ # page = context.new_page()
20
22
  # page.goto("https://playwright.dev")
21
- # context.tracing.stop()
22
23
  # context.tracing.stop(path = "trace.zip")
23
24
  # ```
24
25
  def start(name: nil, screenshots: nil, snapshots: nil)
25
26
  wrap_impl(@impl.start(name: unwrap_impl(name), screenshots: unwrap_impl(screenshots), snapshots: unwrap_impl(snapshots)))
26
27
  end
27
28
 
29
+ # Start a new trace chunk. If you'd like to record multiple traces on the same `BrowserContext`, use
30
+ # [`method: Tracing.start`] once, and then create multiple trace chunks with [`method: Tracing.startChunk`] and
31
+ # [`method: Tracing.stopChunk`].
32
+ #
33
+ # ```python sync
34
+ # context.tracing.start(name="trace", screenshots=True, snapshots=True)
35
+ # page = context.new_page()
36
+ # page.goto("https://playwright.dev")
37
+ #
38
+ # context.tracing.start_chunk()
39
+ # page.click("text=Get Started")
40
+ # # Everything between start_chunk and stop_chunk will be recorded in the trace.
41
+ # context.tracing.stop_chunk(path = "trace1.zip")
42
+ #
43
+ # context.tracing.start_chunk()
44
+ # page.goto("http://example.com")
45
+ # # Save a second trace file with different actions.
46
+ # context.tracing.stop_chunk(path = "trace2.zip")
47
+ # ```
48
+ def start_chunk
49
+ wrap_impl(@impl.start_chunk)
50
+ end
51
+
28
52
  # Stop tracing.
29
53
  def stop(path: nil)
30
54
  wrap_impl(@impl.stop(path: unwrap_impl(path)))
31
55
  end
56
+
57
+ # Stop the trace chunk. See [`method: Tracing.startChunk`] for more details about multiple trace chunks.
58
+ def stop_chunk(path: nil)
59
+ wrap_impl(@impl.stop_chunk(path: unwrap_impl(path)))
60
+ end
32
61
  end
33
62
  end