playwright-ruby-client 1.20.0 → 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/android.rb +2 -1
- data/lib/playwright/channel_owners/android_device.rb +0 -4
- data/lib/playwright/channel_owners/browser_context.rb +11 -2
- 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 +12 -8
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/input_files.rb +60 -8
- data/lib/playwright/javascript/value_parser.rb +13 -15
- data/lib/playwright/locator_impl.rb +5 -0
- data/lib/playwright/route_handler.rb +5 -3
- data/lib/playwright/transport.rb +12 -3
- 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 -11
- 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
|
@@ -5,7 +5,8 @@ module Playwright
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
def devices(port: nil)
|
|
8
|
-
|
|
8
|
+
params = { port: port }.compact
|
|
9
|
+
resp = @channel.send_message_to_server('devices', params)
|
|
9
10
|
resp.map { |device| ChannelOwners::AndroidDevice.from(device) }
|
|
10
11
|
end
|
|
11
12
|
end
|
|
@@ -65,10 +65,6 @@ module Playwright
|
|
|
65
65
|
@channel.send_message_to_server('info', selector: to_selector_channel(selector))
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
def tree
|
|
69
|
-
@channel.send_message_to_server('tree')
|
|
70
|
-
end
|
|
71
|
-
|
|
72
68
|
def screenshot(path: nil)
|
|
73
69
|
encoded_binary = @channel.send_message_to_server('screenshot')
|
|
74
70
|
decoded_binary = Base64.strict_decode64(encoded_binary)
|
|
@@ -13,6 +13,7 @@ module Playwright
|
|
|
13
13
|
@timeout_settings = TimeoutSettings.new
|
|
14
14
|
@service_workers = Set.new
|
|
15
15
|
@background_pages = Set.new
|
|
16
|
+
@owner_page = nil
|
|
16
17
|
|
|
17
18
|
@tracing = ChannelOwners::Tracing.from(@initializer['tracing'])
|
|
18
19
|
@request = ChannelOwners::APIRequestContext.from(@initializer['APIRequestContext'])
|
|
@@ -179,7 +180,7 @@ module Playwright
|
|
|
179
180
|
else
|
|
180
181
|
[urls]
|
|
181
182
|
end
|
|
182
|
-
@channel.send_message_to_server('cookies', urls:
|
|
183
|
+
@channel.send_message_to_server('cookies', urls: target_urls)
|
|
183
184
|
end
|
|
184
185
|
|
|
185
186
|
def add_cookies(cookies)
|
|
@@ -225,7 +226,7 @@ module Playwright
|
|
|
225
226
|
raise ArgumentError.new('Either path or script parameter must be specified')
|
|
226
227
|
end
|
|
227
228
|
|
|
228
|
-
@channel.send_message_to_server('addInitScript', source:
|
|
229
|
+
@channel.send_message_to_server('addInitScript', source: source)
|
|
229
230
|
nil
|
|
230
231
|
end
|
|
231
232
|
|
|
@@ -366,5 +367,13 @@ module Playwright
|
|
|
366
367
|
private def base_url
|
|
367
368
|
@options[:baseURL]
|
|
368
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
|
|
369
378
|
end
|
|
370
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
|
|
@@ -386,7 +386,7 @@ module Playwright
|
|
|
386
386
|
raise ArgumentError.new('Either path or script parameter must be specified')
|
|
387
387
|
end
|
|
388
388
|
|
|
389
|
-
@channel.send_message_to_server('addInitScript', source:
|
|
389
|
+
@channel.send_message_to_server('addInitScript', source: source)
|
|
390
390
|
nil
|
|
391
391
|
end
|
|
392
392
|
|
|
@@ -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
|
|
@@ -24,21 +24,19 @@ module Playwright
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
if hash.key?('v')
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-0
|
|
41
|
-
end
|
|
27
|
+
return case hash['v']
|
|
28
|
+
when 'undefined'
|
|
29
|
+
nil
|
|
30
|
+
when 'null'
|
|
31
|
+
nil
|
|
32
|
+
when 'NaN'
|
|
33
|
+
Float::NAN
|
|
34
|
+
when 'Infinity'
|
|
35
|
+
Float::INFINITY
|
|
36
|
+
when '-Infinity'
|
|
37
|
+
-Float::INFINITY when '-0'
|
|
38
|
+
-0
|
|
39
|
+
end
|
|
42
40
|
end
|
|
43
41
|
|
|
44
42
|
if hash.key?('d')
|
|
@@ -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
|
|
@@ -51,9 +51,11 @@ module Playwright
|
|
|
51
51
|
@counter.increment
|
|
52
52
|
|
|
53
53
|
Concurrent::Promises.future do
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
begin
|
|
55
|
+
@handler.call(route, request)
|
|
56
|
+
rescue => err
|
|
57
|
+
puts err, err.backtrace
|
|
58
|
+
end
|
|
57
59
|
end
|
|
58
60
|
end
|
|
59
61
|
|
data/lib/playwright/transport.rb
CHANGED
|
@@ -46,7 +46,6 @@ module Playwright
|
|
|
46
46
|
#
|
|
47
47
|
# @note This method blocks until playwright-cli exited. Consider using Thread or Future.
|
|
48
48
|
def async_run
|
|
49
|
-
popen3_args = {}
|
|
50
49
|
@stdin, @stdout, @stderr, @thread = run_driver_with_open3
|
|
51
50
|
@stdin.binmode # Ensure Strings are written 1:1 without encoding conversion, necessary for integer values
|
|
52
51
|
|
|
@@ -111,12 +110,22 @@ module Playwright
|
|
|
111
110
|
|
|
112
111
|
def debug_send_message(message)
|
|
113
112
|
metadata = message.delete(:metadata)
|
|
114
|
-
puts "\x1b[33mSEND>\x1b[0m#{message}"
|
|
113
|
+
puts "\x1b[33mSEND>\x1b[0m#{shorten_double_quoted_string(message)}"
|
|
115
114
|
message[:metadata] = metadata
|
|
116
115
|
end
|
|
117
116
|
|
|
118
117
|
def debug_recv_message(message)
|
|
119
|
-
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
|
|
120
129
|
end
|
|
121
130
|
end
|
|
122
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,17 +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
|
-
# @nodoc
|
|
173
|
-
def tree
|
|
174
|
-
wrap_impl(@impl.tree)
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
# -- inherited from EventEmitter --
|
|
178
|
-
# @nodoc
|
|
179
|
-
def off(event, callback)
|
|
180
|
-
event_emitter_proxy.off(event, callback)
|
|
181
|
-
end
|
|
182
|
-
|
|
183
172
|
# -- inherited from EventEmitter --
|
|
184
173
|
# @nodoc
|
|
185
174
|
def once(event, callback)
|
|
@@ -192,6 +181,12 @@ module Playwright
|
|
|
192
181
|
event_emitter_proxy.on(event, callback)
|
|
193
182
|
end
|
|
194
183
|
|
|
184
|
+
# -- inherited from EventEmitter --
|
|
185
|
+
# @nodoc
|
|
186
|
+
def off(event, callback)
|
|
187
|
+
event_emitter_proxy.off(event, callback)
|
|
188
|
+
end
|
|
189
|
+
|
|
195
190
|
private def event_emitter_proxy
|
|
196
191
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
|
197
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
|