playwright-ruby-client 1.63.0 → 1.64.1

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/api_request_context.md +47 -0
  3. data/documentation/docs/api/browser.md +2 -0
  4. data/documentation/docs/api/browser_type.md +1 -0
  5. data/documentation/docs/api/clock.md +1 -0
  6. data/documentation/docs/api/credentials.md +6 -3
  7. data/documentation/docs/api/frame.md +6 -1
  8. data/documentation/docs/api/locator.md +38 -0
  9. data/documentation/docs/api/page.md +32 -1
  10. data/documentation/docs/api/request.md +1 -1
  11. data/documentation/docs/api/response.md +2 -1
  12. data/documentation/docs/api/tracing.md +2 -2
  13. data/documentation/docs/api/web_mcp.md +34 -0
  14. data/documentation/docs/article/guides/playwright_on_alpine_linux.md +1 -1
  15. data/documentation/docs/include/api_coverage.md +12 -0
  16. data/lib/playwright/channel_owners/api_request_context.rb +16 -0
  17. data/lib/playwright/channel_owners/browser_context.rb +4 -31
  18. data/lib/playwright/channel_owners/frame.rb +4 -3
  19. data/lib/playwright/channel_owners/local_utils.rb +5 -0
  20. data/lib/playwright/channel_owners/page.rb +10 -2
  21. data/lib/playwright/channel_owners/tracing.rb +2 -0
  22. data/lib/playwright/connection.rb +6 -2
  23. data/lib/playwright/credentials_impl.rb +2 -1
  24. data/lib/playwright/errors.rb +4 -1
  25. data/lib/playwright/locator_impl.rb +22 -8
  26. data/lib/playwright/screencast.rb +4 -2
  27. data/lib/playwright/transport.rb +21 -5
  28. data/lib/playwright/utils.rb +20 -0
  29. data/lib/playwright/version.rb +2 -2
  30. data/lib/playwright/web_mcp_impl.rb +21 -0
  31. data/lib/playwright_api/api_request_context.rb +44 -6
  32. data/lib/playwright_api/browser.rb +10 -8
  33. data/lib/playwright_api/browser_context.rb +13 -13
  34. data/lib/playwright_api/browser_type.rb +8 -7
  35. data/lib/playwright_api/cdp_session.rb +6 -6
  36. data/lib/playwright_api/clock.rb +1 -0
  37. data/lib/playwright_api/credentials.rb +7 -4
  38. data/lib/playwright_api/dialog.rb +6 -6
  39. data/lib/playwright_api/element_handle.rb +6 -6
  40. data/lib/playwright_api/frame.rb +19 -13
  41. data/lib/playwright_api/js_handle.rb +6 -6
  42. data/lib/playwright_api/locator.rb +35 -0
  43. data/lib/playwright_api/page.rb +46 -17
  44. data/lib/playwright_api/playwright.rb +6 -6
  45. data/lib/playwright_api/request.rb +9 -9
  46. data/lib/playwright_api/response.rb +8 -7
  47. data/lib/playwright_api/route.rb +6 -6
  48. data/lib/playwright_api/tracing.rb +8 -8
  49. data/lib/playwright_api/web_mcp.rb +26 -0
  50. data/lib/playwright_api/web_socket.rb +6 -6
  51. data/lib/playwright_api/worker.rb +8 -8
  52. data/sig/playwright.rbs +21 -8
  53. metadata +5 -2
@@ -5,8 +5,9 @@ module Playwright
5
5
  define_api_implementation :LocatorImpl do
6
6
  include LocatorUtils
7
7
 
8
- def initialize(frame:, selector:, has: nil, hasNot: nil, hasNotText: nil, hasText: nil, visible: nil)
8
+ def initialize(frame:, selector:, has: nil, hasNot: nil, hasNotText: nil, hasText: nil, visible: nil, locator_code: nil)
9
9
  @frame = frame
10
+ @locator_code = locator_code
10
11
  selector_scopes = [selector]
11
12
 
12
13
  if hasText
@@ -39,11 +40,18 @@ module Playwright
39
40
  end
40
41
 
41
42
  def to_s
42
- if @description
43
- "Locator@#{@selector} (#{@description})"
44
- else
45
- "Locator@#{@selector}"
46
- end
43
+ custom_description = description
44
+ return custom_description if custom_description
45
+ return @locator_code if @locator_code
46
+
47
+ local_utils = @frame.instance_variable_get(:@connection).local_utils
48
+ return "Locator@#{@selector}" unless local_utils
49
+
50
+ local_utils.as_locator_description(@selector)
51
+ end
52
+
53
+ def within(locator)
54
+ locator.locator(self)
47
55
  end
48
56
 
49
57
  private def to_protocol
@@ -232,6 +240,11 @@ module Playwright
232
240
  hasNot: nil,
233
241
  hasNotText: nil,
234
242
  hasText: nil)
243
+ if selector.is_a?(LocatorImpl)
244
+ raise ArgumentError, 'Locators must belong to the same frame.' unless same_frame?(selector)
245
+
246
+ selector = "internal:chain=#{selector.send(:selector_json)}"
247
+ end
235
248
  LocatorImpl.new(
236
249
  frame: @frame,
237
250
  selector: "#{@selector} >> #{selector}",
@@ -453,10 +466,11 @@ module Playwright
453
466
  end
454
467
 
455
468
  def normalize
456
- resolved_selector = @frame.channel.send_message_to_server('resolveSelector', { selector: @selector })
469
+ result = @frame.channel.send_message_to_server_result('resolveSelector', { selector: @selector, sdkLanguage: 'python' })
457
470
  LocatorImpl.new(
458
471
  frame: @frame,
459
- selector: resolved_selector,
472
+ selector: result['resolvedSelector'],
473
+ locator_code: result['locatorCode'],
460
474
  )
461
475
  end
462
476
 
@@ -11,7 +11,7 @@ module Playwright
11
11
  @page.send(:channel).on('screencastFrame', method(:handle_screencast_frame))
12
12
  end
13
13
 
14
- def start(path: nil, size: nil, quality: nil, &on_frame)
14
+ def start(path: nil, size: nil, quality: nil, fps: nil, &on_frame)
15
15
  raise 'Screencast is already started' if @started
16
16
 
17
17
  @started = true
@@ -21,6 +21,7 @@ module Playwright
21
21
  params[:record] = true if path
22
22
  params[:size] = size if size
23
23
  params[:quality] = quality if quality
24
+ params[:fps] = fps unless fps.nil?
24
25
  params[:sendFrames] = true if on_frame
25
26
 
26
27
  result = @page.send(:channel).send_message_to_server_result('screencastStart', params)
@@ -63,12 +64,13 @@ module Playwright
63
64
  @page.send(:channel).send_message_to_server('screencastChapter', params)
64
65
  end
65
66
 
66
- def show_actions(duration: nil, fontSize: nil, position: nil, cursor: nil)
67
+ def show_actions(duration: nil, fontSize: nil, position: nil, cursor: nil, style: nil)
67
68
  params = {}
68
69
  params[:duration] = duration if duration
69
70
  params[:fontSize] = fontSize if fontSize
70
71
  params[:position] = position if position
71
72
  params[:cursor] = cursor if cursor
73
+ params[:style] = style if style
72
74
  @page.send(:channel).send_message_to_server('screencastShowActions', params)
73
75
  DisposableStub.new { hide_actions }
74
76
  end
@@ -32,10 +32,15 @@ module Playwright
32
32
  def send_message(message)
33
33
  debug_send_message(message) if @debug
34
34
  msg = JSON.dump(message)
35
- @mutex.synchronize {
36
- @stdin.write([msg.bytes.length].pack('V')) # unsigned 32bit, little endian, real byte size instead of chars
37
- @stdin.write(msg) # write UTF-8 in binary mode as byte stream
38
- }
35
+ # Build the whole frame (4-byte little-endian length header + JSON payload) in a
36
+ # single buffer, and write it at once. Two separate writes can be torn by an
37
+ # asynchronous exception (e.g. Timeout::Error from Timeout.timeout, delivered via
38
+ # Thread#raise), which crashes the driver with a JSON parse error.
39
+ # ref: https://github.com/YusukeIwaki/playwright-ruby-client/issues/392
40
+ frame = [msg.bytesize].pack('V') + msg.b # unsigned 32bit, little endian, real byte size instead of chars
41
+ Thread.handle_interrupt(Object => :never) do
42
+ @mutex.synchronize { @stdin.write(frame) } # write UTF-8 in binary mode as byte stream
43
+ end
39
44
  rescue Errno::EPIPE, IOError
40
45
  raise AlreadyDisconnectedError.new('send_message failed')
41
46
  end
@@ -85,6 +90,10 @@ module Playwright
85
90
  debug_recv_message(obj) if @debug
86
91
  @on_message&.call(obj)
87
92
  end
93
+ # exited the loop on clean EOF. The driver is gone, so reject pending
94
+ # callbacks instead of hanging forever on promises that will never resolve.
95
+ # ref: https://github.com/YusukeIwaki/playwright-ruby-client/issues/392
96
+ @on_driver_closed&.call
88
97
  rescue IOError
89
98
  # disconnected by remote.
90
99
  @on_driver_closed&.call
@@ -92,6 +101,9 @@ module Playwright
92
101
 
93
102
  def handle_stderr
94
103
  while err = @stderr.read
104
+ # IO#read without length on a pipe returns "" (not nil) at EOF.
105
+ # Bail out instead of spinning forever on empty reads.
106
+ break if err.empty?
95
107
  # sometimed driver crashes with the error below.
96
108
  # --------
97
109
  # undefined:1
@@ -103,7 +115,11 @@ module Playwright
103
115
  # at Transport.transport.onmessage (/home/runner/work/playwright-ruby-client/playwright-ruby-client/node_modules/playwright/lib/cli/driver.js:42:73)
104
116
  # at Immediate.<anonymous> (/home/runner/work/playwright-ruby-client/playwright-ruby-client/node_modules/playwright/lib/protocol/transport.js:74:26)
105
117
  # at processImmediate (internal/timers.js:461:21)
106
- if err.include?('undefined:1')
118
+ #
119
+ # Node >= 16 prints '<anonymous_script>:1' instead of 'undefined:1'.
120
+ # ref: https://github.com/YusukeIwaki/playwright-ruby-client/issues/392
121
+ if err.include?('undefined:1') || err.include?('<anonymous_script>:1') ||
122
+ err.include?('is not valid JSON')
107
123
  @on_driver_crashed&.call
108
124
  break
109
125
  end
@@ -18,6 +18,23 @@ module Playwright
18
18
  end
19
19
 
20
20
  module Utils
21
+ module ClearCookiesParameters
22
+ private def clear_cookies_params(domain:, name:, path:)
23
+ params = {}
24
+ { domain: domain, name: name, path: path }.each do |key, value|
25
+ case value
26
+ when String
27
+ params[key] = value
28
+ when Regexp
29
+ regex = JavaScript::Regex.new(value)
30
+ params["#{key}RegexSource".to_sym] = regex.source
31
+ params["#{key}RegexFlags".to_sym] = regex.flag
32
+ end
33
+ end
34
+ params
35
+ end
36
+ end
37
+
21
38
  module PrepareHttpCredentials
22
39
  private def prepare_http_credentials(credentials)
23
40
  return nil unless credentials
@@ -47,6 +64,9 @@ module Playwright
47
64
  if params[:record_video_size]
48
65
  params[:recordVideo][:size] = params.delete(:record_video_size)
49
66
  end
67
+ unless params[:record_video_fps].nil?
68
+ params[:recordVideo][:fps] = params.delete(:record_video_fps)
69
+ end
50
70
  if params[:record_video_show_actions]
51
71
  params[:recordVideo][:showActions] = params.delete(:record_video_show_actions)
52
72
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playwright
4
- VERSION = '1.63.0'
5
- COMPATIBLE_PLAYWRIGHT_VERSION = '1.63.0'
4
+ VERSION = '1.64.1'
5
+ COMPATIBLE_PLAYWRIGHT_VERSION = '1.64.1'
6
6
  end
@@ -0,0 +1,21 @@
1
+ module Playwright
2
+ # https://github.com/microsoft/playwright/blob/v1.64.0/packages/playwright-core/src/client/webmcp.ts
3
+ define_api_implementation :WebMCPImpl do
4
+ def initialize(frame)
5
+ @frame = frame
6
+ end
7
+
8
+ def tools(timeout: nil)
9
+ @frame.channel.send_message_to_server('webmcpTools', timeout: @frame.send(:_timeout, timeout))
10
+ end
11
+
12
+ def call_tool(name, input: nil, timeout: nil)
13
+ result = @frame.channel.send_message_to_server('webmcpCallTool',
14
+ name: name,
15
+ input: JavaScript::ValueSerializer.new(input).serialize,
16
+ timeout: @frame.send(:_timeout, timeout),
17
+ )
18
+ JavaScript::ValueParser.new(result).parse
19
+ end
20
+ end
21
+ end
@@ -73,6 +73,44 @@ module Playwright
73
73
  wrap_impl(@impl.tracing)
74
74
  end
75
75
 
76
+ #
77
+ # Adds cookies into this request context. They will be sent with matching subsequent requests. For [`property: BrowserContext.request`]
78
+ # and [`property: Page.request`], this is equivalent to calling [`method: BrowserContext.addCookies`] on the corresponding browser context.
79
+ #
80
+ # **Usage**
81
+ #
82
+ # ```python sync
83
+ # request.add_cookies([cookie_object1, cookie_object2])
84
+ # ```
85
+ def add_cookies(cookies)
86
+ wrap_impl(@impl.add_cookies(unwrap_impl(cookies)))
87
+ end
88
+
89
+ #
90
+ # Removes cookies from this request context. Accepts optional filter. For [`property: BrowserContext.request`]
91
+ # and [`property: Page.request`], this is equivalent to calling [`method: BrowserContext.clearCookies`] on the corresponding browser context.
92
+ #
93
+ # **Usage**
94
+ #
95
+ # ```python sync
96
+ # request.clear_cookies()
97
+ # request.clear_cookies(name="session-id")
98
+ # request.clear_cookies(domain="my-origin.com")
99
+ # request.clear_cookies(path="/api/v1")
100
+ # request.clear_cookies(name="session-id", domain="my-origin.com")
101
+ # ```
102
+ def clear_cookies(domain: nil, name: nil, path: nil)
103
+ wrap_impl(@impl.clear_cookies(domain: unwrap_impl(domain), name: unwrap_impl(name), path: unwrap_impl(path)))
104
+ end
105
+
106
+ #
107
+ # If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs
108
+ # are returned. For [`property: BrowserContext.request`] and [`property: Page.request`], this is equivalent to calling
109
+ # [`method: BrowserContext.cookies`] on the corresponding browser context.
110
+ def cookies(urls: nil)
111
+ wrap_impl(@impl.cookies(urls: unwrap_impl(urls)))
112
+ end
113
+
76
114
  #
77
115
  # Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its response.
78
116
  # The method will populate request cookies from the context and update
@@ -292,12 +330,6 @@ module Playwright
292
330
  raise NotImplementedError.new('storage_state is not implemented yet.')
293
331
  end
294
332
 
295
- # -- inherited from EventEmitter --
296
- # @nodoc
297
- def off(event, callback)
298
- event_emitter_proxy.off(event, callback)
299
- end
300
-
301
333
  # -- inherited from EventEmitter --
302
334
  # @nodoc
303
335
  def once(event, callback)
@@ -310,6 +342,12 @@ module Playwright
310
342
  event_emitter_proxy.on(event, callback)
311
343
  end
312
344
 
345
+ # -- inherited from EventEmitter --
346
+ # @nodoc
347
+ def off(event, callback)
348
+ event_emitter_proxy.off(event, callback)
349
+ end
350
+
313
351
  private def event_emitter_proxy
314
352
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
315
353
  end
@@ -113,6 +113,7 @@ module Playwright
113
113
  record_har_path: nil,
114
114
  record_har_url_filter: nil,
115
115
  record_video_dir: nil,
116
+ record_video_fps: nil,
116
117
  record_video_size: nil,
117
118
  reducedMotion: nil,
118
119
  screen: nil,
@@ -123,7 +124,7 @@ module Playwright
123
124
  userAgent: nil,
124
125
  viewport: nil,
125
126
  &block)
126
- wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), clientCertificates: unwrap_impl(clientCertificates), colorScheme: unwrap_impl(colorScheme), contrast: unwrap_impl(contrast), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), storageState: unwrap_impl(storageState), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
127
+ wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), clientCertificates: unwrap_impl(clientCertificates), colorScheme: unwrap_impl(colorScheme), contrast: unwrap_impl(contrast), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_fps: unwrap_impl(record_video_fps), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), storageState: unwrap_impl(storageState), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
127
128
  end
128
129
 
129
130
  #
@@ -159,6 +160,7 @@ module Playwright
159
160
  record_har_path: nil,
160
161
  record_har_url_filter: nil,
161
162
  record_video_dir: nil,
163
+ record_video_fps: nil,
162
164
  record_video_size: nil,
163
165
  reducedMotion: nil,
164
166
  screen: nil,
@@ -169,7 +171,7 @@ module Playwright
169
171
  userAgent: nil,
170
172
  viewport: nil,
171
173
  &block)
172
- wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), clientCertificates: unwrap_impl(clientCertificates), colorScheme: unwrap_impl(colorScheme), contrast: unwrap_impl(contrast), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), storageState: unwrap_impl(storageState), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
174
+ wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), clientCertificates: unwrap_impl(clientCertificates), colorScheme: unwrap_impl(colorScheme), contrast: unwrap_impl(contrast), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_fps: unwrap_impl(record_video_fps), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), storageState: unwrap_impl(storageState), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
173
175
  end
174
176
 
175
177
  #
@@ -215,12 +217,6 @@ module Playwright
215
217
  wrap_impl(@impl.version)
216
218
  end
217
219
 
218
- # -- inherited from EventEmitter --
219
- # @nodoc
220
- def off(event, callback)
221
- event_emitter_proxy.off(event, callback)
222
- end
223
-
224
220
  # -- inherited from EventEmitter --
225
221
  # @nodoc
226
222
  def once(event, callback)
@@ -233,6 +229,12 @@ module Playwright
233
229
  event_emitter_proxy.on(event, callback)
234
230
  end
235
231
 
232
+ # -- inherited from EventEmitter --
233
+ # @nodoc
234
+ def off(event, callback)
235
+ event_emitter_proxy.off(event, callback)
236
+ end
237
+
236
238
  private def event_emitter_proxy
237
239
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
238
240
  end
@@ -498,21 +498,11 @@ module Playwright
498
498
  raise NotImplementedError.new('wait_for_event is not implemented yet.')
499
499
  end
500
500
 
501
- # @nodoc
502
- def owner_page=(req)
503
- wrap_impl(@impl.owner_page=(unwrap_impl(req)))
504
- end
505
-
506
501
  # @nodoc
507
502
  def browser=(req)
508
503
  wrap_impl(@impl.browser=(unwrap_impl(req)))
509
504
  end
510
505
 
511
- # @nodoc
512
- def options=(req)
513
- wrap_impl(@impl.options=(unwrap_impl(req)))
514
- end
515
-
516
506
  # @nodoc
517
507
  def enable_debug_console!
518
508
  wrap_impl(@impl.enable_debug_console!)
@@ -523,10 +513,14 @@ module Playwright
523
513
  wrap_impl(@impl.pause)
524
514
  end
525
515
 
526
- # -- inherited from EventEmitter --
527
516
  # @nodoc
528
- def off(event, callback)
529
- event_emitter_proxy.off(event, callback)
517
+ def options=(req)
518
+ wrap_impl(@impl.options=(unwrap_impl(req)))
519
+ end
520
+
521
+ # @nodoc
522
+ def owner_page=(req)
523
+ wrap_impl(@impl.owner_page=(unwrap_impl(req)))
530
524
  end
531
525
 
532
526
  # -- inherited from EventEmitter --
@@ -541,6 +535,12 @@ module Playwright
541
535
  event_emitter_proxy.on(event, callback)
542
536
  end
543
537
 
538
+ # -- inherited from EventEmitter --
539
+ # @nodoc
540
+ def off(event, callback)
541
+ event_emitter_proxy.off(event, callback)
542
+ end
543
+
544
544
  private def event_emitter_proxy
545
545
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
546
546
  end
@@ -165,6 +165,7 @@ module Playwright
165
165
  record_har_path: nil,
166
166
  record_har_url_filter: nil,
167
167
  record_video_dir: nil,
168
+ record_video_fps: nil,
168
169
  record_video_size: nil,
169
170
  reducedMotion: nil,
170
171
  screen: nil,
@@ -177,7 +178,7 @@ module Playwright
177
178
  userAgent: nil,
178
179
  viewport: nil,
179
180
  &block)
180
- wrap_impl(@impl.launch_persistent_context(unwrap_impl(userDataDir), acceptDownloads: unwrap_impl(acceptDownloads), args: unwrap_impl(args), artifactsDir: unwrap_impl(artifactsDir), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), clientCertificates: unwrap_impl(clientCertificates), colorScheme: unwrap_impl(colorScheme), contrast: unwrap_impl(contrast), deviceScaleFactor: unwrap_impl(deviceScaleFactor), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), firefoxUserPrefs: unwrap_impl(firefoxUserPrefs), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), hasTouch: unwrap_impl(hasTouch), headless: unwrap_impl(headless), httpCredentials: unwrap_impl(httpCredentials), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), slowMo: unwrap_impl(slowMo), strictSelectors: unwrap_impl(strictSelectors), timeout: unwrap_impl(timeout), timezoneId: unwrap_impl(timezoneId), tracesDir: unwrap_impl(tracesDir), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
181
+ wrap_impl(@impl.launch_persistent_context(unwrap_impl(userDataDir), acceptDownloads: unwrap_impl(acceptDownloads), args: unwrap_impl(args), artifactsDir: unwrap_impl(artifactsDir), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), clientCertificates: unwrap_impl(clientCertificates), colorScheme: unwrap_impl(colorScheme), contrast: unwrap_impl(contrast), deviceScaleFactor: unwrap_impl(deviceScaleFactor), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), firefoxUserPrefs: unwrap_impl(firefoxUserPrefs), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), hasTouch: unwrap_impl(hasTouch), headless: unwrap_impl(headless), httpCredentials: unwrap_impl(httpCredentials), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_fps: unwrap_impl(record_video_fps), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), slowMo: unwrap_impl(slowMo), strictSelectors: unwrap_impl(strictSelectors), timeout: unwrap_impl(timeout), timezoneId: unwrap_impl(timezoneId), tracesDir: unwrap_impl(tracesDir), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
181
182
  end
182
183
 
183
184
  #
@@ -186,12 +187,6 @@ module Playwright
186
187
  wrap_impl(@impl.name)
187
188
  end
188
189
 
189
- # -- inherited from EventEmitter --
190
- # @nodoc
191
- def off(event, callback)
192
- event_emitter_proxy.off(event, callback)
193
- end
194
-
195
190
  # -- inherited from EventEmitter --
196
191
  # @nodoc
197
192
  def once(event, callback)
@@ -204,6 +199,12 @@ module Playwright
204
199
  event_emitter_proxy.on(event, callback)
205
200
  end
206
201
 
202
+ # -- inherited from EventEmitter --
203
+ # @nodoc
204
+ def off(event, callback)
205
+ event_emitter_proxy.off(event, callback)
206
+ end
207
+
207
208
  private def event_emitter_proxy
208
209
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
209
210
  end
@@ -31,12 +31,6 @@ module Playwright
31
31
  wrap_impl(@impl.send_message(unwrap_impl(method), params: unwrap_impl(params)))
32
32
  end
33
33
 
34
- # -- inherited from EventEmitter --
35
- # @nodoc
36
- def off(event, callback)
37
- event_emitter_proxy.off(event, callback)
38
- end
39
-
40
34
  # -- inherited from EventEmitter --
41
35
  # @nodoc
42
36
  def once(event, callback)
@@ -49,6 +43,12 @@ module Playwright
49
43
  event_emitter_proxy.on(event, callback)
50
44
  end
51
45
 
46
+ # -- inherited from EventEmitter --
47
+ # @nodoc
48
+ def off(event, callback)
49
+ event_emitter_proxy.off(event, callback)
50
+ end
51
+
52
52
  private def event_emitter_proxy
53
53
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
54
54
  end
@@ -23,6 +23,7 @@ module Playwright
23
23
  #
24
24
  # Install fake implementations for the following time-related functions:
25
25
  # - `Date`
26
+ # - `Temporal.Now`
26
27
  # - `setTimeout`
27
28
  # - `clearTimeout`
28
29
  # - `setInterval`
@@ -54,6 +54,7 @@ module Playwright
54
54
  # user_handle=credential["userHandle"],
55
55
  # private_key=credential["privateKey"],
56
56
  # public_key=credential["publicKey"],
57
+ # sign_count=credential["signCount"],
57
58
  # )
58
59
  # context.credentials.install()
59
60
  #
@@ -64,7 +65,7 @@ module Playwright
64
65
  #
65
66
  # **Usage: save credentials in the storage state, restore later**
66
67
  #
67
- # See [authentication guide](../auth.md) for examples of using saving and resotring the storage state.
68
+ # See [authentication guide](../auth.md) for examples of using saving and restoring the storage state.
68
69
  #
69
70
  # **Defaults**
70
71
  class Credentials < PlaywrightApi
@@ -90,7 +91,8 @@ module Playwright
90
91
  # username-then-passkey and usernameless passkey flows. The returned object carries the private and public keys, so it can be persisted to disk and re-seeded in a later test.
91
92
  #
92
93
  # To **import a known credential**, supply all four of `id`, `userHandle`, `privateKey` and
93
- # `publicKey` together.
94
+ # `publicKey` together. Pass `signCount` as well to continue from the
95
+ # signature counter the relying party has already seen.
94
96
  #
95
97
  # Call [`method: Credentials.install`] before navigating to a page that uses WebAuthn.
96
98
  def create(
@@ -98,8 +100,9 @@ module Playwright
98
100
  id: nil,
99
101
  privateKey: nil,
100
102
  publicKey: nil,
103
+ signCount: nil,
101
104
  userHandle: nil)
102
- wrap_impl(@impl.create(unwrap_impl(rpId), id: unwrap_impl(id), privateKey: unwrap_impl(privateKey), publicKey: unwrap_impl(publicKey), userHandle: unwrap_impl(userHandle)))
105
+ wrap_impl(@impl.create(unwrap_impl(rpId), id: unwrap_impl(id), privateKey: unwrap_impl(privateKey), publicKey: unwrap_impl(publicKey), signCount: unwrap_impl(signCount), userHandle: unwrap_impl(userHandle)))
103
106
  end
104
107
 
105
108
  #
@@ -115,7 +118,7 @@ module Playwright
115
118
  # `id`. This includes both credentials seeded with [`method: Credentials.create`] and credentials
116
119
  # the page registered itself by calling `navigator.credentials.create()`.
117
120
  #
118
- # Each returned credential includes its private and public keys, so a passkey the app just
121
+ # Each returned credential includes its private and public keys and the current signature counter, so a passkey the app just
119
122
  # registered can be saved and re-seeded into a later test with [`method: Credentials.create`] — see the second example in the class overview.
120
123
  def get(id: nil, rpId: nil)
121
124
  wrap_impl(@impl.get(id: unwrap_impl(id), rpId: unwrap_impl(rpId)))
@@ -68,12 +68,6 @@ module Playwright
68
68
  wrap_impl(@impl.accept_async(promptText: unwrap_impl(promptText)))
69
69
  end
70
70
 
71
- # -- inherited from EventEmitter --
72
- # @nodoc
73
- def off(event, callback)
74
- event_emitter_proxy.off(event, callback)
75
- end
76
-
77
71
  # -- inherited from EventEmitter --
78
72
  # @nodoc
79
73
  def once(event, callback)
@@ -86,6 +80,12 @@ module Playwright
86
80
  event_emitter_proxy.on(event, callback)
87
81
  end
88
82
 
83
+ # -- inherited from EventEmitter --
84
+ # @nodoc
85
+ def off(event, callback)
86
+ event_emitter_proxy.off(event, callback)
87
+ end
88
+
89
89
  private def event_emitter_proxy
90
90
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
91
91
  end
@@ -581,12 +581,6 @@ module Playwright
581
581
  wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
582
582
  end
583
583
 
584
- # -- inherited from EventEmitter --
585
- # @nodoc
586
- def off(event, callback)
587
- event_emitter_proxy.off(event, callback)
588
- end
589
-
590
584
  # -- inherited from EventEmitter --
591
585
  # @nodoc
592
586
  def once(event, callback)
@@ -599,6 +593,12 @@ module Playwright
599
593
  event_emitter_proxy.on(event, callback)
600
594
  end
601
595
 
596
+ # -- inherited from EventEmitter --
597
+ # @nodoc
598
+ def off(event, callback)
599
+ event_emitter_proxy.off(event, callback)
600
+ end
601
+
602
602
  private def event_emitter_proxy
603
603
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
604
604
  end
@@ -31,6 +31,12 @@ module Playwright
31
31
  # ```
32
32
  class Frame < PlaywrightApi
33
33
 
34
+ #
35
+ # Tools that the frame registers through the experimental `WebMCP` browser API. See `WebMCP` for details.
36
+ def webmcp # property
37
+ wrap_impl(@impl.webmcp)
38
+ end
39
+
34
40
  #
35
41
  # Returns the added tag when the script's onload fires or when the script content was injected into frame.
36
42
  #
@@ -103,8 +109,8 @@ module Playwright
103
109
 
104
110
  #
105
111
  # Gets the full HTML contents of the frame, including the doctype.
106
- def content
107
- wrap_impl(@impl.content)
112
+ def content(includeShadow: nil)
113
+ wrap_impl(@impl.content(includeShadow: unwrap_impl(includeShadow)))
108
114
  end
109
115
 
110
116
  #
@@ -1065,6 +1071,11 @@ module Playwright
1065
1071
  wrap_impl(@impl.drop(unwrap_impl(selector), unwrap_impl(payload), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
1066
1072
  end
1067
1073
 
1074
+ # @nodoc
1075
+ def expect(selector, expression, options, title)
1076
+ wrap_impl(@impl.expect(unwrap_impl(selector), unwrap_impl(expression), unwrap_impl(options), unwrap_impl(title)))
1077
+ end
1078
+
1068
1079
  # @nodoc
1069
1080
  def detached=(req)
1070
1081
  wrap_impl(@impl.detached=(unwrap_impl(req)))
@@ -1080,17 +1091,6 @@ module Playwright
1080
1091
  wrap_impl(@impl.hide_highlight(unwrap_impl(selector)))
1081
1092
  end
1082
1093
 
1083
- # @nodoc
1084
- def expect(selector, expression, options, title)
1085
- wrap_impl(@impl.expect(unwrap_impl(selector), unwrap_impl(expression), unwrap_impl(options), unwrap_impl(title)))
1086
- end
1087
-
1088
- # -- inherited from EventEmitter --
1089
- # @nodoc
1090
- def off(event, callback)
1091
- event_emitter_proxy.off(event, callback)
1092
- end
1093
-
1094
1094
  # -- inherited from EventEmitter --
1095
1095
  # @nodoc
1096
1096
  def once(event, callback)
@@ -1103,6 +1103,12 @@ module Playwright
1103
1103
  event_emitter_proxy.on(event, callback)
1104
1104
  end
1105
1105
 
1106
+ # -- inherited from EventEmitter --
1107
+ # @nodoc
1108
+ def off(event, callback)
1109
+ event_emitter_proxy.off(event, callback)
1110
+ end
1111
+
1106
1112
  private def event_emitter_proxy
1107
1113
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
1108
1114
  end