playwright-ruby-client 1.20.2 → 1.21.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 +4 -4
- data/documentation/docs/api/api_request_context.md +15 -2
- data/documentation/docs/api/browser_type.md +1 -1
- data/documentation/docs/api/console_message.md +27 -1
- data/documentation/docs/api/element_handle.md +4 -2
- data/documentation/docs/api/experimental/android.md +1 -1
- data/documentation/docs/api/frame_locator.md +1 -1
- data/documentation/docs/api/locator.md +3 -1
- data/documentation/docs/api/page.md +4 -1
- data/documentation/package.json +6 -6
- data/documentation/yarn.lock +2931 -3220
- data/lib/playwright/channel_owners/browser_context.rb +8 -0
- data/lib/playwright/channel_owners/element_handle.rb +12 -3
- data/lib/playwright/channel_owners/frame.rb +4 -5
- data/lib/playwright/channel_owners/page.rb +11 -7
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/input_files.rb +60 -8
- data/lib/playwright/locator_impl.rb +5 -0
- data/lib/playwright/transport.rb +12 -2
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/accessibility.rb +2 -1
- data/lib/playwright_api/android.rb +8 -8
- data/lib/playwright_api/android_device.rb +6 -6
- data/lib/playwright_api/api_request.rb +3 -3
- data/lib/playwright_api/api_request_context.rb +21 -8
- data/lib/playwright_api/browser.rb +6 -6
- data/lib/playwright_api/browser_context.rb +11 -11
- data/lib/playwright_api/browser_type.rb +8 -8
- data/lib/playwright_api/cdp_session.rb +6 -6
- data/lib/playwright_api/console_message.rb +26 -7
- data/lib/playwright_api/dialog.rb +6 -6
- data/lib/playwright_api/element_handle.rb +40 -38
- data/lib/playwright_api/frame.rb +24 -24
- data/lib/playwright_api/frame_locator.rb +1 -1
- data/lib/playwright_api/js_handle.rb +6 -6
- data/lib/playwright_api/locator.rb +22 -20
- data/lib/playwright_api/page.rb +31 -28
- data/lib/playwright_api/playwright.rb +9 -9
- data/lib/playwright_api/request.rb +6 -6
- data/lib/playwright_api/response.rb +6 -6
- data/lib/playwright_api/route.rb +6 -6
- data/lib/playwright_api/selectors.rb +7 -7
- data/lib/playwright_api/tracing.rb +7 -7
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +8 -8
- metadata +4 -3
@@ -367,5 +367,13 @@ module Playwright
|
|
367
367
|
private def base_url
|
368
368
|
@options[:baseURL]
|
369
369
|
end
|
370
|
+
|
371
|
+
# called from InputFiles
|
372
|
+
# @param name [string]
|
373
|
+
# @return [WritableStream]
|
374
|
+
private def create_temp_file(name)
|
375
|
+
result = @channel.send_message_to_server('createTempFile', name: name)
|
376
|
+
ChannelOwners::WritableStream.from(result)
|
377
|
+
end
|
370
378
|
end
|
371
379
|
end
|
@@ -205,9 +205,14 @@ module Playwright
|
|
205
205
|
end
|
206
206
|
|
207
207
|
def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
208
|
-
|
209
|
-
|
210
|
-
|
208
|
+
frame = owner_frame
|
209
|
+
unless frame
|
210
|
+
raise 'Cannot set input files to detached element'
|
211
|
+
end
|
212
|
+
|
213
|
+
method_name, params = InputFiles.new(frame.page.context, files).as_method_and_params
|
214
|
+
params.merge!({ noWaitAfter: noWaitAfter, timeout: timeout }.compact)
|
215
|
+
@channel.send_message_to_server(method_name, params)
|
211
216
|
|
212
217
|
nil
|
213
218
|
end
|
@@ -282,18 +287,22 @@ module Playwright
|
|
282
287
|
|
283
288
|
def screenshot(
|
284
289
|
animations: nil,
|
290
|
+
caret: nil,
|
285
291
|
mask: nil,
|
286
292
|
omitBackground: nil,
|
287
293
|
path: nil,
|
288
294
|
quality: nil,
|
295
|
+
scale: nil,
|
289
296
|
timeout: nil,
|
290
297
|
type: nil)
|
291
298
|
|
292
299
|
params = {
|
293
300
|
animations: animations,
|
301
|
+
caret: caret,
|
294
302
|
omitBackground: omitBackground,
|
295
303
|
path: path,
|
296
304
|
quality: quality,
|
305
|
+
scale: scale,
|
297
306
|
timeout: timeout,
|
298
307
|
type: type,
|
299
308
|
}.compact
|
@@ -487,15 +487,14 @@ module Playwright
|
|
487
487
|
end
|
488
488
|
|
489
489
|
def set_input_files(selector, files, noWaitAfter: nil, strict: nil, timeout: nil)
|
490
|
-
|
491
|
-
params
|
492
|
-
files: file_payloads,
|
490
|
+
method_name, params = InputFiles.new(page.context, files).as_method_and_params
|
491
|
+
params.merge!({
|
493
492
|
selector: selector,
|
494
493
|
noWaitAfter: noWaitAfter,
|
495
494
|
strict: strict,
|
496
495
|
timeout: timeout,
|
497
|
-
}.compact
|
498
|
-
@channel.send_message_to_server(
|
496
|
+
}.compact)
|
497
|
+
@channel.send_message_to_server(method_name, params)
|
499
498
|
|
500
499
|
nil
|
501
500
|
end
|
@@ -408,15 +408,17 @@ module Playwright
|
|
408
408
|
end
|
409
409
|
|
410
410
|
def screenshot(
|
411
|
-
path: nil,
|
412
|
-
type: nil,
|
413
|
-
quality: nil,
|
414
|
-
fullPage: nil,
|
415
|
-
clip: nil,
|
416
|
-
omitBackground: nil,
|
417
411
|
animations: nil,
|
412
|
+
caret: nil,
|
413
|
+
clip: nil,
|
414
|
+
fullPage: nil,
|
418
415
|
mask: nil,
|
419
|
-
|
416
|
+
omitBackground: nil,
|
417
|
+
path: nil,
|
418
|
+
quality: nil,
|
419
|
+
scale: nil,
|
420
|
+
timeout: nil,
|
421
|
+
type: nil)
|
420
422
|
|
421
423
|
params = {
|
422
424
|
type: type,
|
@@ -425,6 +427,8 @@ module Playwright
|
|
425
427
|
clip: clip,
|
426
428
|
omitBackground: omitBackground,
|
427
429
|
animations: animations,
|
430
|
+
caret: caret,
|
431
|
+
scale: scale,
|
428
432
|
timeout: timeout,
|
429
433
|
}.compact
|
430
434
|
if mask.is_a?(Enumerable)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module Playwright
|
4
|
+
define_channel_owner :WritableStream do
|
5
|
+
# @param readable [File|IO]
|
6
|
+
def write(readable, bufsize = 1048576)
|
7
|
+
while buf = readable.read(bufsize)
|
8
|
+
binary = Base64.strict_encode64(buf)
|
9
|
+
@channel.send_message_to_server('write', binary: binary)
|
10
|
+
end
|
11
|
+
@channel.send_message_to_server('close')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -2,18 +2,64 @@ require 'base64'
|
|
2
2
|
|
3
3
|
module Playwright
|
4
4
|
class InputFiles
|
5
|
-
def initialize(files)
|
6
|
-
@
|
5
|
+
def initialize(context, files)
|
6
|
+
@context = context
|
7
|
+
if files.is_a?(Enumerable)
|
8
|
+
@files = files
|
9
|
+
else
|
10
|
+
@files = [files]
|
11
|
+
end
|
7
12
|
end
|
8
13
|
|
9
|
-
def
|
10
|
-
|
14
|
+
def as_method_and_params
|
15
|
+
if has_large_file?
|
16
|
+
['setInputFilePaths', params_for_set_input_file_paths]
|
17
|
+
else
|
18
|
+
['setInputFiles', params_for_set_input_files]
|
19
|
+
end
|
11
20
|
end
|
12
21
|
|
13
|
-
private def
|
14
|
-
|
22
|
+
private def has_large_file?
|
23
|
+
max_bufsize = 1024 * 1024 # 1MB
|
15
24
|
|
16
|
-
files.
|
25
|
+
@files.any? do |file|
|
26
|
+
case file
|
27
|
+
when String
|
28
|
+
File::Stat.new(file).size > max_bufsize
|
29
|
+
when File
|
30
|
+
file.stat.size > max_bufsize
|
31
|
+
else
|
32
|
+
raise_argument_error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private def params_for_set_input_file_paths
|
38
|
+
writable_streams = @files.map do |file|
|
39
|
+
case file
|
40
|
+
when String
|
41
|
+
writable_stream = @context.send(:create_temp_file, File.basename(file))
|
42
|
+
|
43
|
+
File.open(file, 'rb') do |file|
|
44
|
+
writable_stream.write(file)
|
45
|
+
end
|
46
|
+
|
47
|
+
writable_stream.channel
|
48
|
+
when File
|
49
|
+
writable_stream = @context.send(:create_temp_file, File.basename(file.path))
|
50
|
+
writable_stream.write(file)
|
51
|
+
|
52
|
+
writable_stream.channel
|
53
|
+
else
|
54
|
+
raise_argument_error
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
{ streams: writable_streams }
|
59
|
+
end
|
60
|
+
|
61
|
+
private def params_for_set_input_files
|
62
|
+
file_payloads = @files.map do |file|
|
17
63
|
case file
|
18
64
|
when String
|
19
65
|
{
|
@@ -26,9 +72,15 @@ module Playwright
|
|
26
72
|
buffer: Base64.strict_encode64(file.read),
|
27
73
|
}
|
28
74
|
else
|
29
|
-
|
75
|
+
raise_argument_error
|
30
76
|
end
|
31
77
|
end
|
78
|
+
|
79
|
+
{ files: file_payloads }
|
80
|
+
end
|
81
|
+
|
82
|
+
private def raise_argument_error
|
83
|
+
raise ArgumentError.new('file must be a String or File.')
|
32
84
|
end
|
33
85
|
end
|
34
86
|
end
|
@@ -314,19 +314,24 @@ module Playwright
|
|
314
314
|
|
315
315
|
def screenshot(
|
316
316
|
animations: nil,
|
317
|
+
caret: nil,
|
317
318
|
mask: nil,
|
318
319
|
omitBackground: nil,
|
319
320
|
path: nil,
|
320
321
|
quality: nil,
|
322
|
+
scale: nil,
|
321
323
|
timeout: nil,
|
322
324
|
type: nil)
|
325
|
+
|
323
326
|
with_element(timeout: timeout) do |handle, options|
|
324
327
|
handle.screenshot(
|
325
328
|
animations: animations,
|
329
|
+
caret: caret,
|
326
330
|
mask: mask,
|
327
331
|
omitBackground: omitBackground,
|
328
332
|
path: path,
|
329
333
|
quality: quality,
|
334
|
+
scale: scale,
|
330
335
|
timeout: options[:timeout],
|
331
336
|
type: type)
|
332
337
|
end
|
data/lib/playwright/transport.rb
CHANGED
@@ -110,12 +110,22 @@ module Playwright
|
|
110
110
|
|
111
111
|
def debug_send_message(message)
|
112
112
|
metadata = message.delete(:metadata)
|
113
|
-
puts "\x1b[33mSEND>\x1b[0m#{message}"
|
113
|
+
puts "\x1b[33mSEND>\x1b[0m#{shorten_double_quoted_string(message)}"
|
114
114
|
message[:metadata] = metadata
|
115
115
|
end
|
116
116
|
|
117
117
|
def debug_recv_message(message)
|
118
|
-
puts "\x1b[33mRECV>\x1b[0m#{message}"
|
118
|
+
puts "\x1b[33mRECV>\x1b[0m#{shorten_double_quoted_string(message)}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def shorten_double_quoted_string(message, maxlen: 512)
|
122
|
+
message.to_s.gsub(/"([^"]+)"/) do |str|
|
123
|
+
if $1.length > maxlen
|
124
|
+
"\"#{$1[0...maxlen]}...\""
|
125
|
+
else
|
126
|
+
str
|
127
|
+
end
|
128
|
+
end
|
119
129
|
end
|
120
130
|
end
|
121
131
|
end
|
data/lib/playwright/version.rb
CHANGED
@@ -35,7 +35,8 @@ module Playwright
|
|
35
35
|
# return node
|
36
36
|
# for child in (node.get("children") or []):
|
37
37
|
# found_node = find_focused_node(child)
|
38
|
-
#
|
38
|
+
# if (found_node)
|
39
|
+
# return found_node
|
39
40
|
# return None
|
40
41
|
#
|
41
42
|
# snapshot = page.accessibility.snapshot()
|
@@ -26,8 +26,8 @@ module Playwright
|
|
26
26
|
class Android < PlaywrightApi
|
27
27
|
|
28
28
|
# Returns the list of detected Android devices.
|
29
|
-
def devices(port: nil)
|
30
|
-
wrap_impl(@impl.devices(port: unwrap_impl(port)))
|
29
|
+
def devices(omitDriverInstall: nil, port: nil)
|
30
|
+
wrap_impl(@impl.devices(omitDriverInstall: unwrap_impl(omitDriverInstall), port: unwrap_impl(port)))
|
31
31
|
end
|
32
32
|
|
33
33
|
# This setting will change the default maximum time for all the methods accepting `timeout` option.
|
@@ -36,12 +36,6 @@ module Playwright
|
|
36
36
|
end
|
37
37
|
alias_method :default_timeout=, :set_default_timeout
|
38
38
|
|
39
|
-
# -- inherited from EventEmitter --
|
40
|
-
# @nodoc
|
41
|
-
def off(event, callback)
|
42
|
-
event_emitter_proxy.off(event, callback)
|
43
|
-
end
|
44
|
-
|
45
39
|
# -- inherited from EventEmitter --
|
46
40
|
# @nodoc
|
47
41
|
def once(event, callback)
|
@@ -54,6 +48,12 @@ module Playwright
|
|
54
48
|
event_emitter_proxy.on(event, callback)
|
55
49
|
end
|
56
50
|
|
51
|
+
# -- inherited from EventEmitter --
|
52
|
+
# @nodoc
|
53
|
+
def off(event, callback)
|
54
|
+
event_emitter_proxy.off(event, callback)
|
55
|
+
end
|
56
|
+
|
57
57
|
private def event_emitter_proxy
|
58
58
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
59
59
|
end
|
@@ -169,12 +169,6 @@ module Playwright
|
|
169
169
|
wrap_impl(@impl.tap_on(unwrap_impl(selector), duration: unwrap_impl(duration), timeout: unwrap_impl(timeout)))
|
170
170
|
end
|
171
171
|
|
172
|
-
# -- inherited from EventEmitter --
|
173
|
-
# @nodoc
|
174
|
-
def off(event, callback)
|
175
|
-
event_emitter_proxy.off(event, callback)
|
176
|
-
end
|
177
|
-
|
178
172
|
# -- inherited from EventEmitter --
|
179
173
|
# @nodoc
|
180
174
|
def once(event, callback)
|
@@ -187,6 +181,12 @@ module Playwright
|
|
187
181
|
event_emitter_proxy.on(event, callback)
|
188
182
|
end
|
189
183
|
|
184
|
+
# -- inherited from EventEmitter --
|
185
|
+
# @nodoc
|
186
|
+
def off(event, callback)
|
187
|
+
event_emitter_proxy.off(event, callback)
|
188
|
+
end
|
189
|
+
|
190
190
|
private def event_emitter_proxy
|
191
191
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
192
192
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Playwright
|
2
|
-
# Exposes API that can be used for the Web API testing.
|
3
|
-
#
|
4
|
-
#
|
2
|
+
# Exposes API that can be used for the Web API testing. This class is used for creating `APIRequestContext` instance which
|
3
|
+
# in turn can be used for sending web requests. An instance of this class can be obtained via
|
4
|
+
# [`property: Playwright.request`]. For more information see `APIRequestContext`.
|
5
5
|
class APIRequest < PlaywrightApi
|
6
6
|
|
7
7
|
# Creates new instances of `APIRequestContext`.
|
@@ -1,9 +1,22 @@
|
|
1
1
|
module Playwright
|
2
2
|
# This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
|
3
|
-
# environment or the service to your e2e test.
|
4
|
-
#
|
3
|
+
# environment or the service to your e2e test.
|
4
|
+
#
|
5
|
+
# Each Playwright browser context has associated with it `APIRequestContext` instance which shares cookie storage with the
|
6
|
+
# browser context and can be accessed via [`property: BrowserContext.request`] or [`property: Page.request`]. It is also
|
7
|
+
# possible to create a new APIRequestContext instance manually by calling [`method: APIRequest.newContext`].
|
8
|
+
#
|
9
|
+
# **Cookie management**
|
10
|
+
#
|
11
|
+
# `APIRequestContext` retuned by [`property: BrowserContext.request`] and [`property: Page.request`] shares cookie storage
|
12
|
+
# with the corresponding `BrowserContext`. Each API request will have `Cookie` header populated with the values from the
|
13
|
+
# browser context. If the API response contains `Set-Cookie` header it will automatically update `BrowserContext` cookies
|
14
|
+
# and requests made from the page will pick them up. This means that if you log in using this API, your e2e test will be
|
5
15
|
# logged in and vice versa.
|
6
16
|
#
|
17
|
+
# If you want API requests to not interfere with the browser cookies you shoud create a new `APIRequestContext` by calling
|
18
|
+
# [`method: APIRequest.newContext`]. Such `APIRequestContext` object will have its own isolated cookie storage.
|
19
|
+
#
|
7
20
|
# ```python sync
|
8
21
|
# import os
|
9
22
|
# from playwright.sync_api import sync_playwright
|
@@ -171,12 +184,6 @@ module Playwright
|
|
171
184
|
raise NotImplementedError.new('storage_state is not implemented yet.')
|
172
185
|
end
|
173
186
|
|
174
|
-
# -- inherited from EventEmitter --
|
175
|
-
# @nodoc
|
176
|
-
def off(event, callback)
|
177
|
-
event_emitter_proxy.off(event, callback)
|
178
|
-
end
|
179
|
-
|
180
187
|
# -- inherited from EventEmitter --
|
181
188
|
# @nodoc
|
182
189
|
def once(event, callback)
|
@@ -189,6 +196,12 @@ module Playwright
|
|
189
196
|
event_emitter_proxy.on(event, callback)
|
190
197
|
end
|
191
198
|
|
199
|
+
# -- inherited from EventEmitter --
|
200
|
+
# @nodoc
|
201
|
+
def off(event, callback)
|
202
|
+
event_emitter_proxy.off(event, callback)
|
203
|
+
end
|
204
|
+
|
192
205
|
private def event_emitter_proxy
|
193
206
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
194
207
|
end
|
@@ -166,12 +166,6 @@ module Playwright
|
|
166
166
|
wrap_impl(@impl.version)
|
167
167
|
end
|
168
168
|
|
169
|
-
# -- inherited from EventEmitter --
|
170
|
-
# @nodoc
|
171
|
-
def off(event, callback)
|
172
|
-
event_emitter_proxy.off(event, callback)
|
173
|
-
end
|
174
|
-
|
175
169
|
# -- inherited from EventEmitter --
|
176
170
|
# @nodoc
|
177
171
|
def once(event, callback)
|
@@ -184,6 +178,12 @@ module Playwright
|
|
184
178
|
event_emitter_proxy.on(event, callback)
|
185
179
|
end
|
186
180
|
|
181
|
+
# -- inherited from EventEmitter --
|
182
|
+
# @nodoc
|
183
|
+
def off(event, callback)
|
184
|
+
event_emitter_proxy.off(event, callback)
|
185
|
+
end
|
186
|
+
|
187
187
|
private def event_emitter_proxy
|
188
188
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
189
189
|
end
|
@@ -376,6 +376,11 @@ module Playwright
|
|
376
376
|
wrap_impl(@impl.pause)
|
377
377
|
end
|
378
378
|
|
379
|
+
# @nodoc
|
380
|
+
def options=(req)
|
381
|
+
wrap_impl(@impl.options=(unwrap_impl(req)))
|
382
|
+
end
|
383
|
+
|
379
384
|
# @nodoc
|
380
385
|
def enable_debug_console!
|
381
386
|
wrap_impl(@impl.enable_debug_console!)
|
@@ -391,17 +396,6 @@ module Playwright
|
|
391
396
|
wrap_impl(@impl.owner_page=(unwrap_impl(req)))
|
392
397
|
end
|
393
398
|
|
394
|
-
# @nodoc
|
395
|
-
def options=(req)
|
396
|
-
wrap_impl(@impl.options=(unwrap_impl(req)))
|
397
|
-
end
|
398
|
-
|
399
|
-
# -- inherited from EventEmitter --
|
400
|
-
# @nodoc
|
401
|
-
def off(event, callback)
|
402
|
-
event_emitter_proxy.off(event, callback)
|
403
|
-
end
|
404
|
-
|
405
399
|
# -- inherited from EventEmitter --
|
406
400
|
# @nodoc
|
407
401
|
def once(event, callback)
|
@@ -414,6 +408,12 @@ module Playwright
|
|
414
408
|
event_emitter_proxy.on(event, callback)
|
415
409
|
end
|
416
410
|
|
411
|
+
# -- inherited from EventEmitter --
|
412
|
+
# @nodoc
|
413
|
+
def off(event, callback)
|
414
|
+
event_emitter_proxy.off(event, callback)
|
415
|
+
end
|
416
|
+
|
417
417
|
private def event_emitter_proxy
|
418
418
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
419
419
|
end
|
@@ -18,12 +18,12 @@ module Playwright
|
|
18
18
|
# ```
|
19
19
|
class BrowserType < PlaywrightApi
|
20
20
|
|
21
|
-
# This
|
21
|
+
# This method attaches Playwright to an existing browser instance.
|
22
22
|
def connect(wsEndpoint, headers: nil, slowMo: nil, timeout: nil)
|
23
23
|
raise NotImplementedError.new('connect is not implemented yet.')
|
24
24
|
end
|
25
25
|
|
26
|
-
# This
|
26
|
+
# This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
|
27
27
|
#
|
28
28
|
# The default browser context is accessible via [`method: Browser.contexts`].
|
29
29
|
#
|
@@ -146,12 +146,6 @@ module Playwright
|
|
146
146
|
wrap_impl(@impl.name)
|
147
147
|
end
|
148
148
|
|
149
|
-
# -- inherited from EventEmitter --
|
150
|
-
# @nodoc
|
151
|
-
def off(event, callback)
|
152
|
-
event_emitter_proxy.off(event, callback)
|
153
|
-
end
|
154
|
-
|
155
149
|
# -- inherited from EventEmitter --
|
156
150
|
# @nodoc
|
157
151
|
def once(event, callback)
|
@@ -164,6 +158,12 @@ module Playwright
|
|
164
158
|
event_emitter_proxy.on(event, callback)
|
165
159
|
end
|
166
160
|
|
161
|
+
# -- inherited from EventEmitter --
|
162
|
+
# @nodoc
|
163
|
+
def off(event, callback)
|
164
|
+
event_emitter_proxy.off(event, callback)
|
165
|
+
end
|
166
|
+
|
167
167
|
private def event_emitter_proxy
|
168
168
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
169
169
|
end
|
@@ -33,12 +33,6 @@ module Playwright
|
|
33
33
|
wrap_impl(@impl.send_message(unwrap_impl(method), params: unwrap_impl(params)))
|
34
34
|
end
|
35
35
|
|
36
|
-
# -- inherited from EventEmitter --
|
37
|
-
# @nodoc
|
38
|
-
def off(event, callback)
|
39
|
-
event_emitter_proxy.off(event, callback)
|
40
|
-
end
|
41
|
-
|
42
36
|
# -- inherited from EventEmitter --
|
43
37
|
# @nodoc
|
44
38
|
def once(event, callback)
|
@@ -51,6 +45,12 @@ module Playwright
|
|
51
45
|
event_emitter_proxy.on(event, callback)
|
52
46
|
end
|
53
47
|
|
48
|
+
# -- inherited from EventEmitter --
|
49
|
+
# @nodoc
|
50
|
+
def off(event, callback)
|
51
|
+
event_emitter_proxy.off(event, callback)
|
52
|
+
end
|
53
|
+
|
54
54
|
private def event_emitter_proxy
|
55
55
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
56
56
|
end
|
@@ -1,5 +1,24 @@
|
|
1
1
|
module Playwright
|
2
|
-
# `ConsoleMessage` objects are dispatched by page via the [`event: Page.console`] event.
|
2
|
+
# `ConsoleMessage` objects are dispatched by page via the [`event: Page.console`] event. For each console messages logged
|
3
|
+
# in the page there will be corresponding event in the Playwright context.
|
4
|
+
#
|
5
|
+
# ```python sync
|
6
|
+
# # Listen for all console logs
|
7
|
+
# page.on("console", lambda msg: print(msg.text))
|
8
|
+
#
|
9
|
+
# # Listen for all console events and handle errors
|
10
|
+
# page.on("console", lambda msg: print(f"error: {msg.text}") if msg.type == "error" else None)
|
11
|
+
#
|
12
|
+
# # Get the next console log
|
13
|
+
# with page.expect_console_message() as msg_info:
|
14
|
+
# # Issue console.log inside the page
|
15
|
+
# page.evaluate("console.log('hello', 42, { foo: 'bar' })")
|
16
|
+
# msg = msg_info.value
|
17
|
+
#
|
18
|
+
# # Deconstruct print arguments
|
19
|
+
# msg.args[0].json_value() # hello
|
20
|
+
# msg.args[1].json_value() # 42
|
21
|
+
# ```
|
3
22
|
class ConsoleMessage < PlaywrightApi
|
4
23
|
|
5
24
|
# List of arguments passed to a `console` function call. See also [`event: Page.console`].
|
@@ -23,12 +42,6 @@ module Playwright
|
|
23
42
|
wrap_impl(@impl.type)
|
24
43
|
end
|
25
44
|
|
26
|
-
# -- inherited from EventEmitter --
|
27
|
-
# @nodoc
|
28
|
-
def off(event, callback)
|
29
|
-
event_emitter_proxy.off(event, callback)
|
30
|
-
end
|
31
|
-
|
32
45
|
# -- inherited from EventEmitter --
|
33
46
|
# @nodoc
|
34
47
|
def once(event, callback)
|
@@ -41,6 +54,12 @@ module Playwright
|
|
41
54
|
event_emitter_proxy.on(event, callback)
|
42
55
|
end
|
43
56
|
|
57
|
+
# -- inherited from EventEmitter --
|
58
|
+
# @nodoc
|
59
|
+
def off(event, callback)
|
60
|
+
event_emitter_proxy.off(event, callback)
|
61
|
+
end
|
62
|
+
|
44
63
|
private def event_emitter_proxy
|
45
64
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
46
65
|
end
|
@@ -58,12 +58,6 @@ module Playwright
|
|
58
58
|
wrap_impl(@impl.accept_async(promptText: unwrap_impl(promptText)))
|
59
59
|
end
|
60
60
|
|
61
|
-
# -- inherited from EventEmitter --
|
62
|
-
# @nodoc
|
63
|
-
def off(event, callback)
|
64
|
-
event_emitter_proxy.off(event, callback)
|
65
|
-
end
|
66
|
-
|
67
61
|
# -- inherited from EventEmitter --
|
68
62
|
# @nodoc
|
69
63
|
def once(event, callback)
|
@@ -76,6 +70,12 @@ module Playwright
|
|
76
70
|
event_emitter_proxy.on(event, callback)
|
77
71
|
end
|
78
72
|
|
73
|
+
# -- inherited from EventEmitter --
|
74
|
+
# @nodoc
|
75
|
+
def off(event, callback)
|
76
|
+
event_emitter_proxy.off(event, callback)
|
77
|
+
end
|
78
|
+
|
79
79
|
private def event_emitter_proxy
|
80
80
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
81
81
|
end
|