playwright-ruby-client 1.39.1 → 1.41.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/api_request_context.md +1 -2
  3. data/documentation/docs/api/browser.md +1 -1
  4. data/documentation/docs/api/browser_context.md +10 -1
  5. data/documentation/docs/api/browser_type.md +1 -0
  6. data/documentation/docs/api/download.md +1 -2
  7. data/documentation/docs/api/element_handle.md +5 -1
  8. data/documentation/docs/api/frame.md +4 -1
  9. data/documentation/docs/api/locator.md +5 -1
  10. data/documentation/docs/api/locator_assertions.md +12 -2
  11. data/documentation/docs/api/page.md +16 -3
  12. data/documentation/docs/api/tracing.md +2 -2
  13. data/documentation/docs/article/guides/rails_integration.md +80 -51
  14. data/documentation/docs/article/guides/rspec_integration.md +59 -0
  15. data/documentation/docs/include/api_coverage.md +2 -0
  16. data/documentation/docusaurus.config.js +1 -1
  17. data/documentation/package.json +7 -7
  18. data/documentation/yarn.lock +4641 -5023
  19. data/lib/playwright/api_response_impl.rb +2 -2
  20. data/lib/playwright/channel_owners/api_request_context.rb +12 -3
  21. data/lib/playwright/channel_owners/browser.rb +11 -7
  22. data/lib/playwright/channel_owners/browser_context.rb +40 -15
  23. data/lib/playwright/channel_owners/element_handle.rb +2 -0
  24. data/lib/playwright/channel_owners/frame.rb +38 -14
  25. data/lib/playwright/channel_owners/page.rb +36 -16
  26. data/lib/playwright/channel_owners/web_socket.rb +8 -13
  27. data/lib/playwright/connection.rb +18 -2
  28. data/lib/playwright/errors.rb +20 -2
  29. data/lib/playwright/input_files.rb +4 -4
  30. data/lib/playwright/locator_assertions_impl.rb +15 -15
  31. data/lib/playwright/locator_impl.rb +2 -0
  32. data/lib/playwright/test.rb +2 -2
  33. data/lib/playwright/utils.rb +3 -10
  34. data/lib/playwright/version.rb +2 -2
  35. data/lib/playwright/waiter.rb +146 -0
  36. data/lib/playwright.rb +1 -1
  37. data/lib/playwright_api/api_request_context.rb +1 -2
  38. data/lib/playwright_api/browser.rb +2 -2
  39. data/lib/playwright_api/browser_context.rb +9 -3
  40. data/lib/playwright_api/browser_type.rb +2 -1
  41. data/lib/playwright_api/download.rb +1 -2
  42. data/lib/playwright_api/element_handle.rb +6 -2
  43. data/lib/playwright_api/frame.rb +4 -1
  44. data/lib/playwright_api/locator.rb +6 -2
  45. data/lib/playwright_api/locator_assertions.rb +14 -4
  46. data/lib/playwright_api/page.rb +20 -10
  47. data/lib/playwright_api/request.rb +4 -4
  48. data/lib/playwright_api/tracing.rb +2 -2
  49. data/lib/playwright_api/worker.rb +4 -4
  50. data/sig/playwright.rbs +12 -10
  51. metadata +7 -6
  52. data/lib/playwright/wait_helper.rb +0 -73
data/sig/playwright.rbs CHANGED
@@ -118,7 +118,7 @@ module Playwright
118
118
  def press: (String key, ?delay: Float, ?noWaitAfter: bool, ?timeout: Float) -> void
119
119
  def query_selector: (String selector) -> (nil | ElementHandle)
120
120
  def query_selector_all: (String selector) -> Array[untyped]
121
- def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?mask: Array[untyped], ?maskColor: String, ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?timeout: Float, ?type: ("png" | "jpeg")) -> String
121
+ def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?mask: Array[untyped], ?maskColor: String, ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?style: String, ?timeout: Float, ?type: ("png" | "jpeg")) -> String
122
122
  def scroll_into_view_if_needed: (?timeout: Float) -> void
123
123
  def select_option: (?element: (ElementHandle | Array[untyped]), ?index: (Integer | Array[untyped]), ?value: (String | Array[untyped]), ?label: (String | Array[untyped]), ?force: bool, ?noWaitAfter: bool, ?timeout: Float) -> Array[untyped]
124
124
  def select_text: (?force: bool, ?timeout: Float) -> void
@@ -242,7 +242,7 @@ module Playwright
242
242
  def delete: -> void
243
243
  def failure: -> (nil | String)
244
244
  def page: -> Page
245
- def path: -> (nil | (String | File))
245
+ def path: -> (String | File)
246
246
  def save_as: ((String | File) path) -> void
247
247
  def suggested_filename: -> String
248
248
  def url: -> String
@@ -255,7 +255,7 @@ module Playwright
255
255
  def bring_to_front: -> void
256
256
  def check: (String selector, ?force: bool, ?noWaitAfter: bool, ?position: Hash[untyped, untyped], ?strict: bool, ?timeout: Float, ?trial: bool) -> void
257
257
  def click: (String selector, ?button: ("left" | "right" | "middle"), ?clickCount: Integer, ?delay: Float, ?force: bool, ?modifiers: Array[untyped], ?noWaitAfter: bool, ?position: Hash[untyped, untyped], ?strict: bool, ?timeout: Float, ?trial: bool) -> void
258
- def close: (?runBeforeUnload: bool) -> void
258
+ def close: (?reason: String, ?runBeforeUnload: bool) -> void
259
259
  def content: -> String
260
260
  def context: -> BrowserContext
261
261
  def dblclick: (String selector, ?button: ("left" | "right" | "middle"), ?delay: Float, ?force: bool, ?modifiers: Array[untyped], ?noWaitAfter: bool, ?position: Hash[untyped, untyped], ?strict: bool, ?timeout: Float, ?trial: bool) -> void
@@ -306,7 +306,7 @@ module Playwright
306
306
  def reload: (?timeout: Float, ?waitUntil: ("load" | "domcontentloaded" | "networkidle" | "commit")) -> (nil | Response)
307
307
  def route: ((String | Regexp | function) url, function handler, ?times: Integer) -> void
308
308
  def route_from_har: ((String | File) har, ?notFound: ("abort" | "fallback"), ?update: bool, ?updateContent: ("embed" | "attach"), ?updateMode: ("full" | "minimal"), ?url: (String | Regexp)) -> void
309
- def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?clip: Hash[untyped, untyped], ?fullPage: bool, ?mask: Array[untyped], ?maskColor: String, ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?timeout: Float, ?type: ("png" | "jpeg")) -> String
309
+ def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?clip: Hash[untyped, untyped], ?fullPage: bool, ?mask: Array[untyped], ?maskColor: String, ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?style: String, ?timeout: Float, ?type: ("png" | "jpeg")) -> String
310
310
  def select_option: (String selector, ?element: (ElementHandle | Array[untyped]), ?index: (Integer | Array[untyped]), ?value: (String | Array[untyped]), ?label: (String | Array[untyped]), ?force: bool, ?noWaitAfter: bool, ?strict: bool, ?timeout: Float) -> Array[untyped]
311
311
  def set_checked: (String selector, bool checked, ?force: bool, ?noWaitAfter: bool, ?position: Hash[untyped, untyped], ?strict: bool, ?timeout: Float, ?trial: bool) -> void
312
312
  def set_content: (String html, ?timeout: Float, ?waitUntil: ("load" | "domcontentloaded" | "networkidle" | "commit")) -> void
@@ -325,6 +325,7 @@ module Playwright
325
325
  def title: -> String
326
326
  def type: (String selector, String text, ?delay: Float, ?noWaitAfter: bool, ?strict: bool, ?timeout: Float) -> void
327
327
  def uncheck: (String selector, ?force: bool, ?noWaitAfter: bool, ?position: Hash[untyped, untyped], ?strict: bool, ?timeout: Float, ?trial: bool) -> void
328
+ def unroute_all: (?behavior: ("wait" | "ignoreErrors" | "default")) -> void
328
329
  def unroute: ((String | Regexp | function) url, ?handler: function) -> void
329
330
  def url: -> String
330
331
  def video: -> (nil | untyped)
@@ -361,7 +362,7 @@ module Playwright
361
362
  def browser: -> (nil | Browser)
362
363
  def clear_cookies: -> void
363
364
  def clear_permissions: -> void
364
- def close: -> void
365
+ def close: (?reason: String) -> void
365
366
  def cookies: (?urls: (String | Array[untyped])) -> Array[untyped]
366
367
  def expose_binding: (String name, function callback, ?handle: bool) -> void
367
368
  def expose_function: (String name, function callback) -> void
@@ -383,6 +384,7 @@ module Playwright
383
384
  def set_offline: (bool offline) -> void
384
385
  def offline=: (bool offline) -> void
385
386
  def storage_state: (?path: (String | File)) -> Hash[untyped, untyped]
387
+ def unroute_all: (?behavior: ("wait" | "ignoreErrors" | "default")) -> void
386
388
  def unroute: ((String | Regexp | function) url, ?handler: function) -> void
387
389
  def expect_console_message: (?predicate: function, ?timeout: Float) { () -> void } -> ConsoleMessage
388
390
  def expect_event: (String event, ?predicate: function, ?timeout: Float) { () -> void } -> untyped
@@ -399,7 +401,7 @@ module Playwright
399
401
 
400
402
  class Browser
401
403
  def browser_type: -> BrowserType
402
- def close: -> void
404
+ def close: (?reason: String) -> void
403
405
  def contexts: -> Array[untyped]
404
406
  def connected?: -> bool
405
407
  def new_browser_cdp_session: -> CDPSession
@@ -414,7 +416,7 @@ module Playwright
414
416
  def connect_over_cdp: (String endpointURL, ?headers: Hash[untyped, untyped], ?slowMo: Float, ?timeout: Float) ?{ (untyped) -> untyped } -> Browser
415
417
  def executable_path: -> String
416
418
  def launch: (?args: Array[untyped], ?channel: String, ?chromiumSandbox: bool, ?devtools: bool, ?downloadsPath: (String | File), ?env: Hash[untyped, untyped], ?executablePath: (String | File), ?firefoxUserPrefs: Hash[untyped, untyped], ?handleSIGHUP: bool, ?handleSIGINT: bool, ?handleSIGTERM: bool, ?headless: bool, ?ignoreDefaultArgs: (bool | Array[untyped]), ?proxy: Hash[untyped, untyped], ?slowMo: Float, ?timeout: Float, ?tracesDir: (String | File)) ?{ (Browser) -> untyped } -> Browser
417
- def launch_persistent_context: ((String | File) userDataDir, ?acceptDownloads: bool, ?args: Array[untyped], ?baseURL: String, ?bypassCSP: bool, ?channel: String, ?chromiumSandbox: bool, ?colorScheme: ("light" | "dark" | "no-preference" | "null"), ?deviceScaleFactor: Float, ?devtools: bool, ?downloadsPath: (String | File), ?env: Hash[untyped, untyped], ?executablePath: (String | File), ?extraHTTPHeaders: Hash[untyped, untyped], ?forcedColors: ("active" | "none" | "null"), ?geolocation: Hash[untyped, untyped], ?handleSIGHUP: bool, ?handleSIGINT: bool, ?handleSIGTERM: bool, ?hasTouch: bool, ?headless: bool, ?httpCredentials: Hash[untyped, untyped], ?ignoreDefaultArgs: (bool | Array[untyped]), ?ignoreHTTPSErrors: bool, ?isMobile: bool, ?javaScriptEnabled: bool, ?locale: String, ?noViewport: bool, ?offline: bool, ?permissions: Array[untyped], ?proxy: Hash[untyped, untyped], ?record_har_content: ("omit" | "embed" | "attach"), ?record_har_mode: ("full" | "minimal"), ?record_har_omit_content: bool, ?record_har_path: (String | File), ?record_har_url_filter: (String | Regexp), ?record_video_dir: (String | File), ?record_video_size: Hash[untyped, untyped], ?reducedMotion: ("reduce" | "no-preference" | "null"), ?screen: Hash[untyped, untyped], ?serviceWorkers: ("allow" | "block"), ?slowMo: Float, ?strictSelectors: bool, ?timeout: Float, ?timezoneId: String, ?tracesDir: (String | File), ?userAgent: String, ?viewport: (nil | Hash[untyped, untyped])) ?{ (untyped) -> untyped } -> BrowserContext
419
+ def launch_persistent_context: ((String | File) userDataDir, ?acceptDownloads: bool, ?args: Array[untyped], ?baseURL: String, ?bypassCSP: bool, ?channel: String, ?chromiumSandbox: bool, ?colorScheme: ("light" | "dark" | "no-preference" | "null"), ?deviceScaleFactor: Float, ?devtools: bool, ?downloadsPath: (String | File), ?env: Hash[untyped, untyped], ?executablePath: (String | File), ?extraHTTPHeaders: Hash[untyped, untyped], ?firefoxUserPrefs: Hash[untyped, untyped], ?forcedColors: ("active" | "none" | "null"), ?geolocation: Hash[untyped, untyped], ?handleSIGHUP: bool, ?handleSIGINT: bool, ?handleSIGTERM: bool, ?hasTouch: bool, ?headless: bool, ?httpCredentials: Hash[untyped, untyped], ?ignoreDefaultArgs: (bool | Array[untyped]), ?ignoreHTTPSErrors: bool, ?isMobile: bool, ?javaScriptEnabled: bool, ?locale: String, ?noViewport: bool, ?offline: bool, ?permissions: Array[untyped], ?proxy: Hash[untyped, untyped], ?record_har_content: ("omit" | "embed" | "attach"), ?record_har_mode: ("full" | "minimal"), ?record_har_omit_content: bool, ?record_har_path: (String | File), ?record_har_url_filter: (String | Regexp), ?record_video_dir: (String | File), ?record_video_size: Hash[untyped, untyped], ?reducedMotion: ("reduce" | "no-preference" | "null"), ?screen: Hash[untyped, untyped], ?serviceWorkers: ("allow" | "block"), ?slowMo: Float, ?strictSelectors: bool, ?timeout: Float, ?timezoneId: String, ?tracesDir: (String | File), ?userAgent: String, ?viewport: (nil | Hash[untyped, untyped])) ?{ (untyped) -> untyped } -> BrowserContext
418
420
  def name: -> String
419
421
  end
420
422
 
@@ -484,7 +486,7 @@ module Playwright
484
486
  def page: -> Page
485
487
  def press: (String key, ?delay: Float, ?noWaitAfter: bool, ?timeout: Float) -> void
486
488
  def press_sequentially: (String text, ?delay: Float, ?noWaitAfter: bool, ?timeout: Float) -> void
487
- def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?mask: Array[untyped], ?maskColor: String, ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?timeout: Float, ?type: ("png" | "jpeg")) -> String
489
+ def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?mask: Array[untyped], ?maskColor: String, ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?style: String, ?timeout: Float, ?type: ("png" | "jpeg")) -> String
488
490
  def scroll_into_view_if_needed: (?timeout: Float) -> void
489
491
  def select_option: (?element: (ElementHandle | Array[untyped]), ?index: (Integer | Array[untyped]), ?value: (String | Array[untyped]), ?label: (String | Array[untyped]), ?force: bool, ?noWaitAfter: bool, ?timeout: Float) -> Array[untyped]
490
492
  def select_text: (?force: bool, ?timeout: Float) -> void
@@ -550,7 +552,7 @@ module Playwright
550
552
  def not_to_be_in_viewport: (?ratio: Float, ?timeout: Float) -> void
551
553
  def not_to_be_visible: (?timeout: Float, ?visible: bool) -> void
552
554
  def not_to_contain_text: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?ignoreCase: bool, ?timeout: Float, ?useInnerText: bool) -> void
553
- def not_to_have_attribute: (String name, (String | Regexp) value, ?timeout: Float) -> void
555
+ def not_to_have_attribute: (String name, (String | Regexp) value, ?ignoreCase: bool, ?timeout: Float) -> void
554
556
  def not_to_have_class: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?timeout: Float) -> void
555
557
  def not_to_have_count: (Integer count, ?timeout: Float) -> void
556
558
  def not_to_have_css: (String name, (String | Regexp) value, ?timeout: Float) -> void
@@ -570,7 +572,7 @@ module Playwright
570
572
  def to_be_in_viewport: (?ratio: Float, ?timeout: Float) -> void
571
573
  def to_be_visible: (?timeout: Float, ?visible: bool) -> void
572
574
  def to_contain_text: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?ignoreCase: bool, ?timeout: Float, ?useInnerText: bool) -> void
573
- def to_have_attribute: (String name, (String | Regexp) value, ?timeout: Float) -> void
575
+ def to_have_attribute: (String name, (String | Regexp) value, ?ignoreCase: bool, ?timeout: Float) -> void
574
576
  def to_have_class: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?timeout: Float) -> void
575
577
  def to_have_count: (Integer count, ?timeout: Float) -> void
576
578
  def to_have_css: (String name, (String | Regexp) value, ?timeout: Float) -> 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.39.1
4
+ version: 1.41.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-05 00:00:00.000000000 Z
11
+ date: 2023-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -255,6 +255,7 @@ files:
255
255
  - documentation/docs/article/guides/rails_integration.md
256
256
  - documentation/docs/article/guides/rails_integration_with_null_driver.md
257
257
  - documentation/docs/article/guides/recording_video.md
258
+ - documentation/docs/article/guides/rspec_integration.md
258
259
  - documentation/docs/article/guides/semi_automation.md
259
260
  - documentation/docs/article/guides/use_storage_state.md
260
261
  - documentation/docs/include/api_coverage.md
@@ -343,7 +344,7 @@ files:
343
344
  - lib/playwright/utils.rb
344
345
  - lib/playwright/version.rb
345
346
  - lib/playwright/video.rb
346
- - lib/playwright/wait_helper.rb
347
+ - lib/playwright/waiter.rb
347
348
  - lib/playwright/web_socket_client.rb
348
349
  - lib/playwright/web_socket_transport.rb
349
350
  - lib/playwright_api/accessibility.rb
@@ -398,12 +399,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
398
399
  version: '2.4'
399
400
  required_rubygems_version: !ruby/object:Gem::Requirement
400
401
  requirements:
401
- - - ">="
402
+ - - ">"
402
403
  - !ruby/object:Gem::Version
403
- version: '0'
404
+ version: 1.3.1
404
405
  requirements: []
405
406
  rubygems_version: 3.3.26
406
407
  signing_key:
407
408
  specification_version: 4
408
- summary: The Ruby binding of playwright driver 1.39.0
409
+ summary: The Ruby binding of playwright driver 1.41.0-alpha-dec-24-2023
409
410
  test_files: []
@@ -1,73 +0,0 @@
1
- module Playwright
2
- # ref: https://github.com/microsoft/playwright-python/blob/30946ae3099d51f9b7f355f9ae7e8c04d748ce36/playwright/_impl/_wait_helper.py
3
- # ref: https://github.com/microsoft/playwright/blob/01fb3a6045cbdb4b5bcba0809faed85bd917ab87/src/client/waiter.ts#L21
4
- class WaitHelper
5
- def initialize
6
- @promise = Concurrent::Promises.resolvable_future
7
- @registered_listeners = Set.new
8
- end
9
-
10
- def reject_on_event(emitter, event, error, predicate: nil)
11
- listener = -> (*args) {
12
- if !predicate || predicate.call(*args)
13
- reject(error)
14
- end
15
- }
16
- emitter.on(event, listener)
17
- @registered_listeners << [emitter, event, listener]
18
-
19
- self
20
- end
21
-
22
- def reject_on_timeout(timeout_ms, message)
23
- return if timeout_ms <= 0
24
-
25
- Concurrent::Promises.schedule(timeout_ms / 1000.0) do
26
- reject(TimeoutError.new(message: message))
27
- end
28
-
29
- self
30
- end
31
-
32
- # @param [Playwright::EventEmitter]
33
- # @param
34
- def wait_for_event(emitter, event, predicate: nil)
35
- listener = -> (*args) {
36
- begin
37
- if !predicate || predicate.call(*args)
38
- fulfill(*args)
39
- end
40
- rescue => err
41
- reject(err)
42
- end
43
- }
44
- emitter.on(event, listener)
45
- @registered_listeners << [emitter, event, listener]
46
-
47
- self
48
- end
49
-
50
- attr_reader :promise
51
-
52
- private def cleanup
53
- @registered_listeners.each do |emitter, event, listener|
54
- emitter.off(event, listener)
55
- end
56
- @registered_listeners.clear
57
- end
58
-
59
- private def fulfill(*args)
60
- cleanup
61
- unless @promise.resolved?
62
- @promise.fulfill(args.first)
63
- end
64
- end
65
-
66
- private def reject(error)
67
- cleanup
68
- unless @promise.resolved?
69
- @promise.reject(error)
70
- end
71
- end
72
- end
73
- end