playwright-ruby-client 1.27.0 → 1.28.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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/element_handle.md +1 -0
  3. data/documentation/docs/api/frame.md +51 -3
  4. data/documentation/docs/api/frame_locator.md +50 -3
  5. data/documentation/docs/api/js_handle.md +5 -3
  6. data/documentation/docs/api/keyboard.md +1 -1
  7. data/documentation/docs/api/locator.md +73 -3
  8. data/documentation/docs/api/page.md +51 -3
  9. data/documentation/docs/api/request.md +1 -1
  10. data/documentation/docs/article/guides/rails_integration.md +1 -0
  11. data/documentation/docs/include/api_coverage.md +3 -0
  12. data/lib/playwright/channel_owner.rb +41 -0
  13. data/lib/playwright/channel_owners/browser_context.rb +6 -0
  14. data/lib/playwright/channel_owners/element_handle.rb +8 -1
  15. data/lib/playwright/channel_owners/frame.rb +2 -0
  16. data/lib/playwright/channel_owners/page.rb +23 -28
  17. data/lib/playwright/connection.rb +4 -1
  18. data/lib/playwright/locator_impl.rb +16 -2
  19. data/lib/playwright/locator_utils.rb +13 -19
  20. data/lib/playwright/utils.rb +6 -0
  21. data/lib/playwright/version.rb +2 -2
  22. data/lib/playwright_api/android.rb +12 -6
  23. data/lib/playwright_api/android_device.rb +6 -6
  24. data/lib/playwright_api/api_request_context.rb +6 -6
  25. data/lib/playwright_api/browser.rb +6 -6
  26. data/lib/playwright_api/browser_context.rb +6 -6
  27. data/lib/playwright_api/browser_type.rb +6 -6
  28. data/lib/playwright_api/cdp_session.rb +6 -6
  29. data/lib/playwright_api/console_message.rb +6 -6
  30. data/lib/playwright_api/dialog.rb +6 -6
  31. data/lib/playwright_api/element_handle.rb +8 -7
  32. data/lib/playwright_api/frame.rb +45 -11
  33. data/lib/playwright_api/frame_locator.rb +39 -6
  34. data/lib/playwright_api/js_handle.rb +7 -7
  35. data/lib/playwright_api/keyboard.rb +1 -1
  36. data/lib/playwright_api/locator.rb +55 -5
  37. data/lib/playwright_api/page.rb +45 -11
  38. data/lib/playwright_api/playwright.rb +6 -6
  39. data/lib/playwright_api/request.rb +7 -7
  40. data/lib/playwright_api/response.rb +6 -6
  41. data/lib/playwright_api/route.rb +6 -6
  42. data/lib/playwright_api/selectors.rb +6 -6
  43. data/lib/playwright_api/tracing.rb +6 -6
  44. data/lib/playwright_api/web_socket.rb +6 -6
  45. data/lib/playwright_api/worker.rb +6 -6
  46. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9944a15cd23ff09a56c09f396ff276ec366670740f4c79cb553a9dedec346ff8
4
- data.tar.gz: 33807cddbf67539e40d8659fd565827a1c0127ccc65c7b6a2864b8e80184053b
3
+ metadata.gz: 6d96f4cf4c170f020d8b73571e23f61e994e535708759b0148aec799110f3d72
4
+ data.tar.gz: cc6471e1da4e8f02d8b98b960a84feb67251bafd7781dec9c0d103385474f098
5
5
  SHA512:
6
- metadata.gz: ece68b2c84a789d011b00dd17f27a280e26b23349cc474ec04ca00eab18df2a813a1ebda61143603de02f3abec0fc988818122a09a35d57aa101fbb5429c2beb
7
- data.tar.gz: 5070dd01c89f50580c98e196e1d97b5ffcc34ab1fc7856ac9943a6bfc4743e418cac2b3632566a88c24f99ed7fad1c0c3f1c7f66f873a76c02b993eb0baf74bc
6
+ metadata.gz: 953724a4d98d278b2bcd63a580f433b1defb630534023ae2c3c2df426ef4717a89c6c0e546fb76df5df7ae0b16cfd01d494be36c277d890f1774d65551932fdc
7
+ data.tar.gz: 92be169ac6c6adeac4ac7346df21dd929de1021e38f99f01eba73a74c4327d0436b97e6ea074560f49520eada9a6cd29f399ae144a7baa93fd64cec1c63c9cd4
@@ -292,6 +292,7 @@ Returns element attribute value.
292
292
  def hover(
293
293
  force: nil,
294
294
  modifiers: nil,
295
+ noWaitAfter: nil,
295
296
  position: nil,
296
297
  timeout: nil,
297
298
  trial: nil)
@@ -435,7 +435,7 @@ def get_by_label(text, exact: nil)
435
435
  ```
436
436
 
437
437
  Allows locating input elements by the text of the associated label. For example, this method will find the input by
438
- label text Password in the following DOM:
438
+ label text "Password" in the following DOM:
439
439
 
440
440
  ```html
441
441
  <label for="password-input">Password:</label>
@@ -464,6 +464,7 @@ def get_by_role(
464
464
  role,
465
465
  checked: nil,
466
466
  disabled: nil,
467
+ exact: nil,
467
468
  expanded: nil,
468
469
  includeHidden: nil,
469
470
  level: nil,
@@ -491,13 +492,59 @@ def get_by_test_id(testId)
491
492
  Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
492
493
  [Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
493
494
 
495
+
496
+
494
497
  ## get_by_text
495
498
 
496
499
  ```
497
500
  def get_by_text(text, exact: nil)
498
501
  ```
499
502
 
500
- Allows locating elements that contain given text.
503
+ Allows locating elements that contain given text. Consider the following DOM structure:
504
+
505
+ ```html
506
+ <div>Hello <span>world</span></div>
507
+ <div>Hello</div>
508
+ ```
509
+
510
+ You can locate by text substring, exact string, or a regular expression:
511
+
512
+ ```ruby
513
+ page.content = <<~HTML
514
+ <div>Hello <span>world</span></div>
515
+ <div>Hello</div>
516
+ HTML
517
+
518
+ # Matches <span>
519
+ locator = page.get_by_text("world")
520
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<span>world</span>')
521
+
522
+ # Matches first <div>
523
+ locator = page.get_by_text("Hello world")
524
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
525
+
526
+ # Matches second <div>
527
+ locator = page.get_by_text("Hello", exact: true)
528
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
529
+
530
+ # Matches both <div>s
531
+ locator = page.get_by_text(/Hello/)
532
+ expect(locator.count).to eq(2)
533
+ expect(locator.first.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
534
+ expect(locator.last.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
535
+
536
+ # Matches second <div>
537
+ locator = page.get_by_text(/^hello$/i)
538
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
539
+ ```
540
+
541
+ See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter
542
+ by the text content.
543
+
544
+ > NOTE: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into
545
+ one, turns line breaks into spaces and ignores leading and trailing whitespace.
546
+ > NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
547
+ example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
501
548
 
502
549
  ## get_by_title
503
550
 
@@ -505,7 +552,7 @@ Allows locating elements that contain given text.
505
552
  def get_by_title(text, exact: nil)
506
553
  ```
507
554
 
508
- Allows locating elements by their title. For example, this method will find the button by its title "Submit":
555
+ Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
509
556
 
510
557
  ```html
511
558
  <button title='Place the order'>Order Now</button>
@@ -544,6 +591,7 @@ def hover(
544
591
  selector,
545
592
  force: nil,
546
593
  modifiers: nil,
594
+ noWaitAfter: nil,
547
595
  position: nil,
548
596
  strict: nil,
549
597
  timeout: nil,
@@ -74,7 +74,7 @@ def get_by_label(text, exact: nil)
74
74
  ```
75
75
 
76
76
  Allows locating input elements by the text of the associated label. For example, this method will find the input by
77
- label text Password in the following DOM:
77
+ label text "Password" in the following DOM:
78
78
 
79
79
  ```html
80
80
  <label for="password-input">Password:</label>
@@ -103,6 +103,7 @@ def get_by_role(
103
103
  role,
104
104
  checked: nil,
105
105
  disabled: nil,
106
+ exact: nil,
106
107
  expanded: nil,
107
108
  includeHidden: nil,
108
109
  level: nil,
@@ -130,13 +131,59 @@ def get_by_test_id(testId)
130
131
  Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
131
132
  [Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
132
133
 
134
+
135
+
133
136
  ## get_by_text
134
137
 
135
138
  ```
136
139
  def get_by_text(text, exact: nil)
137
140
  ```
138
141
 
139
- Allows locating elements that contain given text.
142
+ Allows locating elements that contain given text. Consider the following DOM structure:
143
+
144
+ ```html
145
+ <div>Hello <span>world</span></div>
146
+ <div>Hello</div>
147
+ ```
148
+
149
+ You can locate by text substring, exact string, or a regular expression:
150
+
151
+ ```ruby
152
+ page.content = <<~HTML
153
+ <div>Hello <span>world</span></div>
154
+ <div>Hello</div>
155
+ HTML
156
+
157
+ # Matches <span>
158
+ locator = page.get_by_text("world")
159
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<span>world</span>')
160
+
161
+ # Matches first <div>
162
+ locator = page.get_by_text("Hello world")
163
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
164
+
165
+ # Matches second <div>
166
+ locator = page.get_by_text("Hello", exact: true)
167
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
168
+
169
+ # Matches both <div>s
170
+ locator = page.get_by_text(/Hello/)
171
+ expect(locator.count).to eq(2)
172
+ expect(locator.first.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
173
+ expect(locator.last.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
174
+
175
+ # Matches second <div>
176
+ locator = page.get_by_text(/^hello$/i)
177
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
178
+ ```
179
+
180
+ See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter
181
+ by the text content.
182
+
183
+ > NOTE: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into
184
+ one, turns line breaks into spaces and ignores leading and trailing whitespace.
185
+ > NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
186
+ example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
140
187
 
141
188
  ## get_by_title
142
189
 
@@ -144,7 +191,7 @@ Allows locating elements that contain given text.
144
191
  def get_by_title(text, exact: nil)
145
192
  ```
146
193
 
147
- Allows locating elements by their title. For example, this method will find the button by its title "Submit":
194
+ Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
148
195
 
149
196
  ```html
150
197
  <button title='Place the order'>Order Now</button>
@@ -85,10 +85,12 @@ The method returns a map with **own property names** as keys and JSHandle instan
85
85
 
86
86
  ```ruby
87
87
  page.goto('https://example.com/')
88
- window_handle = page.evaluate_handle("window")
89
- properties = window_handle.properties
88
+ handle = page.evaluate_handle("({window, document})")
89
+ properties = handle.properties
90
90
  puts properties
91
- window_handle.dispose
91
+ window_handle = properties["window"]
92
+ document_handle = properties["document"]
93
+ handle.dispose
92
94
  ```
93
95
 
94
96
 
@@ -5,7 +5,7 @@ sidebar_position: 10
5
5
  # Keyboard
6
6
 
7
7
  Keyboard provides an api for managing a virtual keyboard. The high level api is [Keyboard#type](./keyboard#type), which takes
8
- raw characters and generates proper keydown, keypress/input, and keyup events on your page.
8
+ raw characters and generates proper `keydown`, `keypress`/`input`, and `keyup` events on your page.
9
9
 
10
10
  For finer control, you can use [Keyboard#down](./keyboard#down), [Keyboard#up](./keyboard#up), and [Keyboard#insert_text](./keyboard#insert_text)
11
11
  to manually fire events as if they were generated from a real keyboard.
@@ -25,6 +25,14 @@ def all_text_contents
25
25
 
26
26
  Returns an array of `node.textContent` values for all matching nodes.
27
27
 
28
+ ## blur
29
+
30
+ ```
31
+ def blur(timeout: nil)
32
+ ```
33
+
34
+ Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur) on the element.
35
+
28
36
  ## bounding_box
29
37
 
30
38
  ```
@@ -79,6 +87,20 @@ If the element is detached from the DOM at any moment during the action, this me
79
87
  When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
80
88
  zero timeout disables this.
81
89
 
90
+ ## clear
91
+
92
+ ```
93
+ def clear(force: nil, noWaitAfter: nil, timeout: nil)
94
+ ```
95
+
96
+ This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, focuses the element, clears it and triggers an
97
+ `input` event after clearing.
98
+
99
+ If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
100
+ However, if the element is inside the `<label>` element that has an associated
101
+ [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be cleared
102
+ instead.
103
+
82
104
  ## click
83
105
 
84
106
  ```
@@ -382,7 +404,7 @@ def get_by_label(text, exact: nil)
382
404
  ```
383
405
 
384
406
  Allows locating input elements by the text of the associated label. For example, this method will find the input by
385
- label text Password in the following DOM:
407
+ label text "Password" in the following DOM:
386
408
 
387
409
  ```html
388
410
  <label for="password-input">Password:</label>
@@ -411,6 +433,7 @@ def get_by_role(
411
433
  role,
412
434
  checked: nil,
413
435
  disabled: nil,
436
+ exact: nil,
414
437
  expanded: nil,
415
438
  includeHidden: nil,
416
439
  level: nil,
@@ -438,13 +461,59 @@ def get_by_test_id(testId)
438
461
  Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
439
462
  [Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
440
463
 
464
+
465
+
441
466
  ## get_by_text
442
467
 
443
468
  ```
444
469
  def get_by_text(text, exact: nil)
445
470
  ```
446
471
 
447
- Allows locating elements that contain given text.
472
+ Allows locating elements that contain given text. Consider the following DOM structure:
473
+
474
+ ```html
475
+ <div>Hello <span>world</span></div>
476
+ <div>Hello</div>
477
+ ```
478
+
479
+ You can locate by text substring, exact string, or a regular expression:
480
+
481
+ ```ruby
482
+ page.content = <<~HTML
483
+ <div>Hello <span>world</span></div>
484
+ <div>Hello</div>
485
+ HTML
486
+
487
+ # Matches <span>
488
+ locator = page.get_by_text("world")
489
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<span>world</span>')
490
+
491
+ # Matches first <div>
492
+ locator = page.get_by_text("Hello world")
493
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
494
+
495
+ # Matches second <div>
496
+ locator = page.get_by_text("Hello", exact: true)
497
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
498
+
499
+ # Matches both <div>s
500
+ locator = page.get_by_text(/Hello/)
501
+ expect(locator.count).to eq(2)
502
+ expect(locator.first.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
503
+ expect(locator.last.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
504
+
505
+ # Matches second <div>
506
+ locator = page.get_by_text(/^hello$/i)
507
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
508
+ ```
509
+
510
+ See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter
511
+ by the text content.
512
+
513
+ > NOTE: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into
514
+ one, turns line breaks into spaces and ignores leading and trailing whitespace.
515
+ > NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
516
+ example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
448
517
 
449
518
  ## get_by_title
450
519
 
@@ -452,7 +521,7 @@ Allows locating elements that contain given text.
452
521
  def get_by_title(text, exact: nil)
453
522
  ```
454
523
 
455
- Allows locating elements by their title. For example, this method will find the button by its title "Submit":
524
+ Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
456
525
 
457
526
  ```html
458
527
  <button title='Place the order'>Order Now</button>
@@ -474,6 +543,7 @@ Highlight the corresponding element(s) on the screen. Useful for debugging, don'
474
543
  def hover(
475
544
  force: nil,
476
545
  modifiers: nil,
546
+ noWaitAfter: nil,
477
547
  position: nil,
478
548
  timeout: nil,
479
549
  trial: nil)
@@ -648,7 +648,7 @@ def get_by_label(text, exact: nil)
648
648
  ```
649
649
 
650
650
  Allows locating input elements by the text of the associated label. For example, this method will find the input by
651
- label text Password in the following DOM:
651
+ label text "Password" in the following DOM:
652
652
 
653
653
  ```html
654
654
  <label for="password-input">Password:</label>
@@ -677,6 +677,7 @@ def get_by_role(
677
677
  role,
678
678
  checked: nil,
679
679
  disabled: nil,
680
+ exact: nil,
680
681
  expanded: nil,
681
682
  includeHidden: nil,
682
683
  level: nil,
@@ -704,13 +705,59 @@ def get_by_test_id(testId)
704
705
  Locate element by the test id. By default, the `data-testid` attribute is used as a test id. Use
705
706
  [Selectors#set_test_id_attribute](./selectors#set_test_id_attribute) to configure a different test id attribute if necessary.
706
707
 
708
+
709
+
707
710
  ## get_by_text
708
711
 
709
712
  ```
710
713
  def get_by_text(text, exact: nil)
711
714
  ```
712
715
 
713
- Allows locating elements that contain given text.
716
+ Allows locating elements that contain given text. Consider the following DOM structure:
717
+
718
+ ```html
719
+ <div>Hello <span>world</span></div>
720
+ <div>Hello</div>
721
+ ```
722
+
723
+ You can locate by text substring, exact string, or a regular expression:
724
+
725
+ ```ruby
726
+ page.content = <<~HTML
727
+ <div>Hello <span>world</span></div>
728
+ <div>Hello</div>
729
+ HTML
730
+
731
+ # Matches <span>
732
+ locator = page.get_by_text("world")
733
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<span>world</span>')
734
+
735
+ # Matches first <div>
736
+ locator = page.get_by_text("Hello world")
737
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
738
+
739
+ # Matches second <div>
740
+ locator = page.get_by_text("Hello", exact: true)
741
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
742
+
743
+ # Matches both <div>s
744
+ locator = page.get_by_text(/Hello/)
745
+ expect(locator.count).to eq(2)
746
+ expect(locator.first.evaluate('e => e.outerHTML')).to eq('<div>Hello <span>world</span></div>')
747
+ expect(locator.last.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
748
+
749
+ # Matches second <div>
750
+ locator = page.get_by_text(/^hello$/i)
751
+ expect(locator.evaluate('e => e.outerHTML')).to eq('<div>Hello</div>')
752
+ ```
753
+
754
+ See also [Locator#filter](./locator#filter) that allows to match by another criteria, like an accessible role, and then filter
755
+ by the text content.
756
+
757
+ > NOTE: Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into
758
+ one, turns line breaks into spaces and ignores leading and trailing whitespace.
759
+ > NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
760
+ example, locating by text `"Log in"` matches `<input type=button value="Log in">`.
714
761
 
715
762
  ## get_by_title
716
763
 
@@ -718,7 +765,7 @@ Allows locating elements that contain given text.
718
765
  def get_by_title(text, exact: nil)
719
766
  ```
720
767
 
721
- Allows locating elements by their title. For example, this method will find the button by its title "Submit":
768
+ Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
722
769
 
723
770
  ```html
724
771
  <button title='Place the order'>Order Now</button>
@@ -781,6 +828,7 @@ def hover(
781
828
  selector,
782
829
  force: nil,
783
830
  modifiers: nil,
831
+ noWaitAfter: nil,
784
832
  position: nil,
785
833
  strict: nil,
786
834
  timeout: nil,
@@ -15,7 +15,7 @@ the [`event: Page.requestFailed`] event is emitted.
15
15
  > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
16
16
  complete with `'requestfinished'` event.
17
17
 
18
- If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new
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
21
  ## all_headers
@@ -95,6 +95,7 @@ These parameters can be passed into `Capybara::Playwright::Driver.new`
95
95
  * record_video_dir
96
96
  * record_video_size
97
97
  * screen
98
+ * serviceWorkers
98
99
  * storageState
99
100
  * timezoneId
100
101
  * userAgent
@@ -420,8 +420,10 @@
420
420
 
421
421
  * all_inner_texts
422
422
  * all_text_contents
423
+ * blur
423
424
  * bounding_box
424
425
  * check
426
+ * clear
425
427
  * click
426
428
  * count
427
429
  * dblclick
@@ -519,6 +521,7 @@
519
521
 
520
522
  ## Android
521
523
 
524
+ * ~~connect~~
522
525
  * devices
523
526
  * ~~set_default_timeout~~
524
527
 
@@ -36,6 +36,7 @@ module Playwright
36
36
  @type = type
37
37
  @guid = guid
38
38
  @initializer = initializer
39
+ @event_to_subscription_mapping = {}
39
40
 
40
41
  after_initialize
41
42
  end
@@ -59,6 +60,46 @@ module Playwright
59
60
  @objects.clear
60
61
  end
61
62
 
63
+ private def set_event_to_subscription_mapping(event_to_subscription_mapping)
64
+ @event_to_subscription_mapping = event_to_subscription_mapping
65
+ end
66
+
67
+ private def update_subscription(event, enabled)
68
+ protocol_event = @event_to_subscription_mapping[event]
69
+ if protocol_event
70
+ payload = {
71
+ event: protocol_event,
72
+ enabled: enabled,
73
+ }
74
+ @channel.async_send_message_to_server('updateSubscription', payload)
75
+ end
76
+ end
77
+
78
+ # @override
79
+ def on(event, callback)
80
+ if listener_count(event) == 0
81
+ update_subscription(event, true)
82
+ end
83
+ super
84
+ end
85
+
86
+ # @override
87
+ def once(event, callback)
88
+ if listener_count(event) == 0
89
+ update_subscription(event, true)
90
+ end
91
+ super
92
+ end
93
+
94
+ # @override
95
+ def off(event, callback)
96
+ super
97
+ if listener_count(event) == 0
98
+ update_subscription(event, false)
99
+ end
100
+ end
101
+
102
+
62
103
  # Suppress long long inspect log and avoid RSpec from hanging up...
63
104
  def inspect
64
105
  to_s
@@ -58,6 +58,12 @@ module Playwright
58
58
  ChannelOwners::Page.from_nullable(params['page']),
59
59
  )
60
60
  })
61
+ set_event_to_subscription_mapping({
62
+ Events::BrowserContext::Request => "request",
63
+ Events::BrowserContext::Response => "response",
64
+ Events::BrowserContext::RequestFinished => "requestFinished",
65
+ Events::BrowserContext::RequestFailed => "requestFailed",
66
+ })
61
67
 
62
68
  @closed_promise = Concurrent::Promises.resolvable_future
63
69
  end
@@ -76,10 +76,17 @@ module Playwright
76
76
  nil
77
77
  end
78
78
 
79
- def hover(force: nil, modifiers: nil, position: nil, timeout: nil, trial: nil)
79
+ def hover(
80
+ force: nil,
81
+ modifiers: nil,
82
+ noWaitAfter: nil,
83
+ position: nil,
84
+ timeout: nil,
85
+ trial: nil)
80
86
  params = {
81
87
  force: force,
82
88
  modifiers: modifiers,
89
+ noWaitAfter: noWaitAfter,
83
90
  position: position,
84
91
  timeout: timeout,
85
92
  trial: trial,
@@ -461,6 +461,7 @@ module Playwright
461
461
  selector,
462
462
  force: nil,
463
463
  modifiers: nil,
464
+ noWaitAfter: nil,
464
465
  position: nil,
465
466
  strict: nil,
466
467
  timeout: nil,
@@ -469,6 +470,7 @@ module Playwright
469
470
  selector: selector,
470
471
  force: force,
471
472
  modifiers: modifiers,
473
+ noWaitAfter: noWaitAfter,
472
474
  position: position,
473
475
  strict: strict,
474
476
  timeout: timeout,