playwright-ruby-client 1.15.beta1 → 1.15.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -14
  3. data/documentation/docs/api/browser.md +2 -0
  4. data/documentation/docs/api/browser_context.md +5 -1
  5. data/documentation/docs/api/browser_type.md +1 -0
  6. data/documentation/docs/api/element_handle.md +27 -1
  7. data/documentation/docs/api/experimental/android_device.md +1 -0
  8. data/documentation/docs/api/frame.md +28 -0
  9. data/documentation/docs/api/locator.md +29 -0
  10. data/documentation/docs/api/page.md +35 -2
  11. data/documentation/docs/api/request.md +27 -1
  12. data/documentation/docs/api/response.md +18 -1
  13. data/documentation/docs/api/tracing.md +42 -8
  14. data/documentation/docs/article/getting_started.md +10 -1
  15. data/documentation/docs/article/guides/download_playwright_driver.md +9 -0
  16. data/documentation/docs/article/guides/inspector.md +1 -1
  17. data/documentation/docs/article/guides/playwright_on_alpine_linux.md +56 -3
  18. data/documentation/docs/article/guides/rails_integration.md +4 -2
  19. data/documentation/docs/article/guides/rails_integration_with_null_driver.md +86 -0
  20. data/documentation/docs/article/guides/recording_video.md +1 -1
  21. data/documentation/docs/article/guides/semi_automation.md +1 -1
  22. data/documentation/docs/article/guides/use_storage_state.md +1 -1
  23. data/documentation/docs/include/api_coverage.md +11 -0
  24. data/documentation/docusaurus.config.js +1 -0
  25. data/documentation/package.json +2 -2
  26. data/documentation/src/pages/index.js +0 -1
  27. data/documentation/static/img/playwright-ruby-client.png +0 -0
  28. data/documentation/yarn.lock +625 -549
  29. data/lib/playwright/channel.rb +36 -2
  30. data/lib/playwright/channel_owners/artifact.rb +6 -2
  31. data/lib/playwright/channel_owners/browser.rb +4 -0
  32. data/lib/playwright/channel_owners/browser_context.rb +21 -14
  33. data/lib/playwright/channel_owners/element_handle.rb +10 -2
  34. data/lib/playwright/channel_owners/frame.rb +8 -0
  35. data/lib/playwright/channel_owners/page.rb +20 -4
  36. data/lib/playwright/channel_owners/request.rb +38 -17
  37. data/lib/playwright/channel_owners/response.rb +41 -5
  38. data/lib/playwright/connection.rb +5 -3
  39. data/lib/playwright/http_headers.rb +9 -4
  40. data/lib/playwright/locator_impl.rb +8 -0
  41. data/lib/playwright/{route_handler_entry.rb → route_handler.rb} +30 -2
  42. data/lib/playwright/tracing_impl.rb +18 -7
  43. data/lib/playwright/transport.rb +2 -0
  44. data/lib/playwright/utils.rb +8 -0
  45. data/lib/playwright/version.rb +1 -1
  46. data/lib/playwright/web_socket_transport.rb +2 -0
  47. data/lib/playwright.rb +1 -1
  48. data/lib/playwright_api/android.rb +6 -6
  49. data/lib/playwright_api/android_device.rb +10 -9
  50. data/lib/playwright_api/browser.rb +10 -8
  51. data/lib/playwright_api/browser_context.rb +12 -8
  52. data/lib/playwright_api/browser_type.rb +8 -7
  53. data/lib/playwright_api/cdp_session.rb +6 -6
  54. data/lib/playwright_api/console_message.rb +6 -6
  55. data/lib/playwright_api/dialog.rb +6 -6
  56. data/lib/playwright_api/element_handle.rb +31 -8
  57. data/lib/playwright_api/frame.rb +31 -6
  58. data/lib/playwright_api/js_handle.rb +6 -6
  59. data/lib/playwright_api/locator.rb +26 -0
  60. data/lib/playwright_api/page.rb +40 -10
  61. data/lib/playwright_api/playwright.rb +6 -6
  62. data/lib/playwright_api/request.rb +26 -4
  63. data/lib/playwright_api/response.rb +20 -4
  64. data/lib/playwright_api/route.rb +6 -6
  65. data/lib/playwright_api/selectors.rb +6 -6
  66. data/lib/playwright_api/tracing.rb +33 -4
  67. data/lib/playwright_api/web_socket.rb +6 -6
  68. data/lib/playwright_api/worker.rb +8 -8
  69. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae7bd712526c9e50089204c128fc6aff20ff430e2f58d04faea66d429ab53357
4
- data.tar.gz: 95cb87802b32b1ce4487f6bc7a0fe897c5cdf285cef09700dc9472b8caea46d1
3
+ metadata.gz: 2247f39a5fa4881e45ad884606295d7003b3e42ca9db5436b223d921649e5553
4
+ data.tar.gz: f7f57d5044c66e300912578faa1d8114ee98f2eb1de736eac3da698e7851b9d6
5
5
  SHA512:
6
- metadata.gz: b6854306d49f2bdf5a2f51bcfc639297043a52d9f0c38b3eb1b8db3931462cd98c42f0d45a35867352dccce25637efcc414b5c14edfe9d332c176d10a9fe9723
7
- data.tar.gz: 4e1e89f99491cb4d2cc3ef1092b5a95fcd7486b2b19cd45dcc01d2d25ac5884c4ab6ba956172f41017561aee74013c2902ac787d0d5a1d6b71ef5eacf8740056
6
+ metadata.gz: 86b2003368d06755bfef64cebe40c716ef9d0156d6bd21f18fddc79cef07ffee5a48f562294c32b956dd664b5480326587736ee56334c76e80e8a8e2b89dfb72
7
+ data.tar.gz: 20697ed55fb7ce54856d04dc0f9568316d5941b0b103ce5c0138e680a28aeda1b7876a3cf4d358f006a2b5d7115a267ed8e7c689064bf54f65e6797848d69a2f
data/README.md CHANGED
@@ -6,19 +6,13 @@
6
6
 
7
7
  ## Getting Started
8
8
 
9
- At this point, playwright-ruby-client doesn't include the downloader of playwright driver, so **we have to install [playwright](https://github.com/microsoft/playwright) in advance**.
10
-
11
- ```sh
12
- npx playwright install
9
+ ```
10
+ gem 'playwright-ruby-client'
13
11
  ```
14
12
 
15
- and then, set `playwright_cli_executable_path: "npx playwright"` at `Playwright.create`.
16
-
17
- **Prefer npm install instead of npx?**
18
-
19
- Actually `npx playwright` is a bit slow. We can also use `npm install` to setup.
13
+ and then 'bundle install'.
20
14
 
21
- Instead of `npx playwright install`:
15
+ Since playwright-ruby-client doesn't include the playwright driver, **we have to install [playwright](https://github.com/microsoft/playwright) in advance**.
22
16
 
23
17
  ```
24
18
  npm install playwright
@@ -29,14 +23,14 @@ And set `playwright_cli_executable_path: './node_modules/.bin/playwright'`
29
23
 
30
24
  **Prefer playwrighting without Node.js?**
31
25
 
32
- Instead of npm, you can also directly download playwright driver from playwright.azureedge.net/builds/. The URL can be easily detected from [here](https://github.com/microsoft/playwright-python/blob/79f6ce0a6a69c480573372706df84af5ef99c4a4/setup.py#L56-L61)
26
+ Instead of npm, you can also directly download playwright driver from playwright.azureedge.net/builds/. The URL can be easily detected from [here](https://github.com/microsoft/playwright-python/blob/cb5409934629adaabc0cff1891080de2052fa778/setup.py#L73-L77)
33
27
 
34
28
  ### Capture a site
35
29
 
36
30
  ```ruby
37
31
  require 'playwright'
38
32
 
39
- Playwright.create(playwright_cli_executable_path: 'npx playwright') do |playwright|
33
+ Playwright.create(playwright_cli_executable_path: './node_modules/.bin/playwright') do |playwright|
40
34
  playwright.chromium.launch(headless: false) do |browser|
41
35
  page = browser.new_page
42
36
  page.goto('https://github.com/YusukeIwaki')
@@ -52,7 +46,7 @@ end
52
46
  ```ruby
53
47
  require 'playwright'
54
48
 
55
- Playwright.create(playwright_cli_executable_path: 'npx playwright') do |playwright|
49
+ Playwright.create(playwright_cli_executable_path: './node_modules/.bin/playwright') do |playwright|
56
50
  playwright.chromium.launch(headless: false) do |browser|
57
51
  page = browser.new_page
58
52
  page.goto('https://github.com/')
@@ -94,7 +88,7 @@ $ bundle exec ruby main.rb
94
88
  ```ruby
95
89
  require 'playwright'
96
90
 
97
- Playwright.create(playwright_cli_executable_path: 'npx playwright') do |playwright|
91
+ Playwright.create(playwright_cli_executable_path: './node_modules/.bin/playwright') do |playwright|
98
92
  devices = playwright.android.devices
99
93
  unless devices.empty?
100
94
  device = devices.last
@@ -185,6 +179,8 @@ end
185
179
 
186
180
  When `Playwright.connect_to_playwright_server` is used, playwright_cli_executable_path is not required.
187
181
 
182
+ For more detailed instraction, refer this article: https://playwright-ruby-client.vercel.app/docs/article/guides/playwright_on_alpine_linux
183
+
188
184
  ## License
189
185
 
190
186
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -81,6 +81,7 @@ def new_context(
81
81
  colorScheme: nil,
82
82
  deviceScaleFactor: nil,
83
83
  extraHTTPHeaders: nil,
84
+ forcedColors: nil,
84
85
  geolocation: nil,
85
86
  hasTouch: nil,
86
87
  httpCredentials: nil,
@@ -131,6 +132,7 @@ def new_page(
131
132
  colorScheme: nil,
132
133
  deviceScaleFactor: nil,
133
134
  extraHTTPHeaders: nil,
135
+ forcedColors: nil,
134
136
  geolocation: nil,
135
137
  hasTouch: nil,
136
138
  httpCredentials: nil,
@@ -265,12 +265,16 @@ Returns all open pages in the context.
265
265
  ## route
266
266
 
267
267
  ```
268
- def route(url, handler)
268
+ def route(url, handler, times: nil)
269
269
  ```
270
270
 
271
271
  Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
272
272
  is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
273
273
 
274
+ > NOTE: [Page#route](./page#route) will not intercept requests intercepted by Service Worker. See
275
+ [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
276
+ request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);`
277
+
274
278
  An example of a naive handler that aborts all image requests:
275
279
 
276
280
  ```ruby
@@ -114,6 +114,7 @@ def launch_persistent_context(
114
114
  env: nil,
115
115
  executablePath: nil,
116
116
  extraHTTPHeaders: nil,
117
+ forcedColors: nil,
117
118
  geolocation: nil,
118
119
  handleSIGHUP: nil,
119
120
  handleSIGINT: nil,
@@ -510,6 +510,32 @@ def select_text(force: nil, timeout: nil)
510
510
  This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then focuses the element and selects all its text
511
511
  content.
512
512
 
513
+ ## set_checked
514
+
515
+ ```
516
+ def set_checked(
517
+ checked,
518
+ force: nil,
519
+ noWaitAfter: nil,
520
+ position: nil,
521
+ timeout: nil,
522
+ trial: nil)
523
+ ```
524
+ alias: `checked=`
525
+
526
+ This method checks or unchecks an element by performing the following steps:
527
+ 1. Ensure that element is a checkbox or a radio input. If not, this method throws.
528
+ 1. If the element already has the right checked state, this method returns immediately.
529
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
530
+ element is detached during the checks, the whole action is retried.
531
+ 1. Scroll the element into view if needed.
532
+ 1. Use [Page#mouse](./page#mouse) to click in the center of the element.
533
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
534
+ 1. Ensure that the element is now checked or unchecked. If not, this method throws.
535
+
536
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
537
+ zero timeout disables this.
538
+
513
539
  ## set_input_files
514
540
 
515
541
  ```
@@ -630,7 +656,7 @@ If the element does not satisfy the condition for the `timeout` milliseconds, th
630
656
  ## wait_for_selector
631
657
 
632
658
  ```
633
- def wait_for_selector(selector, state: nil, timeout: nil)
659
+ def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
634
660
  ```
635
661
 
636
662
  Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or
@@ -34,6 +34,7 @@ def launch_browser(
34
34
  command: nil,
35
35
  deviceScaleFactor: nil,
36
36
  extraHTTPHeaders: nil,
37
+ forcedColors: nil,
37
38
  geolocation: nil,
38
39
  hasTouch: nil,
39
40
  httpCredentials: nil,
@@ -649,6 +649,34 @@ frame.select_option("select#colors", value: ["red", "green", "blue"])
649
649
 
650
650
 
651
651
 
652
+ ## set_checked
653
+
654
+ ```
655
+ def set_checked(
656
+ selector,
657
+ checked,
658
+ force: nil,
659
+ noWaitAfter: nil,
660
+ position: nil,
661
+ strict: nil,
662
+ timeout: nil,
663
+ trial: nil)
664
+ ```
665
+
666
+ This method checks or unchecks an element matching `selector` by performing the following steps:
667
+ 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
668
+ 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
669
+ 1. If the element already has the right checked state, this method returns immediately.
670
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
671
+ element is detached during the checks, the whole action is retried.
672
+ 1. Scroll the element into view if needed.
673
+ 1. Use [Page#mouse](./page#mouse) to click in the center of the element.
674
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
675
+ 1. Ensure that the element is now checked or unchecked. If not, this method throws.
676
+
677
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
678
+ zero timeout disables this.
679
+
652
680
  ## set_content
653
681
 
654
682
  ```
@@ -45,6 +45,9 @@ page.locator('button').click
45
45
 
46
46
  # Works because we explicitly tell locator to pick the first element:
47
47
  page.locator('button').first.click
48
+
49
+ # Works because count knows what to do with multiple matches:
50
+ page.locator('button').count
48
51
  ```
49
52
 
50
53
 
@@ -553,6 +556,32 @@ def select_text(force: nil, timeout: nil)
553
556
  This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, then focuses the element and selects all its text
554
557
  content.
555
558
 
559
+ ## set_checked
560
+
561
+ ```
562
+ def set_checked(
563
+ checked,
564
+ force: nil,
565
+ noWaitAfter: nil,
566
+ position: nil,
567
+ timeout: nil,
568
+ trial: nil)
569
+ ```
570
+ alias: `checked=`
571
+
572
+ This method checks or unchecks an element by performing the following steps:
573
+ 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
574
+ 1. If the element already has the right checked state, this method returns immediately.
575
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
576
+ element is detached during the checks, the whole action is retried.
577
+ 1. Scroll the element into view if needed.
578
+ 1. Use [Page#mouse](./page#mouse) to click in the center of the element.
579
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
580
+ 1. Ensure that the element is now checked or unchecked. If not, this method throws.
581
+
582
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
583
+ zero timeout disables this.
584
+
556
585
  ## set_input_files
557
586
 
558
587
  ```
@@ -281,7 +281,7 @@ def drag_and_drop(
281
281
  ## emulate_media
282
282
 
283
283
  ```
284
- def emulate_media(colorScheme: nil, media: nil, reducedMotion: nil)
284
+ def emulate_media(colorScheme: nil, forcedColors: nil, media: nil, reducedMotion: nil)
285
285
  ```
286
286
 
287
287
  This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media
@@ -933,7 +933,7 @@ last redirect.
933
933
  ## route
934
934
 
935
935
  ```
936
- def route(url, handler)
936
+ def route(url, handler, times: nil)
937
937
  ```
938
938
 
939
939
  Routing provides the capability to modify network requests that are made by a page.
@@ -941,6 +941,9 @@ Routing provides the capability to modify network requests that are made by a pa
941
941
  Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
942
942
 
943
943
  > NOTE: The handler will only be called for the first url if the response is a redirect.
944
+ > NOTE: [Page#route](./page#route) will not intercept requests intercepted by Service Worker. See
945
+ [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
946
+ request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);`
944
947
 
945
948
  An example of a naive handler that aborts all image requests:
946
949
 
@@ -1030,6 +1033,36 @@ page.select_option("select#colors", value: ["red", "green", "blue"])
1030
1033
 
1031
1034
  Shortcut for main frame's [Frame#select_option](./frame#select_option).
1032
1035
 
1036
+ ## set_checked
1037
+
1038
+ ```
1039
+ def set_checked(
1040
+ selector,
1041
+ checked,
1042
+ force: nil,
1043
+ noWaitAfter: nil,
1044
+ position: nil,
1045
+ strict: nil,
1046
+ timeout: nil,
1047
+ trial: nil)
1048
+ ```
1049
+
1050
+ This method checks or unchecks an element matching `selector` by performing the following steps:
1051
+ 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
1052
+ 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
1053
+ 1. If the element already has the right checked state, this method returns immediately.
1054
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
1055
+ element is detached during the checks, the whole action is retried.
1056
+ 1. Scroll the element into view if needed.
1057
+ 1. Use [Page#mouse](./page#mouse) to click in the center of the element.
1058
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
1059
+ 1. Ensure that the element is now checked or unchecked. If not, this method throws.
1060
+
1061
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
1062
+ zero timeout disables this.
1063
+
1064
+ Shortcut for main frame's [Frame#set_checked](./frame#set_checked).
1065
+
1033
1066
  ## set_content
1034
1067
 
1035
1068
  ```
@@ -18,6 +18,14 @@ complete with `'requestfinished'` event.
18
18
  If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new
19
19
  request is issued to a redirected url.
20
20
 
21
+ ## all_headers
22
+
23
+ ```
24
+ def all_headers
25
+ ```
26
+
27
+ An object with all the request HTTP headers associated with this request. The header names are lower-cased.
28
+
21
29
  ## failure
22
30
 
23
31
  ```
@@ -48,7 +56,16 @@ Returns the [Frame](./frame) that initiated this request.
48
56
  def headers
49
57
  ```
50
58
 
51
- An object with HTTP headers associated with the request. All header names are lower-case.
59
+ **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [Request#all_headers](./request#all_headers) instead.
60
+
61
+ ## headers_array
62
+
63
+ ```
64
+ def headers_array
65
+ ```
66
+
67
+ An array with all the request HTTP headers associated with this request. Unlike [Request#all_headers](./request#all_headers), header
68
+ names are not lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
52
69
 
53
70
  ## navigation_request?
54
71
 
@@ -156,6 +173,15 @@ def response
156
173
 
157
174
  Returns the matching [Response](./response) object, or `null` if the response was not received due to error.
158
175
 
176
+ ## sizes
177
+
178
+ ```
179
+ def sizes
180
+ ```
181
+
182
+ Returns resource size information for given request. Requires the response to be finished via
183
+ [Response#finished](./response#finished) to ensure the info is available.
184
+
159
185
  ## timing
160
186
 
161
187
  ```
@@ -6,6 +6,14 @@ sidebar_position: 10
6
6
 
7
7
  [Response](./response) class represents responses which are received by page.
8
8
 
9
+ ## all_headers
10
+
11
+ ```
12
+ def all_headers
13
+ ```
14
+
15
+ An object with all the response HTTP headers associated with this response.
16
+
9
17
  ## body
10
18
 
11
19
  ```
@@ -36,7 +44,16 @@ Returns the [Frame](./frame) that initiated this response.
36
44
  def headers
37
45
  ```
38
46
 
39
- Returns the object with HTTP headers associated with the response. All header names are lower-case.
47
+ **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [Response#all_headers](./response#all_headers) instead.
48
+
49
+ ## headers_array
50
+
51
+ ```
52
+ def headers_array
53
+ ```
54
+
55
+ An array with all the request HTTP headers associated with this response. Unlike [Response#all_headers](./response#all_headers), header
56
+ names are not lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
40
57
 
41
58
  ## json
42
59
 
@@ -4,16 +4,15 @@ sidebar_position: 10
4
4
 
5
5
  # Tracing
6
6
 
7
- API for collecting and saving Playwright traces. Playwright traces can be opened using the Playwright CLI after
8
- Playwright script runs.
7
+ API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](https://playwright.dev/python/docs/trace-viewer)
8
+ after Playwright script runs.
9
9
 
10
- Start with specifying the folder traces will be stored in:
10
+ Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
11
11
 
12
12
  ```ruby
13
- browser.new_page do |page|
14
- context = page.context
15
-
13
+ browser.new_context do |context|
16
14
  context.tracing.start(screenshots: true, snapshots: true)
15
+ page = context.new_page
17
16
  page.goto('https://playwright.dev')
18
17
  context.tracing.stop(path: 'trace.zip')
19
18
  end
@@ -30,15 +29,42 @@ def start(name: nil, screenshots: nil, snapshots: nil)
30
29
  Start tracing.
31
30
 
32
31
  ```ruby
33
- context = page.context
34
-
35
32
  context.tracing.start(name: 'trace', screenshots: true, snapshots: true)
33
+ page = context.new_page
36
34
  page.goto('https://playwright.dev')
37
35
  context.tracing.stop(path: 'trace.zip')
38
36
  ```
39
37
 
40
38
 
41
39
 
40
+ ## start_chunk
41
+
42
+ ```
43
+ def start_chunk
44
+ ```
45
+
46
+ Start a new trace chunk. If you'd like to record multiple traces on the same [BrowserContext](./browser_context), use
47
+ [Tracing#start](./tracing#start) once, and then create multiple trace chunks with [Tracing#start_chunk](./tracing#start_chunk) and
48
+ [Tracing#stop_chunk](./tracing#stop_chunk).
49
+
50
+ ```ruby
51
+ context.tracing.start(name: "trace", screenshots: true, snapshots: true)
52
+ page = context.new_page
53
+ page.goto("https://playwright.dev")
54
+
55
+ context.tracing.start_chunk
56
+ page.click("text=Get Started")
57
+ # Everything between start_chunk and stop_chunk will be recorded in the trace.
58
+ context.tracing.stop_chunk(path: "trace1.zip")
59
+
60
+ context.tracing.start_chunk
61
+ page.goto("http://example.com")
62
+ # Save a second trace file with different actions.
63
+ context.tracing.stop_chunk(path: "trace2.zip")
64
+ ```
65
+
66
+
67
+
42
68
  ## stop
43
69
 
44
70
  ```
@@ -46,3 +72,11 @@ def stop(path: nil)
46
72
  ```
47
73
 
48
74
  Stop tracing.
75
+
76
+ ## stop_chunk
77
+
78
+ ```
79
+ def stop_chunk(path: nil)
80
+ ```
81
+
82
+ Stop the trace chunk. See [Tracing#start_chunk](./tracing#start_chunk) for more details about multiple trace chunks.