playwright-ruby-client 1.59.1 → 1.60.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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/api_request.md +25 -1
  3. data/documentation/docs/api/api_request_context.md +13 -11
  4. data/documentation/docs/api/browser.md +18 -0
  5. data/documentation/docs/api/browser_context.md +1 -1
  6. data/documentation/docs/api/browser_type.md +18 -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 +37 -2
  10. data/documentation/docs/api/locator_assertions.md +1 -1
  11. data/documentation/docs/api/page.md +12 -2
  12. data/documentation/docs/api/page_assertions.md +28 -0
  13. data/documentation/docs/api/playwright.md +5 -0
  14. data/documentation/docs/api/tracing.md +29 -0
  15. data/documentation/docs/include/api_coverage.md +14 -60
  16. data/lib/playwright/api_request_impl.rb +70 -0
  17. data/lib/playwright/channel_owners/api_request_context.rb +5 -1
  18. data/lib/playwright/channel_owners/binding_call.rb +3 -9
  19. data/lib/playwright/channel_owners/browser.rb +17 -0
  20. data/lib/playwright/channel_owners/browser_context.rb +10 -54
  21. data/lib/playwright/channel_owners/browser_type.rb +34 -1
  22. data/lib/playwright/channel_owners/frame.rb +89 -3
  23. data/lib/playwright/channel_owners/json_pipe.rb +4 -0
  24. data/lib/playwright/channel_owners/local_utils.rb +11 -2
  25. data/lib/playwright/channel_owners/page.rb +16 -11
  26. data/lib/playwright/channel_owners/playwright.rb +4 -0
  27. data/lib/playwright/channel_owners/tracing.rb +105 -4
  28. data/lib/playwright/connection.rb +5 -1
  29. data/lib/playwright/console_message_impl.rb +10 -1
  30. data/lib/playwright/errors.rb +3 -2
  31. data/lib/playwright/events.rb +7 -0
  32. data/lib/playwright/json_pipe_transport.rb +40 -0
  33. data/lib/playwright/locator_assertions_impl.rb +21 -4
  34. data/lib/playwright/locator_impl.rb +17 -3
  35. data/lib/playwright/locator_utils.rb +2 -0
  36. data/lib/playwright/page_assertions_impl.rb +33 -3
  37. data/lib/playwright/screencast.rb +5 -1
  38. data/lib/playwright/url_matcher.rb +35 -0
  39. data/lib/playwright/version.rb +2 -2
  40. data/lib/playwright.rb +1 -0
  41. data/lib/playwright_api/api_request.rb +1 -1
  42. data/lib/playwright_api/api_request_context.rb +15 -11
  43. data/lib/playwright_api/browser.rb +2 -2
  44. data/lib/playwright_api/browser_context.rb +7 -7
  45. data/lib/playwright_api/browser_type.rb +5 -3
  46. data/lib/playwright_api/frame.rb +18 -7
  47. data/lib/playwright_api/frame_locator.rb +2 -1
  48. data/lib/playwright_api/locator.rb +34 -5
  49. data/lib/playwright_api/locator_assertions.rb +2 -2
  50. data/lib/playwright_api/page.rb +27 -20
  51. data/lib/playwright_api/page_assertions.rb +22 -0
  52. data/lib/playwright_api/playwright.rb +1 -1
  53. data/lib/playwright_api/tracing.rb +23 -0
  54. data/sig/playwright.rbs +35 -43
  55. metadata +5 -12
  56. data/documentation/docs/api/experimental/android.md +0 -42
  57. data/documentation/docs/api/experimental/android_device.md +0 -109
  58. data/documentation/docs/api/experimental/android_input.md +0 -43
  59. data/documentation/docs/api/experimental/android_socket.md +0 -7
  60. data/documentation/docs/api/experimental/android_web_view.md +0 -7
  61. data/lib/playwright_api/android.rb +0 -68
  62. data/lib/playwright_api/android_device.rb +0 -229
  63. data/lib/playwright_api/android_input.rb +0 -34
  64. data/lib/playwright_api/android_socket.rb +0 -18
  65. data/lib/playwright_api/android_web_view.rb +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8943d61bb3cd1ebe3737284e7556d8bcb4b1be154105c2bb05f8d8d77ba51aca
4
- data.tar.gz: 15fdc15c33208bb8389306733807768797038d7a788c9f3e5f7465680823ebb7
3
+ metadata.gz: ac9256b441d66c5a19585735b23567b6dc1eedca695812ee3388f48918054970
4
+ data.tar.gz: 9a13c1dcfc540d7bc1120743af1806a338185a2bd6eb41331e2273425af790c6
5
5
  SHA512:
6
- metadata.gz: 1787fb9a9b61c92bb3cb0adc512e18349ae2830d59914e6ac6c202361b849d20e0c09f3fef4ecfa250b90e6858ce60a381c3fe76fcb3c96fd9b42ccf548d26e0
7
- data.tar.gz: b72617a5d25b592c8e3a8d54dc887a56776448be204cc7d1e901145d449b3aadca42090010978c547c8e8e1cc1f0418415624008cd60122eea3a41a4d76c1af8
6
+ metadata.gz: f8fae6bb376c4586a90464a2db4d06b3362a822d191456dcf5ad75f74ae67ed99462403aa4cdca4d817eb58d59ec30380a9b72c5d6cee2f5475a0fda4e2c05a8
7
+ data.tar.gz: b59cc6913b92826850611eab5967f72c2545549f2ac83c8268d59d6ef61152523a1fcb62759278487661369449a817222ecd514a0c066ea913b3e4607a4b0463
@@ -4,4 +4,28 @@ sidebar_position: 10
4
4
 
5
5
  # APIRequest
6
6
 
7
- Not Implemented
7
+
8
+ Exposes API that can be used for the Web API testing. This class is used for creating
9
+ [APIRequestContext](./api_request_context) instance which in turn can be used for sending web requests. An instance
10
+ of this class can be obtained via [Playwright#request](./playwright#request). For more information
11
+ see [APIRequestContext](./api_request_context).
12
+
13
+ ## new_context
14
+
15
+ ```
16
+ def new_context(
17
+ baseURL: nil,
18
+ clientCertificates: nil,
19
+ extraHTTPHeaders: nil,
20
+ failOnStatusCode: nil,
21
+ httpCredentials: nil,
22
+ ignoreHTTPSErrors: nil,
23
+ maxRedirects: nil,
24
+ proxy: nil,
25
+ storageState: nil,
26
+ timeout: nil,
27
+ userAgent: nil)
28
+ ```
29
+
30
+
31
+ Creates new instances of [APIRequestContext](./api_request_context).
@@ -8,21 +8,21 @@ sidebar_position: 10
8
8
  This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
9
9
  environment or the service to your e2e test.
10
10
 
11
- Each Playwright browser context has associated with it [APIRequestContext](./api_request_context) instance which shares cookie storage with
12
- the browser context and can be accessed via [BrowserContext#request](./browser_context#request) or [Page#request](./page#request).
13
- It is also possible to create a new APIRequestContext instance manually by calling [APIRequest#new_context](./api_request#new_context).
11
+ Each Playwright browser context has an associated [APIRequestContext](./api_request_context), accessible via
12
+ [BrowserContext#request](./browser_context#request) or [Page#request](./page#request) (these return the
13
+
14
+ **same instance** — `page.request` is a shortcut for `page.context().request`).
15
+ You can also create a standalone, isolated instance with [APIRequest#new_context](./api_request#new_context).
14
16
 
15
17
  **Cookie management**
16
18
 
17
- [APIRequestContext](./api_request_context) returned by [BrowserContext#request](./browser_context#request) and [Page#request](./page#request) shares cookie
18
- storage with the corresponding [BrowserContext](./browser_context). Each API request will have `Cookie` header populated with the
19
- values from the browser context. If the API response contains `Set-Cookie` header it will automatically update
20
- [BrowserContext](./browser_context) cookies and requests made from the page will pick them up. This means that if you log in using
21
- this API, your e2e test will be logged in and vice versa.
19
+ The [APIRequestContext](./api_request_context) returned by [BrowserContext#request](./browser_context#request) and
20
+
21
+ [Page#request](./page#request) uses the same cookie jar as its [BrowserContext](./browser_context):
22
22
 
23
- If you want API requests to not interfere with the browser cookies you should create a new [APIRequestContext](./api_request_context) by
24
- calling [APIRequest#new_context](./api_request#new_context). Such [APIRequestContext](./api_request_context) object will have its own isolated cookie
25
- storage.
23
+ If you want API requests that do **not** share cookies with the browser, create an
24
+ isolated context via [APIRequest#new_context](./api_request#new_context). Such [APIRequestContext](./api_request_context)
25
+ object will have its own isolated cookie storage.
26
26
 
27
27
  ```ruby
28
28
  playwright.chromium.launch do |browser|
@@ -296,3 +296,5 @@ def put(
296
296
  Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response.
297
297
  The method will populate request cookies from the context and update
298
298
  context cookies from the response. The method will automatically follow redirects.
299
+
300
+ ## tracing
@@ -193,6 +193,15 @@ This is a convenience API that should only be used for the single-page scenarios
193
193
  testing frameworks should explicitly create [Browser#new_context](./browser#new_context) followed by the
194
194
  [BrowserContext#new_page](./browser_context#new_page) to control their exact life times.
195
195
 
196
+ ## bind
197
+
198
+ ```
199
+ def bind(title, host: nil, port: nil, workspaceDir: nil)
200
+ ```
201
+
202
+
203
+ Binds the browser to a named pipe or web socket, making it available for other clients to connect to.
204
+
196
205
  ## start_tracing
197
206
 
198
207
  ```
@@ -227,6 +236,15 @@ def stop_tracing
227
236
 
228
237
  Returns the buffer with trace data.
229
238
 
239
+ ## unbind
240
+
241
+ ```
242
+ def unbind
243
+ ```
244
+
245
+
246
+ Unbinds the browser server previously bound with [Browser#bind](./browser#bind).
247
+
230
248
  ## version
231
249
 
232
250
  ```
@@ -154,7 +154,7 @@ are returned.
154
154
  ## expose_binding
155
155
 
156
156
  ```
157
- def expose_binding(name, callback, handle: nil)
157
+ def expose_binding(name, callback)
158
158
  ```
159
159
 
160
160
 
@@ -19,6 +19,23 @@ chromium.launch do |browser|
19
19
  end
20
20
  ```
21
21
 
22
+ ## connect
23
+
24
+ ```
25
+ def connect(
26
+ endpoint,
27
+ exposeNetwork: nil,
28
+ headers: nil,
29
+ slowMo: nil,
30
+ timeout: nil,
31
+ &block)
32
+ ```
33
+
34
+
35
+ This method attaches Playwright to an existing browser instance created via `BrowserType.launchServer` in Node.js.
36
+
37
+ **NOTE**: The major and minor version of the Playwright instance that connects needs to match the version of Playwright that launches the browser (1.2.3 → is compatible with 1.2.x).
38
+
22
39
  ## connect_over_cdp
23
40
 
24
41
  ```
@@ -26,6 +43,7 @@ def connect_over_cdp(
26
43
  endpointURL,
27
44
  headers: nil,
28
45
  isLocal: nil,
46
+ noDefaults: nil,
29
47
  slowMo: nil,
30
48
  timeout: nil,
31
49
  &block)
@@ -486,6 +486,7 @@ page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
486
486
  def get_by_role(
487
487
  role,
488
488
  checked: nil,
489
+ description: nil,
489
490
  disabled: nil,
490
491
  exact: nil,
491
492
  expanded: nil,
@@ -131,6 +131,7 @@ page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
131
131
  def get_by_role(
132
132
  role,
133
133
  checked: nil,
134
+ description: nil,
134
135
  disabled: nil,
135
136
  exact: nil,
136
137
  expanded: nil,
@@ -87,7 +87,7 @@ button = page.get_by_role("button").and(page.get_by_title("Subscribe"))
87
87
  ## aria_snapshot
88
88
 
89
89
  ```
90
- def aria_snapshot(depth: nil, mode: nil, timeout: nil)
90
+ def aria_snapshot(boxes: nil, depth: nil, mode: nil, timeout: nil)
91
91
  ```
92
92
 
93
93
 
@@ -441,6 +441,31 @@ source.drag_to(
441
441
  )
442
442
  ```
443
443
 
444
+ ## drop
445
+
446
+ ```
447
+ def drop(payload, position: nil, timeout: nil)
448
+ ```
449
+
450
+
451
+ Simulate an external drag-and-drop of files or clipboard-like data onto this locator.
452
+
453
+ **Details**
454
+
455
+ Dispatches the native `dragenter`, `dragover`, and `drop` events at the center of the
456
+ target element with a synthetic [DataTransfer] carrying the provided files and/or data
457
+ entries. Works cross-browser by constructing the [DataTransfer] in the page context.
458
+
459
+ If the target element's `dragover` listener does not call `preventDefault()`, the target
460
+ is considered to have rejected the drop: Playwright dispatches `dragleave` and this
461
+ method throws.
462
+
463
+ **Usage**
464
+
465
+ Drop a file buffer onto an upload area:
466
+
467
+ Drop plain text and a URL together:
468
+
444
469
  ## element_handle
445
470
 
446
471
  ```
@@ -721,6 +746,7 @@ page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
721
746
  def get_by_role(
722
747
  role,
723
748
  checked: nil,
749
+ description: nil,
724
750
  disabled: nil,
725
751
  exact: nil,
726
752
  expanded: nil,
@@ -869,10 +895,19 @@ You can check the issues count after locating it by the title text:
869
895
  page.get_by_title("Issues count").text_content # => "25 issues"
870
896
  ```
871
897
 
898
+ ## hide_highlight
899
+
900
+ ```
901
+ def hide_highlight
902
+ ```
903
+
904
+
905
+ Hides the element highlight previously added by [Locator#highlight](./locator#highlight).
906
+
872
907
  ## highlight
873
908
 
874
909
  ```
875
- def highlight
910
+ def highlight(style: nil)
876
911
  ```
877
912
 
878
913
 
@@ -647,7 +647,7 @@ expect(locator).to have_count(3)
647
647
  ## to_have_css
648
648
 
649
649
  ```ruby
650
- expect(locator).to have_css(name, value, timeout: nil)
650
+ expect(locator).to have_css(name, value, pseudo: nil, timeout: nil)
651
651
  ```
652
652
 
653
653
 
@@ -457,7 +457,7 @@ result_handle.dispose
457
457
  ## expose_binding
458
458
 
459
459
  ```
460
- def expose_binding(name, callback, handle: nil)
460
+ def expose_binding(name, callback)
461
461
  ```
462
462
 
463
463
 
@@ -690,6 +690,7 @@ page.get_by_placeholder("name@example.com").fill("playwright@microsoft.com")
690
690
  def get_by_role(
691
691
  role,
692
692
  checked: nil,
693
+ description: nil,
693
694
  disabled: nil,
694
695
  exact: nil,
695
696
  expanded: nil,
@@ -889,6 +890,15 @@ Found" and 500 "Internal Server Error". The status code for such responses can
889
890
  **NOTE**: Headless mode doesn't support navigation to a PDF document. See the
890
891
  [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
891
892
 
893
+ ## hide_highlight
894
+
895
+ ```
896
+ def hide_highlight
897
+ ```
898
+
899
+
900
+ Hide all locator highlight overlays previously added by [Locator#highlight](./locator#highlight) on this page.
901
+
892
902
  ## hover
893
903
 
894
904
  ```
@@ -1521,7 +1531,7 @@ page.goto("https://example.com")
1521
1531
  ## aria_snapshot
1522
1532
 
1523
1533
  ```
1524
- def aria_snapshot(depth: nil, mode: nil, timeout: nil)
1534
+ def aria_snapshot(boxes: nil, depth: nil, mode: nil, timeout: nil)
1525
1535
  ```
1526
1536
 
1527
1537
 
@@ -34,6 +34,34 @@ def not_to_have_url(urlOrRegExp, ignoreCase: nil, timeout: nil)
34
34
 
35
35
  The opposite of [PageAssertions#to_have_url](./page_assertions#to_have_url).
36
36
 
37
+ ## to_match_aria_snapshot
38
+
39
+ ```
40
+ def to_match_aria_snapshot(expected, timeout: nil)
41
+ ```
42
+
43
+
44
+ Asserts that the page body matches the given [accessibility snapshot](https://playwright.dev/python/docs/aria-snapshots).
45
+
46
+ **Usage**
47
+
48
+ ```ruby
49
+ page.goto("https://demo.playwright.dev/todomvc/")
50
+ expect(page).to match_aria_snapshot(<<~YAML)
51
+ - heading "todos"
52
+ - textbox "What needs to be done?"
53
+ YAML
54
+ ```
55
+
56
+ ## not_to_match_aria_snapshot
57
+
58
+ ```
59
+ def not_to_match_aria_snapshot(expected, timeout: nil)
60
+ ```
61
+
62
+
63
+ The opposite of [PageAssertions#to_match_aria_snapshot](./page_assertions#to_match_aria_snapshot).
64
+
37
65
  ## to_have_title
38
66
 
39
67
  ```
@@ -54,6 +54,11 @@ end
54
54
 
55
55
  This object can be used to launch or connect to Firefox, returning instances of [Browser](./browser).
56
56
 
57
+ ## request
58
+
59
+
60
+ Exposes API that can be used for the Web API testing.
61
+
57
62
  ## selectors
58
63
 
59
64
 
@@ -77,6 +77,26 @@ page.goto("http://example.com")
77
77
  context.tracing.stop_chunk(path: "trace2.zip")
78
78
  ```
79
79
 
80
+ ## start_har
81
+
82
+ ```
83
+ def start_har(path, content: nil, mode: nil, urlFilter: nil)
84
+ ```
85
+
86
+
87
+ Start recording a HAR (HTTP Archive) of network activity in this context. The HAR file is written to disk when [Tracing#stop_har](./tracing#stop_har) is called, or when the returned `Disposable` is disposed.
88
+
89
+ Only one HAR recording can be active at a time per [BrowserContext](./browser_context).
90
+
91
+ **Usage**
92
+
93
+ ```ruby
94
+ context.tracing.start_har("trace.har")
95
+ page = context.new_page
96
+ page.goto("https://playwright.dev")
97
+ context.tracing.stop_har
98
+ ```
99
+
80
100
  ## group
81
101
 
82
102
  ```
@@ -128,3 +148,12 @@ def stop_chunk(path: nil)
128
148
 
129
149
 
130
150
  Stop the trace chunk. See [Tracing#start_chunk](./tracing#start_chunk) for more details about multiple trace chunks.
151
+
152
+ ## stop_har
153
+
154
+ ```
155
+ def stop_har
156
+ ```
157
+
158
+
159
+ Stop HAR recording and save the HAR file to the path given to [Tracing#start_har](./tracing#start_har).
@@ -293,6 +293,7 @@
293
293
  * go_forward
294
294
  * ~~request_gc~~
295
295
  * goto
296
+ * hide_highlight
296
297
  * hover
297
298
  * inner_html
298
299
  * inner_text
@@ -422,15 +423,15 @@
422
423
  * new_browser_cdp_session
423
424
  * new_context
424
425
  * new_page
425
- * ~~bind~~
426
+ * bind
426
427
  * start_tracing
427
428
  * stop_tracing
428
- * ~~unbind~~
429
+ * unbind
429
430
  * version
430
431
 
431
432
  ## BrowserType
432
433
 
433
- * ~~connect~~
434
+ * connect
434
435
  * connect_over_cdp
435
436
  * executable_path
436
437
  * launch
@@ -443,7 +444,7 @@
443
444
  * chromium
444
445
  * devices
445
446
  * firefox
446
- * ~~request~~
447
+ * request
447
448
  * selectors
448
449
  * webkit
449
450
 
@@ -451,10 +452,12 @@
451
452
 
452
453
  * start
453
454
  * start_chunk
455
+ * start_har
454
456
  * group
455
457
  * group_end
456
458
  * stop
457
459
  * stop_chunk
460
+ * stop_har
458
461
 
459
462
  ## Locator
460
463
 
@@ -474,6 +477,7 @@
474
477
  * description
475
478
  * dispatch_event
476
479
  * drag_to
480
+ * drop
477
481
  * element_handle
478
482
  * element_handles
479
483
  * content_frame
@@ -493,6 +497,7 @@
493
497
  * get_by_test_id
494
498
  * get_by_text
495
499
  * get_by_title
500
+ * hide_highlight
496
501
  * highlight
497
502
  * hover
498
503
  * inner_html
@@ -564,10 +569,11 @@
564
569
  * post
565
570
  * put
566
571
  * ~~storage_state~~
572
+ * tracing
567
573
 
568
- ## ~~APIRequest~~
574
+ ## APIRequest
569
575
 
570
- * ~~new_context~~
576
+ * new_context
571
577
 
572
578
  ## LocatorAssertions
573
579
 
@@ -628,59 +634,7 @@
628
634
 
629
635
  * not_to_have_title
630
636
  * not_to_have_url
637
+ * to_match_aria_snapshot
638
+ * not_to_match_aria_snapshot
631
639
  * to_have_title
632
640
  * to_have_url
633
-
634
- ## Android
635
-
636
- * ~~connect~~
637
- * devices
638
- * set_default_timeout
639
-
640
- ## AndroidDevice
641
-
642
- * close
643
- * ~~drag~~
644
- * ~~fill~~
645
- * ~~fling~~
646
- * info
647
- * ~~install_apk~~
648
- * launch_browser
649
- * ~~long_tap~~
650
- * model
651
- * ~~open~~
652
- * ~~pinch_close~~
653
- * ~~pinch_open~~
654
- * ~~press~~
655
- * ~~push~~
656
- * screenshot
657
- * ~~scroll~~
658
- * serial
659
- * ~~set_default_timeout~~
660
- * shell
661
- * ~~swipe~~
662
- * ~~tap_point~~
663
- * ~~wait~~
664
- * ~~wait_for_event~~
665
- * ~~web_view~~
666
- * ~~web_views~~
667
- * input
668
-
669
- ## AndroidInput
670
-
671
- * drag
672
- * press
673
- * ~~swipe~~
674
- * tap_point
675
- * type
676
-
677
- ## ~~AndroidSocket~~
678
-
679
- * ~~close~~
680
- * ~~write~~
681
-
682
- ## ~~AndroidWebView~~
683
-
684
- * ~~page~~
685
- * ~~pid~~
686
- * ~~pkg~~
@@ -0,0 +1,70 @@
1
+ require 'base64'
2
+ require 'json'
3
+
4
+ module Playwright
5
+ define_api_implementation :APIRequestImpl do
6
+ def initialize(playwright)
7
+ @playwright = playwright
8
+ end
9
+
10
+ def new_context(
11
+ baseURL: nil,
12
+ clientCertificates: nil,
13
+ extraHTTPHeaders: nil,
14
+ failOnStatusCode: nil,
15
+ httpCredentials: nil,
16
+ ignoreHTTPSErrors: nil,
17
+ maxRedirects: nil,
18
+ proxy: nil,
19
+ storageState: nil,
20
+ timeout: nil,
21
+ userAgent: nil)
22
+ params = {
23
+ baseURL: baseURL,
24
+ clientCertificates: prepare_client_certificates(clientCertificates),
25
+ extraHTTPHeaders: extraHTTPHeaders ? HttpHeaders.new(extraHTTPHeaders).as_serialized : nil,
26
+ failOnStatusCode: failOnStatusCode,
27
+ httpCredentials: httpCredentials,
28
+ ignoreHTTPSErrors: ignoreHTTPSErrors,
29
+ maxRedirects: maxRedirects,
30
+ proxy: proxy,
31
+ storageState: prepare_storage_state(storageState),
32
+ timeout: timeout,
33
+ userAgent: userAgent,
34
+ }.compact
35
+
36
+ result = @playwright.channel.send_message_to_server_result('newRequest', params)
37
+ context = ChannelOwners::APIRequestContext.from(result['request'])
38
+ context.send(:_update_timeout_settings, TimeoutSettings.new.tap { |settings| settings.default_timeout = timeout if timeout })
39
+ context
40
+ end
41
+
42
+ private def prepare_storage_state(storage_state)
43
+ storage_state.is_a?(String) ? JSON.parse(File.read(storage_state)) : storage_state
44
+ end
45
+
46
+ private def prepare_client_certificates(client_certificates)
47
+ return unless client_certificates.is_a?(Array)
48
+
49
+ client_certificates.filter_map do |item|
50
+ out_record = {
51
+ origin: item[:origin],
52
+ passphrase: item[:passphrase],
53
+ }
54
+
55
+ { pfxPath: 'pfx', certPath: 'cert', keyPath: 'key' }.each do |key, out_key|
56
+ if (filepath = item[key])
57
+ out_record[out_key] = Base64.encode64(File.read(filepath)) rescue ''
58
+ elsif (value = item[out_key.to_sym])
59
+ out_record[out_key] = value
60
+ end
61
+ end
62
+
63
+ out_record.compact!
64
+ next nil if out_record.empty?
65
+
66
+ out_record
67
+ end
68
+ end
69
+ end
70
+ end
@@ -8,13 +8,17 @@ module Playwright
8
8
  @timeout_settings = TimeoutSettings.new
9
9
  end
10
10
 
11
+ attr_reader :tracing
12
+
11
13
  private def _update_timeout_settings(timeout_settings)
12
14
  @timeout_settings = timeout_settings
13
15
  end
14
16
 
15
17
  def dispose(reason: nil)
16
18
  @close_reason = reason
17
- @channel.send_message_to_server('dispose')
19
+ @tracing.send(:export_all_hars)
20
+ @channel.send_message_to_server('dispose', { reason: reason }.compact)
21
+ @tracing.send(:reset_stack_counter)
18
22
  end
19
23
 
20
24
  def delete(url, **options)
@@ -53,15 +53,9 @@ module Playwright
53
53
  page: PlaywrightApi.wrap(frame.page),
54
54
  frame: PlaywrightApi.wrap(frame),
55
55
  }
56
- args =
57
- if @initializer['handle']
58
- handle = ChannelOwners::ElementHandle.from(@initializer['handle'])
59
- [handle]
60
- else
61
- @initializer['args'].map do |arg|
62
- JavaScript::ValueParser.new(arg).parse
63
- end
64
- end
56
+ args = @initializer['args'].map do |arg|
57
+ JavaScript::ValueParser.new(arg).parse
58
+ end
65
59
 
66
60
  begin
67
61
  result = PlaywrightApi.unwrap(callback.call(source, *args))
@@ -87,6 +87,22 @@ module Playwright
87
87
  @initializer['version']
88
88
  end
89
89
 
90
+ def bind(title, host: nil, metadata: nil, port: nil, workspaceDir: nil)
91
+ params = {
92
+ title: title,
93
+ host: host,
94
+ metadata: metadata,
95
+ port: port,
96
+ workspaceDir: workspaceDir,
97
+ }.compact
98
+ @channel.send_message_to_server_result('startServer', params)
99
+ end
100
+
101
+ def unbind
102
+ @channel.send_message_to_server('stopServer')
103
+ nil
104
+ end
105
+
90
106
  def new_browser_cdp_session
91
107
  resp = @channel.send_message_to_server('newBrowserCDPSession')
92
108
  ChannelOwners::CDPSession.from(resp)
@@ -135,6 +151,7 @@ module Playwright
135
151
  if @browser_type
136
152
  setup_browser_context(context)
137
153
  end
154
+ emit(Events::Browser::Context, context)
138
155
  end
139
156
 
140
157
  private def setup_browser_context(context)