playwright-ruby-client 0.5.7 → 0.6.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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/documentation/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/accessibility.md +7 -0
- data/documentation/docs/api/browser.md +185 -0
- data/documentation/docs/api/browser_context.md +398 -0
- data/documentation/docs/api/browser_type.md +105 -0
- data/documentation/docs/api/cdp_session.md +7 -0
- data/documentation/docs/api/console_message.md +41 -0
- data/documentation/docs/api/dialog.md +74 -0
- data/documentation/docs/api/element_handle.md +640 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +25 -0
- data/documentation/docs/api/experimental/android_device.md +91 -0
- data/documentation/docs/api/experimental/android_input.md +38 -0
- data/documentation/docs/api/experimental/android_socket.md +7 -0
- data/documentation/docs/api/experimental/android_web_view.md +7 -0
- data/documentation/docs/api/file_chooser.md +51 -0
- data/documentation/docs/api/frame.md +867 -0
- data/documentation/docs/api/js_handle.md +116 -0
- data/documentation/docs/api/keyboard.md +157 -0
- data/documentation/docs/api/mouse.md +69 -0
- data/documentation/docs/api/page.md +1469 -0
- data/documentation/docs/api/playwright.md +63 -0
- data/documentation/docs/api/request.md +188 -0
- data/documentation/docs/api/response.md +97 -0
- data/documentation/docs/api/route.md +80 -0
- data/documentation/docs/api/selectors.md +23 -0
- data/documentation/docs/api/touchscreen.md +8 -0
- data/documentation/docs/api/tracing.md +54 -0
- data/documentation/docs/api/web_socket.md +7 -0
- data/documentation/docs/api/worker.md +7 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +152 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +49 -0
- data/documentation/docs/article/guides/launch_browser.md +119 -0
- data/documentation/docs/article/guides/rails_integration.md +51 -0
- data/{docs → documentation/docs/include}/api_coverage.md +10 -1
- data/documentation/docusaurus.config.js +107 -0
- data/documentation/package.json +39 -0
- data/documentation/sidebars.js +15 -0
- data/documentation/src/components/HomepageFeatures.js +61 -0
- data/documentation/src/components/HomepageFeatures.module.css +13 -0
- data/documentation/src/css/custom.css +44 -0
- data/documentation/src/pages/index.js +50 -0
- data/documentation/src/pages/index.module.css +41 -0
- data/documentation/src/pages/markdown-page.md +7 -0
- data/documentation/static/.nojekyll +0 -0
- data/documentation/static/img/playwright-logo.svg +9 -0
- data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
- data/documentation/static/img/undraw_web_development.svg +1 -0
- data/documentation/static/img/undraw_windows.svg +1 -0
- data/documentation/yarn.lock +8805 -0
- data/lib/playwright/channel_owner.rb +3 -0
- data/lib/playwright/channel_owners/binding_call.rb +33 -0
- data/lib/playwright/channel_owners/browser.rb +27 -2
- data/lib/playwright/channel_owners/browser_context.rb +54 -3
- data/lib/playwright/channel_owners/browser_type.rb +8 -1
- data/lib/playwright/channel_owners/element_handle.rb +17 -16
- data/lib/playwright/channel_owners/frame.rb +29 -34
- data/lib/playwright/channel_owners/js_handle.rb +2 -10
- data/lib/playwright/channel_owners/page.rb +29 -45
- data/lib/playwright/download.rb +3 -2
- data/lib/playwright/events.rb +4 -0
- data/lib/playwright/input_files.rb +0 -8
- data/lib/playwright/javascript.rb +0 -10
- data/lib/playwright/javascript/expression.rb +2 -7
- data/lib/playwright/playwright_api.rb +1 -5
- data/lib/playwright/tracing_impl.rb +31 -0
- data/lib/playwright/version.rb +2 -1
- data/lib/playwright_api/accessibility.rb +7 -88
- data/lib/playwright_api/android.rb +8 -65
- data/lib/playwright_api/android_device.rb +8 -8
- data/lib/playwright_api/browser.rb +15 -126
- data/lib/playwright_api/browser_context.rb +63 -429
- data/lib/playwright_api/browser_type.rb +33 -84
- data/lib/playwright_api/cdp_session.rb +2 -25
- data/lib/playwright_api/console_message.rb +8 -6
- data/lib/playwright_api/dialog.rb +11 -69
- data/lib/playwright_api/element_handle.rb +102 -300
- data/lib/playwright_api/file_chooser.rb +0 -21
- data/lib/playwright_api/frame.rb +105 -571
- data/lib/playwright_api/js_handle.rb +16 -73
- data/lib/playwright_api/keyboard.rb +22 -166
- data/lib/playwright_api/mouse.rb +1 -45
- data/lib/playwright_api/page.rb +202 -1217
- data/lib/playwright_api/playwright.rb +14 -99
- data/lib/playwright_api/request.rb +15 -93
- data/lib/playwright_api/response.rb +7 -7
- data/lib/playwright_api/route.rb +9 -86
- data/lib/playwright_api/selectors.rb +6 -72
- data/lib/playwright_api/tracing.rb +39 -0
- data/lib/playwright_api/web_socket.rb +1 -1
- data/lib/playwright_api/worker.rb +6 -42
- data/playwright.gemspec +2 -2
- metadata +59 -20
- data/lib/playwright/javascript/function.rb +0 -67
|
@@ -14,19 +14,11 @@ module Playwright
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def evaluate(pageFunction, arg: nil)
|
|
17
|
-
|
|
18
|
-
JavaScript::Function.new(pageFunction, arg).evaluate(@channel)
|
|
19
|
-
else
|
|
20
|
-
JavaScript::Expression.new(pageFunction).evaluate(@channel)
|
|
21
|
-
end
|
|
17
|
+
JavaScript::Expression.new(pageFunction, arg).evaluate(@channel)
|
|
22
18
|
end
|
|
23
19
|
|
|
24
20
|
def evaluate_handle(pageFunction, arg: nil)
|
|
25
|
-
|
|
26
|
-
JavaScript::Function.new(pageFunction, arg).evaluate_handle(@channel)
|
|
27
|
-
else
|
|
28
|
-
JavaScript::Expression.new(pageFunction).evaluate_handle(@channel)
|
|
29
|
-
end
|
|
21
|
+
JavaScript::Expression.new(pageFunction, arg).evaluate_handle(@channel)
|
|
30
22
|
end
|
|
31
23
|
|
|
32
24
|
def get_properties
|
|
@@ -30,6 +30,7 @@ module Playwright
|
|
|
30
30
|
@frames << @main_frame
|
|
31
31
|
@opener = ChannelOwners::Page.from_nullable(@initializer['opener'])
|
|
32
32
|
|
|
33
|
+
@channel.on('bindingCall', ->(params) { on_binding(ChannelOwners::BindingCall.from(params['binding'])) })
|
|
33
34
|
@channel.once('close', ->(_) { on_close })
|
|
34
35
|
@channel.on('console', ->(params) {
|
|
35
36
|
console_message = ChannelOwners::ConsoleMessage.from(params['message'])
|
|
@@ -56,25 +57,6 @@ module Playwright
|
|
|
56
57
|
@channel.on('pageError', ->(params) {
|
|
57
58
|
emit(Events::Page::PageError, Error.parse(params['error']['error']))
|
|
58
59
|
})
|
|
59
|
-
@channel.on('request', ->(params) {
|
|
60
|
-
emit(Events::Page::Request, ChannelOwners::Request.from(params['request']))
|
|
61
|
-
})
|
|
62
|
-
@channel.on('requestFailed', ->(params) {
|
|
63
|
-
on_request_failed(
|
|
64
|
-
ChannelOwners::Request.from(params['request']),
|
|
65
|
-
params['responseEndTiming'],
|
|
66
|
-
params['failureText'],
|
|
67
|
-
)
|
|
68
|
-
})
|
|
69
|
-
@channel.on('requestFinished', ->(params) {
|
|
70
|
-
on_request_finished(
|
|
71
|
-
ChannelOwners::Request.from(params['request']),
|
|
72
|
-
params['responseEndTiming'],
|
|
73
|
-
)
|
|
74
|
-
})
|
|
75
|
-
@channel.on('response', ->(params) {
|
|
76
|
-
emit(Events::Page::Response, ChannelOwners::Response.from(params['response']))
|
|
77
|
-
})
|
|
78
60
|
@channel.on('route', ->(params) {
|
|
79
61
|
on_route(ChannelOwners::Route.from(params['route']), ChannelOwners::Request.from(params['request']))
|
|
80
62
|
})
|
|
@@ -95,17 +77,6 @@ module Playwright
|
|
|
95
77
|
:viewport_size,
|
|
96
78
|
:main_frame
|
|
97
79
|
|
|
98
|
-
private def on_request_failed(request, response_end_timing, failure_text)
|
|
99
|
-
request.send(:update_failure_text, failure_text)
|
|
100
|
-
request.send(:update_response_end_timing, response_end_timing)
|
|
101
|
-
emit(Events::Page::RequestFailed, request)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
private def on_request_finished(request, response_end_timing)
|
|
105
|
-
request.send(:update_response_end_timing, response_end_timing)
|
|
106
|
-
emit(Events::Page::RequestFinished, request)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
80
|
private def on_frame_attached(frame)
|
|
110
81
|
frame.send(:update_page_from_page, self)
|
|
111
82
|
@frames << frame
|
|
@@ -130,6 +101,14 @@ module Playwright
|
|
|
130
101
|
end
|
|
131
102
|
end
|
|
132
103
|
|
|
104
|
+
private def on_binding(binding_call)
|
|
105
|
+
func = @bindings[binding_call.name]
|
|
106
|
+
if func
|
|
107
|
+
binding_call.call_async(func)
|
|
108
|
+
end
|
|
109
|
+
@browser_context.send(:on_binding, binding_call)
|
|
110
|
+
end
|
|
111
|
+
|
|
133
112
|
private def on_close
|
|
134
113
|
@closed = true
|
|
135
114
|
@browser_context.send(:remove_page, self)
|
|
@@ -145,6 +124,7 @@ module Playwright
|
|
|
145
124
|
|
|
146
125
|
private def on_download(params)
|
|
147
126
|
download = Download.new(
|
|
127
|
+
page: self,
|
|
148
128
|
url: params['url'],
|
|
149
129
|
suggested_filename: params['suggestedFilename'],
|
|
150
130
|
artifact: ChannelOwners::Artifact.from(params['artifact']),
|
|
@@ -335,7 +315,7 @@ module Playwright
|
|
|
335
315
|
timeout: timeout,
|
|
336
316
|
waitUntil: waitUntil,
|
|
337
317
|
}.compact
|
|
338
|
-
resp = @channel.send_message_to_server('
|
|
318
|
+
resp = @channel.send_message_to_server('reload', params)
|
|
339
319
|
ChannelOwners::Response.from_nullable(resp)
|
|
340
320
|
end
|
|
341
321
|
|
|
@@ -464,7 +444,8 @@ module Playwright
|
|
|
464
444
|
modifiers: nil,
|
|
465
445
|
noWaitAfter: nil,
|
|
466
446
|
position: nil,
|
|
467
|
-
timeout: nil
|
|
447
|
+
timeout: nil,
|
|
448
|
+
trial: nil)
|
|
468
449
|
|
|
469
450
|
@main_frame.click(
|
|
470
451
|
selector,
|
|
@@ -476,6 +457,7 @@ module Playwright
|
|
|
476
457
|
noWaitAfter: noWaitAfter,
|
|
477
458
|
position: position,
|
|
478
459
|
timeout: timeout,
|
|
460
|
+
trial: trial,
|
|
479
461
|
)
|
|
480
462
|
end
|
|
481
463
|
|
|
@@ -487,7 +469,8 @@ module Playwright
|
|
|
487
469
|
modifiers: nil,
|
|
488
470
|
noWaitAfter: nil,
|
|
489
471
|
position: nil,
|
|
490
|
-
timeout: nil
|
|
472
|
+
timeout: nil,
|
|
473
|
+
trial: nil)
|
|
491
474
|
@main_frame.dblclick(
|
|
492
475
|
selector,
|
|
493
476
|
button: button,
|
|
@@ -497,6 +480,7 @@ module Playwright
|
|
|
497
480
|
noWaitAfter: noWaitAfter,
|
|
498
481
|
position: position,
|
|
499
482
|
timeout: timeout,
|
|
483
|
+
trial: trial,
|
|
500
484
|
)
|
|
501
485
|
end
|
|
502
486
|
|
|
@@ -506,7 +490,8 @@ module Playwright
|
|
|
506
490
|
modifiers: nil,
|
|
507
491
|
noWaitAfter: nil,
|
|
508
492
|
position: nil,
|
|
509
|
-
timeout: nil
|
|
493
|
+
timeout: nil,
|
|
494
|
+
trial: nil)
|
|
510
495
|
@main_frame.tap_point(
|
|
511
496
|
selector,
|
|
512
497
|
force: force,
|
|
@@ -514,6 +499,7 @@ module Playwright
|
|
|
514
499
|
noWaitAfter: noWaitAfter,
|
|
515
500
|
position: position,
|
|
516
501
|
timeout: timeout,
|
|
502
|
+
trial: trial,
|
|
517
503
|
)
|
|
518
504
|
end
|
|
519
505
|
|
|
@@ -546,13 +532,15 @@ module Playwright
|
|
|
546
532
|
force: nil,
|
|
547
533
|
modifiers: nil,
|
|
548
534
|
position: nil,
|
|
549
|
-
timeout: nil
|
|
535
|
+
timeout: nil,
|
|
536
|
+
trial: nil)
|
|
550
537
|
@main_frame.hover(
|
|
551
538
|
selector,
|
|
552
539
|
force: force,
|
|
553
540
|
modifiers: modifiers,
|
|
554
541
|
position: position,
|
|
555
542
|
timeout: timeout,
|
|
543
|
+
trial: trial,
|
|
556
544
|
)
|
|
557
545
|
end
|
|
558
546
|
|
|
@@ -604,9 +592,10 @@ module Playwright
|
|
|
604
592
|
force: nil,
|
|
605
593
|
noWaitAfter: nil,
|
|
606
594
|
position: nil,
|
|
607
|
-
timeout: nil
|
|
595
|
+
timeout: nil,
|
|
596
|
+
trial: nil)
|
|
608
597
|
|
|
609
|
-
@main_frame.check(selector, force: force, noWaitAfter: noWaitAfter, position: position, timeout: timeout)
|
|
598
|
+
@main_frame.check(selector, force: force, noWaitAfter: noWaitAfter, position: position, timeout: timeout, trial: trial)
|
|
610
599
|
end
|
|
611
600
|
|
|
612
601
|
def uncheck(
|
|
@@ -614,9 +603,10 @@ module Playwright
|
|
|
614
603
|
force: nil,
|
|
615
604
|
noWaitAfter: nil,
|
|
616
605
|
position: nil,
|
|
617
|
-
timeout: nil
|
|
606
|
+
timeout: nil,
|
|
607
|
+
trial: nil)
|
|
618
608
|
|
|
619
|
-
@main_frame.uncheck(selector, force: force, noWaitAfter: noWaitAfter, position: position, timeout: timeout)
|
|
609
|
+
@main_frame.uncheck(selector, force: force, noWaitAfter: noWaitAfter, position: position, timeout: timeout, trial: trial)
|
|
620
610
|
end
|
|
621
611
|
|
|
622
612
|
def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
|
|
@@ -783,12 +773,6 @@ module Playwright
|
|
|
783
773
|
expect_event(Events::Page::Response, predicate: predicate, timeout: timeout)
|
|
784
774
|
end
|
|
785
775
|
|
|
786
|
-
# called from BrowserContext#on_page with send(:update_browser_context, page), so keep private.
|
|
787
|
-
private def update_browser_context(context)
|
|
788
|
-
@browser_context = context
|
|
789
|
-
@timeout_settings = TimeoutSettings.new(context.send(:_timeout_settings))
|
|
790
|
-
end
|
|
791
|
-
|
|
792
776
|
# called from Frame with send(:timeout_settings)
|
|
793
777
|
private def timeout_settings
|
|
794
778
|
@timeout_settings
|
data/lib/playwright/download.rb
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
module Playwright
|
|
2
2
|
class Download
|
|
3
|
-
def initialize(url:, suggested_filename:, artifact:)
|
|
3
|
+
def initialize(page:, url:, suggested_filename:, artifact:)
|
|
4
|
+
@page = page
|
|
4
5
|
@url = url
|
|
5
6
|
@suggested_filename = suggested_filename
|
|
6
7
|
@artifact = artifact
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
attr_reader :url, :suggested_filename
|
|
10
|
+
attr_reader :page, :url, :suggested_filename
|
|
10
11
|
|
|
11
12
|
def delete
|
|
12
13
|
@artifact.delete
|
data/lib/playwright/events.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'base64'
|
|
2
|
-
require 'mime/types'
|
|
3
2
|
|
|
4
3
|
module Playwright
|
|
5
4
|
class InputFiles
|
|
@@ -19,13 +18,11 @@ module Playwright
|
|
|
19
18
|
when String
|
|
20
19
|
{
|
|
21
20
|
name: File.basename(file),
|
|
22
|
-
mimeType: mime_type_for(file),
|
|
23
21
|
buffer: Base64.strict_encode64(File.read(file)),
|
|
24
22
|
}
|
|
25
23
|
when File
|
|
26
24
|
{
|
|
27
25
|
name: File.basename(file.path),
|
|
28
|
-
mimeType: mime_type_for(file.path),
|
|
29
26
|
buffer: Base64.strict_encode64(file.read),
|
|
30
27
|
}
|
|
31
28
|
else
|
|
@@ -33,10 +30,5 @@ module Playwright
|
|
|
33
30
|
end
|
|
34
31
|
end
|
|
35
32
|
end
|
|
36
|
-
|
|
37
|
-
private def mime_type_for(filepath)
|
|
38
|
-
mime_types = MIME::Types.type_for(filepath)
|
|
39
|
-
mime_types.first.to_s || 'application/octet-stream'
|
|
40
|
-
end
|
|
41
33
|
end
|
|
42
34
|
end
|
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
require_relative './javascript/expression'
|
|
2
|
-
require_relative './javascript/function'
|
|
3
2
|
require_relative './javascript/value_parser'
|
|
4
3
|
require_relative './javascript/value_serializer'
|
|
5
|
-
|
|
6
|
-
module Playwright
|
|
7
|
-
module JavaScript
|
|
8
|
-
# Detect if str is likely to be a function
|
|
9
|
-
module_function def function?(str)
|
|
10
|
-
['async', 'function'].any? { |key| str.strip.start_with?(key) } || str.include?('=>')
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
module Playwright
|
|
2
2
|
module JavaScript
|
|
3
3
|
class Expression
|
|
4
|
-
def initialize(expression)
|
|
4
|
+
def initialize(expression, arg)
|
|
5
5
|
@expression = expression
|
|
6
|
-
@serialized_arg = ValueSerializer.new(
|
|
6
|
+
@serialized_arg = ValueSerializer.new(arg).serialize
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def evaluate(channel)
|
|
10
10
|
value = channel.send_message_to_server(
|
|
11
11
|
'evaluateExpression',
|
|
12
12
|
expression: @expression,
|
|
13
|
-
isFunction: false,
|
|
14
13
|
arg: @serialized_arg,
|
|
15
14
|
)
|
|
16
15
|
ValueParser.new(value).parse
|
|
@@ -20,7 +19,6 @@ module Playwright
|
|
|
20
19
|
resp = channel.send_message_to_server(
|
|
21
20
|
'evaluateExpressionHandle',
|
|
22
21
|
expression: @expression,
|
|
23
|
-
isFunction: false,
|
|
24
22
|
arg: @serialized_arg,
|
|
25
23
|
)
|
|
26
24
|
::Playwright::ChannelOwner.from(resp)
|
|
@@ -31,7 +29,6 @@ module Playwright
|
|
|
31
29
|
'evalOnSelector',
|
|
32
30
|
selector: selector,
|
|
33
31
|
expression: @expression,
|
|
34
|
-
isFunction: false,
|
|
35
32
|
arg: @serialized_arg,
|
|
36
33
|
)
|
|
37
34
|
ValueParser.new(value).parse
|
|
@@ -42,7 +39,6 @@ module Playwright
|
|
|
42
39
|
'evalOnSelectorAll',
|
|
43
40
|
selector: selector,
|
|
44
41
|
expression: @expression,
|
|
45
|
-
isFunction: false,
|
|
46
42
|
arg: @serialized_arg,
|
|
47
43
|
)
|
|
48
44
|
ValueParser.new(value).parse
|
|
@@ -51,7 +47,6 @@ module Playwright
|
|
|
51
47
|
def wait_for_function(channel, polling:, timeout:)
|
|
52
48
|
params = {
|
|
53
49
|
expression: @expression,
|
|
54
|
-
isFunction: false,
|
|
55
50
|
arg: @serialized_arg,
|
|
56
51
|
polling: polling,
|
|
57
52
|
timeout: timeout,
|
|
@@ -31,7 +31,7 @@ module Playwright
|
|
|
31
31
|
def wrap
|
|
32
32
|
api_class = detect_class_for(@impl.class)
|
|
33
33
|
if api_class
|
|
34
|
-
api_class.new(@impl)
|
|
34
|
+
@impl._api ||= api_class.new(@impl)
|
|
35
35
|
else
|
|
36
36
|
raise NotImplementedError.new("Playwright::#{expected_class_name_for(@impl.class)} is not implemented")
|
|
37
37
|
end
|
|
@@ -101,10 +101,6 @@ module Playwright
|
|
|
101
101
|
@impl = impl
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
-
def ==(other)
|
|
105
|
-
@impl.to_s == other.instance_variable_get(:'@impl').to_s
|
|
106
|
-
end
|
|
107
|
-
|
|
108
104
|
# @param block [Proc]
|
|
109
105
|
private def wrap_block_call(block)
|
|
110
106
|
return nil unless block.is_a?(Proc)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Playwright
|
|
2
|
+
define_api_implementation :TracingImpl do
|
|
3
|
+
def initialize(channel, context)
|
|
4
|
+
@channel = channel
|
|
5
|
+
@context = context
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def start(name: nil, screenshots: nil, snapshots: nil)
|
|
9
|
+
params = {
|
|
10
|
+
name: name,
|
|
11
|
+
screenshots: screenshots,
|
|
12
|
+
snapshots: snapshots,
|
|
13
|
+
}.compact
|
|
14
|
+
@channel.send_message_to_server('tracingStart', params)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Stop tracing.
|
|
18
|
+
def stop
|
|
19
|
+
@channel.send_message_to_server('tracingStop')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def export(path)
|
|
23
|
+
resp = @channel.send_message_to_server('tracingExport')
|
|
24
|
+
artifact = ChannelOwners::Artifact.from(resp)
|
|
25
|
+
# if self._context._browser:
|
|
26
|
+
# artifact._is_remote = self._context._browser._is_remote
|
|
27
|
+
artifact.save_as(path)
|
|
28
|
+
artifact.delete
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/playwright/version.rb
CHANGED
|
@@ -2,13 +2,13 @@ module Playwright
|
|
|
2
2
|
# The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is used by
|
|
3
3
|
# assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or
|
|
4
4
|
# [switches](https://en.wikipedia.org/wiki/Switch_access).
|
|
5
|
-
#
|
|
5
|
+
#
|
|
6
6
|
# Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might
|
|
7
7
|
# have wildly different output.
|
|
8
|
-
#
|
|
8
|
+
#
|
|
9
9
|
# Rendering engines of Chromium, Firefox and WebKit have a concept of "accessibility tree", which is then translated into
|
|
10
10
|
# different platform-specific APIs. Accessibility namespace gives access to this Accessibility Tree.
|
|
11
|
-
#
|
|
11
|
+
#
|
|
12
12
|
# Most of the accessibility tree gets filtered out when converting from internal browser AX Tree to Platform-specific
|
|
13
13
|
# AX-Tree or by assistive technologies themselves. By default, Playwright tries to approximate this filtering, exposing
|
|
14
14
|
# only the "interesting" nodes of the tree.
|
|
@@ -16,100 +16,19 @@ module Playwright
|
|
|
16
16
|
|
|
17
17
|
# Captures the current state of the accessibility tree. The returned object represents the root accessible node of the
|
|
18
18
|
# page.
|
|
19
|
-
#
|
|
19
|
+
#
|
|
20
20
|
# > NOTE: The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers.
|
|
21
21
|
# Playwright will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`.
|
|
22
|
-
#
|
|
22
|
+
#
|
|
23
23
|
# An example of dumping the entire accessibility tree:
|
|
24
|
-
#
|
|
25
24
|
#
|
|
26
|
-
# ```js
|
|
27
|
-
# const snapshot = await page.accessibility.snapshot();
|
|
28
|
-
# console.log(snapshot);
|
|
29
|
-
# ```
|
|
30
|
-
#
|
|
31
|
-
# ```java
|
|
32
|
-
# String snapshot = page.accessibility().snapshot();
|
|
33
|
-
# System.out.println(snapshot);
|
|
34
|
-
# ```
|
|
35
|
-
#
|
|
36
|
-
# ```python async
|
|
37
|
-
# snapshot = await page.accessibility.snapshot()
|
|
38
|
-
# print(snapshot)
|
|
39
|
-
# ```
|
|
40
|
-
#
|
|
41
25
|
# ```python sync
|
|
42
26
|
# snapshot = page.accessibility.snapshot()
|
|
43
27
|
# print(snapshot)
|
|
44
28
|
# ```
|
|
45
|
-
#
|
|
46
|
-
# ```csharp
|
|
47
|
-
# var accessibilitySnapshot = await Page.Accessibility.SnapshotAsync();
|
|
48
|
-
# Console.WriteLine(accessibilitySnapshot);
|
|
49
|
-
# ```
|
|
50
|
-
#
|
|
29
|
+
#
|
|
51
30
|
# An example of logging the focused node's name:
|
|
52
|
-
#
|
|
53
31
|
#
|
|
54
|
-
# ```js
|
|
55
|
-
# const snapshot = await page.accessibility.snapshot();
|
|
56
|
-
# const node = findFocusedNode(snapshot);
|
|
57
|
-
# console.log(node && node.name);
|
|
58
|
-
#
|
|
59
|
-
# function findFocusedNode(node) {
|
|
60
|
-
# if (node.focused)
|
|
61
|
-
# return node;
|
|
62
|
-
# for (const child of node.children || []) {
|
|
63
|
-
# const foundNode = findFocusedNode(child);
|
|
64
|
-
# return foundNode;
|
|
65
|
-
# }
|
|
66
|
-
# return null;
|
|
67
|
-
# }
|
|
68
|
-
# ```
|
|
69
|
-
#
|
|
70
|
-
# ```csharp
|
|
71
|
-
# Func<AccessibilitySnapshotResult, AccessibilitySnapshotResult> findFocusedNode = root =>
|
|
72
|
-
# {
|
|
73
|
-
# var nodes = new Stack<AccessibilitySnapshotResult>(new[] { root });
|
|
74
|
-
# while (nodes.Count > 0)
|
|
75
|
-
# {
|
|
76
|
-
# var node = nodes.Pop();
|
|
77
|
-
# if (node.Focused) return node;
|
|
78
|
-
# foreach (var innerNode in node.Children)
|
|
79
|
-
# {
|
|
80
|
-
# nodes.Push(innerNode);
|
|
81
|
-
# }
|
|
82
|
-
# }
|
|
83
|
-
#
|
|
84
|
-
# return null;
|
|
85
|
-
# };
|
|
86
|
-
#
|
|
87
|
-
# var accessibilitySnapshot = await Page.Accessibility.SnapshotAsync();
|
|
88
|
-
# var focusedNode = findFocusedNode(accessibilitySnapshot);
|
|
89
|
-
# if(focusedNode != null)
|
|
90
|
-
# Console.WriteLine(focusedNode.Name);
|
|
91
|
-
# ```
|
|
92
|
-
#
|
|
93
|
-
# ```java
|
|
94
|
-
# // FIXME
|
|
95
|
-
# String snapshot = page.accessibility().snapshot();
|
|
96
|
-
# ```
|
|
97
|
-
#
|
|
98
|
-
# ```python async
|
|
99
|
-
# def find_focused_node(node):
|
|
100
|
-
# if (node.get("focused"))
|
|
101
|
-
# return node
|
|
102
|
-
# for child in (node.get("children") or []):
|
|
103
|
-
# found_node = find_focused_node(child)
|
|
104
|
-
# return found_node
|
|
105
|
-
# return None
|
|
106
|
-
#
|
|
107
|
-
# snapshot = await page.accessibility.snapshot()
|
|
108
|
-
# node = find_focused_node(snapshot)
|
|
109
|
-
# if node:
|
|
110
|
-
# print(node["name"])
|
|
111
|
-
# ```
|
|
112
|
-
#
|
|
113
32
|
# ```python sync
|
|
114
33
|
# def find_focused_node(node):
|
|
115
34
|
# if (node.get("focused"))
|
|
@@ -118,7 +37,7 @@ module Playwright
|
|
|
118
37
|
# found_node = find_focused_node(child)
|
|
119
38
|
# return found_node
|
|
120
39
|
# return None
|
|
121
|
-
#
|
|
40
|
+
#
|
|
122
41
|
# snapshot = page.accessibility.snapshot()
|
|
123
42
|
# node = find_focused_node(snapshot)
|
|
124
43
|
# if node:
|