playwright-ruby-client 1.33.0 → 1.34.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebc7a6ffab254ce53486bcaf8ad642a42fbadd77f33f48598ee721935f795c98
4
- data.tar.gz: bf6473ce5c3ea31bdcca4f072b68aeb4b1b49b0ffb24cc39a7d17955e5de49cf
3
+ metadata.gz: 64c373804c3cc418f35774036436563714c4e7a42ce87d9ce242d961814c28f9
4
+ data.tar.gz: 3dccf880e4d4911279bbac84575f03872284c379fdcac468fa4e16940b51c352
5
5
  SHA512:
6
- metadata.gz: 1e36fed96c70031d7b78ffffe1b3408251fb86b64afb634304d8fe3434b263de696e99b42cb330bb75b2f68a80683caf56e050dddf1b9ead61d97f2dd885b270
7
- data.tar.gz: eb7607a301b420b0c3c587dfa562eccf459a943e425da930c7739a2faccb46888dbfeb84bd83953ef8eb1446322cdc8cd4c4e58f3ca71515999e11dfcd3ba121
6
+ metadata.gz: e911b7eac54e773e83c18efcc13562500e736b75fc259da2f63abed7bc31b716d86b568215c410245fd613a379a3c0fdb63a3a9d942b33042eaf14019829474b
7
+ data.tar.gz: 47ce8a3dd0a37c79c4786f3d1b34ce99009ee3a572b1d88345d3ae6da767c81cc4f6f0bb9e14c93292dfe4e007f229dd37861a1e358544f787f1aa463792b1f0
@@ -451,6 +451,17 @@ def unroute(url, handler: nil)
451
451
  Removes a route created with [BrowserContext#route](./browser_context#route). When `handler` is not specified, removes all
452
452
  routes for the `url`.
453
453
 
454
+ ## expect_console_message
455
+
456
+ ```
457
+ def expect_console_message(predicate: nil, timeout: nil, &block)
458
+ ```
459
+
460
+
461
+ Performs action and waits for a [ConsoleMessage](./console_message) to be logged by in the pages in the context. If predicate is provided, it passes
462
+ [ConsoleMessage](./console_message) value into the `predicate` function and waits for `predicate(message)` to return a truthy value.
463
+ Will throw an error if the page is closed before the [`event: BrowserContext.console`] event is fired.
464
+
454
465
  ## expect_event
455
466
 
456
467
  ```
@@ -472,7 +483,7 @@ end
472
483
  ## expect_page
473
484
 
474
485
  ```
475
- def expect_page(predicate: nil, timeout: nil)
486
+ def expect_page(predicate: nil, timeout: nil, &block)
476
487
  ```
477
488
 
478
489
 
@@ -49,6 +49,15 @@ def location
49
49
 
50
50
 
51
51
 
52
+ ## page
53
+
54
+ ```
55
+ def page
56
+ ```
57
+
58
+
59
+ The page that produced this console message, if any.
60
+
52
61
  ## text
53
62
 
54
63
  ```
@@ -65,6 +65,15 @@ def message
65
65
 
66
66
  A message displayed in the dialog.
67
67
 
68
+ ## page
69
+
70
+ ```
71
+ def page
72
+ ```
73
+
74
+
75
+ The page that initiated this dialog, if available.
76
+
68
77
  ## type
69
78
 
70
79
  ```
@@ -64,6 +64,23 @@ Returns an array of `node.textContent` values for all matching nodes.
64
64
  texts = page.get_by_role("link").all_text_contents
65
65
  ```
66
66
 
67
+ ## and
68
+
69
+ ```
70
+ def and(locator)
71
+ ```
72
+
73
+
74
+ Creates a locator that matches both this locator and the argument locator.
75
+
76
+ **Usage**
77
+
78
+ The following example finds a button with a specific title.
79
+
80
+ ```ruby
81
+ button = page.get_by_role("button").and(page.get_by_title("Subscribe"))
82
+ ```
83
+
67
84
  ## blur
68
85
 
69
86
  ```
@@ -84,7 +84,7 @@ def handle_post(route, request)
84
84
  end
85
85
 
86
86
  # Handle POST requests.
87
- def handle_post(route)
87
+ def handle_post(route, request)
88
88
  if request.method != "POST"
89
89
  route.fallback
90
90
  return
@@ -218,6 +218,7 @@
218
218
 
219
219
  * args
220
220
  * location
221
+ * page
221
222
  * text
222
223
  * type
223
224
 
@@ -227,6 +228,7 @@
227
228
  * default_value
228
229
  * dismiss
229
230
  * message
231
+ * page
230
232
  * type
231
233
 
232
234
  ## Download
@@ -367,6 +369,7 @@
367
369
  * set_offline
368
370
  * storage_state
369
371
  * unroute
372
+ * expect_console_message
370
373
  * expect_event
371
374
  * expect_page
372
375
  * ~~wait_for_event~~
@@ -422,6 +425,7 @@
422
425
  * all
423
426
  * all_inner_texts
424
427
  * all_text_contents
428
+ * and
425
429
  * blur
426
430
  * bounding_box
427
431
  * check
@@ -35,6 +35,12 @@ module Playwright
35
35
  @channel.on('serviceWorker', ->(params) {
36
36
  on_service_worker(ChannelOwners::Worker.from(params['worker']))
37
37
  })
38
+ @channel.on('console', ->(params) {
39
+ on_console_message(ChannelOwners::ConsoleMessage.from(params['message']))
40
+ })
41
+ @channel.on('dialog', ->(params) {
42
+ on_dialog(ChannelOwners::Dialog.from(params['dialog']))
43
+ })
38
44
  @channel.on('request', ->(params) {
39
45
  on_request(
40
46
  ChannelOwners::Request.from(params['request']),
@@ -57,6 +63,8 @@ module Playwright
57
63
  )
58
64
  })
59
65
  set_event_to_subscription_mapping({
66
+ Events::BrowserContext::Console => 'console',
67
+ Events::BrowserContext::Dialog => 'dialog',
60
68
  Events::BrowserContext::Request => "request",
61
69
  Events::BrowserContext::Response => "response",
62
70
  Events::BrowserContext::RequestFinished => "requestFinished",
@@ -147,6 +155,28 @@ module Playwright
147
155
  response&.send(:mark_as_finished)
148
156
  end
149
157
 
158
+ private def on_console_message(message)
159
+ emit(Events::BrowserContext::Console, message)
160
+ if (page = message.page)
161
+ page.emit(Events::Page::Console, message)
162
+ end
163
+ end
164
+
165
+ private def on_dialog(dialog)
166
+ consumed_by_context = emit(Events::BrowserContext::Dialog, dialog)
167
+ if (page = dialog.page)
168
+ consumed_by_page = page.emit(Events::Page::Dialog, dialog)
169
+ end
170
+
171
+ if !consumed_by_context && !consumed_by_page
172
+ if dialog.type == 'beforeunload'
173
+ dialog.accept_async
174
+ else
175
+ dialog.dismiss
176
+ end
177
+ end
178
+ end
179
+
150
180
  private def on_request(request, page)
151
181
  emit(Events::BrowserContext::Request, request)
152
182
  page&.emit(Events::Page::Request, request)
@@ -414,12 +444,20 @@ module Playwright
414
444
  end
415
445
  end
416
446
 
417
- def expect_page(predicate: nil, timeout: nil)
447
+ def expect_console_message(predicate: nil, timeout: nil, &block)
448
+ params = {
449
+ predicate: predicate,
450
+ timeout: timeout,
451
+ }.compact
452
+ expect_event(Events::BrowserContext::Console, params, &block)
453
+ end
454
+
455
+ def expect_page(predicate: nil, timeout: nil, &block)
418
456
  params = {
419
457
  predicate: predicate,
420
458
  timeout: timeout,
421
459
  }.compact
422
- expect_event(Events::BrowserContext::Page, params)
460
+ expect_event(Events::BrowserContext::Page, params, &block)
423
461
  end
424
462
 
425
463
  # called from Page#on_close with send(:remove_page, page), so keep private
@@ -1,5 +1,9 @@
1
1
  module Playwright
2
2
  define_channel_owner :ConsoleMessage do
3
+ def page
4
+ @page ||= ChannelOwners::Page.from_nullable(@initializer['page'])
5
+ end
6
+
3
7
  def type
4
8
  @initializer['type']
5
9
  end
@@ -1,5 +1,9 @@
1
1
  module Playwright
2
2
  define_channel_owner :Dialog do
3
+ def page
4
+ @page ||= ChannelOwners::Page.from_nullable(@initializer['page'])
5
+ end
6
+
3
7
  def type
4
8
  @initializer['type']
5
9
  end
@@ -36,12 +36,7 @@ module Playwright
36
36
 
37
37
  @channel.on('bindingCall', ->(params) { on_binding(ChannelOwners::BindingCall.from(params['binding'])) })
38
38
  @channel.once('close', ->(_) { on_close })
39
- @channel.on('console', ->(params) {
40
- console_message = ChannelOwners::ConsoleMessage.from(params['message'])
41
- emit(Events::Page::Console, console_message)
42
- })
43
39
  @channel.on('crash', ->(_) { emit(Events::Page::Crash) })
44
- @channel.on('dialog', method(:on_dialog))
45
40
  @channel.on('download', method(:on_download))
46
41
  @channel.on('fileChooser', ->(params) {
47
42
  chooser = FileChooserImpl.new(
@@ -70,6 +65,8 @@ module Playwright
70
65
  })
71
66
 
72
67
  set_event_to_subscription_mapping({
68
+ Events::Page::Console => "console",
69
+ Events::Page::Dialog => "dialog",
73
70
  Events::Page::Request => "request",
74
71
  Events::Page::Response => "response",
75
72
  Events::Page::RequestFinished => "requestFinished",
@@ -151,13 +148,6 @@ module Playwright
151
148
  emit(Events::Page::Close)
152
149
  end
153
150
 
154
- private def on_dialog(params)
155
- dialog = ChannelOwners::Dialog.from(params['dialog'])
156
- unless emit(Events::Page::Dialog, dialog)
157
- dialog.dismiss
158
- end
159
- end
160
-
161
151
  private def on_download(params)
162
152
  artifact = ChannelOwners::Artifact.from(params['artifact'])
163
153
  download = DownloadImpl.new(
@@ -26,6 +26,8 @@ end
26
26
  BrowserContext: {
27
27
  BackgroundPage: 'backgroundpage',
28
28
  Close: 'close',
29
+ Console: 'console',
30
+ Dialog: 'dialog',
29
31
  Page: 'page',
30
32
  ServiceWorker: 'serviceworker',
31
33
  Request: 'request',
@@ -268,9 +268,20 @@ module Playwright
268
268
  )
269
269
  end
270
270
 
271
+ def and(locator)
272
+ unless same_frame?(locator)
273
+ raise DifferentFrameError.new('and')
274
+ end
275
+ LocatorImpl.new(
276
+ frame: @frame,
277
+ timeout_settings: @timeout_settings,
278
+ selector: "#{@selector} >> internal:and=#{locator.send(:selector_json)}",
279
+ )
280
+ end
281
+
271
282
  def or(locator)
272
283
  unless same_frame?(locator)
273
- raise DifferentFrameError.new('locator')
284
+ raise DifferentFrameError.new('or')
274
285
  end
275
286
  LocatorImpl.new(
276
287
  frame: @frame,
@@ -39,7 +39,7 @@ module Playwright
39
39
  end
40
40
 
41
41
  private def get_by_test_id_selector(test_id_attribute_name, test_id)
42
- "internal:testid=[#{test_id_attribute_name}=#{escape_for_attribute_selector(test_id, true)}]"
42
+ "internal:testid=[#{test_id_attribute_name}=#{escape_for_attribute_selector_or_regex(test_id, true)}]"
43
43
  end
44
44
 
45
45
  private def get_by_label_selector(text, exact:)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playwright
4
- VERSION = '1.33.0'
5
- COMPATIBLE_PLAYWRIGHT_VERSION = '1.33.0'
4
+ VERSION = '1.34.0'
5
+ COMPATIBLE_PLAYWRIGHT_VERSION = '1.34.3'
6
6
  end
data/lib/playwright.rb CHANGED
@@ -74,7 +74,7 @@ module Playwright
74
74
  # ...
75
75
  # end
76
76
  #
77
- # When we use this method without block, an instance of Puppeteer::Execution is returned
77
+ # When we use this method without block, an instance of Playwright::Execution is returned
78
78
  # and we *must* call execution.stop on the end.
79
79
  # The instance of playwright is available by calling execution.playwright
80
80
  module_function def create(playwright_cli_executable_path:, &block)
@@ -391,6 +391,14 @@ module Playwright
391
391
  wrap_impl(@impl.unroute(unwrap_impl(url), handler: unwrap_impl(handler)))
392
392
  end
393
393
 
394
+ #
395
+ # Performs action and waits for a `ConsoleMessage` to be logged by in the pages in the context. If predicate is provided, it passes
396
+ # `ConsoleMessage` value into the `predicate` function and waits for `predicate(message)` to return a truthy value.
397
+ # Will throw an error if the page is closed before the [`event: BrowserContext.console`] event is fired.
398
+ def expect_console_message(predicate: nil, timeout: nil, &block)
399
+ wrap_impl(@impl.expect_console_message(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
400
+ end
401
+
394
402
  #
395
403
  # Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
396
404
  # value. Will throw an error if the context closes before the event is fired. Returns the event data value.
@@ -410,8 +418,8 @@ module Playwright
410
418
  # Performs action and waits for a new `Page` to be created in the context. If predicate is provided, it passes
411
419
  # `Page` value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
412
420
  # Will throw an error if the context closes before new `Page` is created.
413
- def expect_page(predicate: nil, timeout: nil)
414
- wrap_impl(@impl.expect_page(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout)))
421
+ def expect_page(predicate: nil, timeout: nil, &block)
422
+ wrap_impl(@impl.expect_page(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
415
423
  end
416
424
 
417
425
  #
@@ -33,6 +33,12 @@ module Playwright
33
33
  wrap_impl(@impl.location)
34
34
  end
35
35
 
36
+ #
37
+ # The page that produced this console message, if any.
38
+ def page
39
+ wrap_impl(@impl.page)
40
+ end
41
+
36
42
  #
37
43
  # The text of the console message.
38
44
  def text
@@ -51,6 +51,12 @@ module Playwright
51
51
  wrap_impl(@impl.message)
52
52
  end
53
53
 
54
+ #
55
+ # The page that initiated this dialog, if available.
56
+ def page
57
+ wrap_impl(@impl.page)
58
+ end
59
+
54
60
  #
55
61
  # Returns dialog's type, can be one of `alert`, `beforeunload`, `confirm` or `prompt`.
56
62
  def type
@@ -50,6 +50,20 @@ module Playwright
50
50
  wrap_impl(@impl.all_text_contents)
51
51
  end
52
52
 
53
+ #
54
+ # Creates a locator that matches both this locator and the argument locator.
55
+ #
56
+ # **Usage**
57
+ #
58
+ # The following example finds a button with a specific title.
59
+ #
60
+ # ```python sync
61
+ # button = page.get_by_role("button").and_(page.getByTitle("Subscribe"))
62
+ # ```
63
+ def and(locator)
64
+ wrap_impl(@impl.and(unwrap_impl(locator)))
65
+ end
66
+
53
67
  #
54
68
  # Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur) on the element.
55
69
  def blur(timeout: nil)
@@ -1672,11 +1672,6 @@ module Playwright
1672
1672
  raise NotImplementedError.new('wait_for_event is not implemented yet.')
1673
1673
  end
1674
1674
 
1675
- # @nodoc
1676
- def stop_css_coverage
1677
- wrap_impl(@impl.stop_css_coverage)
1678
- end
1679
-
1680
1675
  # @nodoc
1681
1676
  def owned_context=(req)
1682
1677
  wrap_impl(@impl.owned_context=(unwrap_impl(req)))
@@ -1702,6 +1697,11 @@ module Playwright
1702
1697
  wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1703
1698
  end
1704
1699
 
1700
+ # @nodoc
1701
+ def stop_css_coverage
1702
+ wrap_impl(@impl.stop_css_coverage)
1703
+ end
1704
+
1705
1705
  # -- inherited from EventEmitter --
1706
1706
  # @nodoc
1707
1707
  def off(event, callback)
@@ -57,7 +57,7 @@ module Playwright
57
57
  #
58
58
  # ```python sync
59
59
  # # Handle GET requests.
60
- # def handle_post(route):
60
+ # def handle_get(route):
61
61
  # if route.request.method != "GET":
62
62
  # route.fallback()
63
63
  # return
@@ -47,13 +47,13 @@ module Playwright
47
47
  end
48
48
 
49
49
  # @nodoc
50
- def page=(req)
51
- wrap_impl(@impl.page=(unwrap_impl(req)))
50
+ def context=(req)
51
+ wrap_impl(@impl.context=(unwrap_impl(req)))
52
52
  end
53
53
 
54
54
  # @nodoc
55
- def context=(req)
56
- wrap_impl(@impl.context=(unwrap_impl(req)))
55
+ def page=(req)
56
+ wrap_impl(@impl.page=(unwrap_impl(req)))
57
57
  end
58
58
 
59
59
  # -- inherited from EventEmitter --
data/sig/playwright.rbs CHANGED
@@ -223,6 +223,7 @@ module Playwright
223
223
  class ConsoleMessage
224
224
  def args: -> Array[untyped]
225
225
  def location: -> Hash[untyped, untyped]
226
+ def page: -> (nil | Page)
226
227
  def text: -> String
227
228
  def type: -> String
228
229
  end
@@ -232,6 +233,7 @@ module Playwright
232
233
  def default_value: -> String
233
234
  def dismiss: -> void
234
235
  def message: -> String
236
+ def page: -> (nil | Page)
235
237
  def type: -> String
236
238
  end
237
239
 
@@ -382,8 +384,9 @@ module Playwright
382
384
  def offline=: (bool offline) -> void
383
385
  def storage_state: (?path: (String | File)) -> Hash[untyped, untyped]
384
386
  def unroute: ((String | Regexp | function) url, ?handler: function) -> void
387
+ def expect_console_message: (?predicate: function, ?timeout: Float) { () -> void } -> ConsoleMessage
385
388
  def expect_event: (String event, ?predicate: function, ?timeout: Float) { () -> void } -> untyped
386
- def expect_page: (?predicate: function, ?timeout: Float) -> Page
389
+ def expect_page: (?predicate: function, ?timeout: Float) { () -> void } -> Page
387
390
 
388
391
  attr_reader request: APIRequestContext
389
392
  attr_reader tracing: Tracing
@@ -434,6 +437,7 @@ module Playwright
434
437
  def all: -> Array[untyped]
435
438
  def all_inner_texts: -> Array[untyped]
436
439
  def all_text_contents: -> Array[untyped]
440
+ def and: (Locator locator) -> Locator
437
441
  def blur: (?timeout: Float) -> void
438
442
  def bounding_box: (?timeout: Float) -> (nil | Hash[untyped, untyped])
439
443
  def check: (?force: bool, ?noWaitAfter: bool, ?position: Hash[untyped, untyped], ?timeout: Float, ?trial: bool) -> void
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playwright-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.33.0
4
+ version: 1.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-29 00:00:00.000000000 Z
11
+ date: 2023-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -401,5 +401,5 @@ requirements: []
401
401
  rubygems_version: 3.3.26
402
402
  signing_key:
403
403
  specification_version: 4
404
- summary: The Ruby binding of playwright driver 1.33.0
404
+ summary: The Ruby binding of playwright driver 1.34.3
405
405
  test_files: []