playwright-ruby-client 0.0.8 → 1.58.1.alpha1
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/AGENTS.md +4 -0
- data/CLAUDE/api_generation.md +28 -0
- data/CLAUDE/ci_expectations.md +23 -0
- data/CLAUDE/gem_release_flow.md +39 -0
- data/CLAUDE/past_upgrade_pr_patterns.md +42 -0
- data/CLAUDE/playwright_upgrade_workflow.md +35 -0
- data/CLAUDE/rspec_debugging.md +30 -0
- data/CLAUDE/unimplemented_examples.md +18 -0
- data/CLAUDE.md +32 -0
- data/CONTRIBUTING.md +5 -0
- data/README.md +60 -16
- data/documentation/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/api_request.md +7 -0
- data/documentation/docs/api/api_request_context.md +298 -0
- data/documentation/docs/api/api_response.md +114 -0
- data/documentation/docs/api/browser.md +237 -0
- data/documentation/docs/api/browser_context.md +503 -0
- data/documentation/docs/api/browser_type.md +184 -0
- data/documentation/docs/api/cdp_session.md +44 -0
- data/documentation/docs/api/clock.md +154 -0
- data/documentation/docs/api/console_message.md +85 -0
- data/documentation/docs/api/dialog.md +84 -0
- data/documentation/docs/api/download.md +111 -0
- data/documentation/docs/api/element_handle.md +694 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +42 -0
- data/documentation/docs/api/experimental/android_device.md +109 -0
- data/documentation/docs/api/experimental/android_input.md +43 -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 +53 -0
- data/documentation/docs/api/frame.md +1218 -0
- data/documentation/docs/api/frame_locator.md +348 -0
- data/documentation/docs/api/js_handle.md +121 -0
- data/documentation/docs/api/keyboard.md +170 -0
- data/documentation/docs/api/locator.md +1495 -0
- data/documentation/docs/api/locator_assertions.md +827 -0
- data/documentation/docs/api/mouse.md +86 -0
- data/documentation/docs/api/page.md +1946 -0
- data/documentation/docs/api/page_assertions.md +65 -0
- data/documentation/docs/api/playwright.md +66 -0
- data/documentation/docs/api/request.md +255 -0
- data/documentation/docs/api/response.md +176 -0
- data/documentation/docs/api/route.md +205 -0
- data/documentation/docs/api/selectors.md +63 -0
- data/documentation/docs/api/touchscreen.md +22 -0
- data/documentation/docs/api/tracing.md +129 -0
- data/documentation/docs/api/web_socket.md +51 -0
- data/documentation/docs/api/worker.md +83 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +161 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +55 -0
- data/documentation/docs/article/guides/inspector.md +31 -0
- data/documentation/docs/article/guides/launch_browser.md +121 -0
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +112 -0
- data/documentation/docs/article/guides/rails_integration.md +278 -0
- data/documentation/docs/article/guides/rails_integration_with_null_driver.md +145 -0
- data/documentation/docs/article/guides/recording_video.md +79 -0
- data/documentation/docs/article/guides/rspec_integration.md +59 -0
- data/documentation/docs/article/guides/semi_automation.md +71 -0
- data/documentation/docs/article/guides/use_storage_state.md +78 -0
- data/documentation/docs/include/api_coverage.md +671 -0
- data/documentation/docusaurus.config.js +114 -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 +49 -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/playwright-ruby-client.png +0 -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 +9005 -0
- data/lib/playwright/{input_types/android_input.rb → android_input_impl.rb} +5 -1
- data/lib/playwright/api_implementation.rb +18 -0
- data/lib/playwright/api_response_impl.rb +77 -0
- data/lib/playwright/channel.rb +62 -1
- data/lib/playwright/channel_owner.rb +70 -7
- data/lib/playwright/channel_owners/android.rb +16 -3
- data/lib/playwright/channel_owners/android_device.rb +22 -66
- data/lib/playwright/channel_owners/api_request_context.rb +247 -0
- data/lib/playwright/channel_owners/artifact.rb +40 -0
- data/lib/playwright/channel_owners/binding_call.rb +70 -0
- data/lib/playwright/channel_owners/browser.rb +114 -22
- data/lib/playwright/channel_owners/browser_context.rb +589 -15
- data/lib/playwright/channel_owners/browser_type.rb +90 -1
- data/lib/playwright/channel_owners/cdp_session.rb +19 -0
- data/lib/playwright/channel_owners/dialog.rb +32 -0
- data/lib/playwright/channel_owners/element_handle.rb +107 -43
- data/lib/playwright/channel_owners/fetch_request.rb +8 -0
- data/lib/playwright/channel_owners/frame.rb +334 -104
- data/lib/playwright/channel_owners/js_handle.rb +9 -13
- data/lib/playwright/channel_owners/local_utils.rb +82 -0
- data/lib/playwright/channel_owners/page.rb +778 -95
- data/lib/playwright/channel_owners/playwright.rb +25 -30
- data/lib/playwright/channel_owners/request.rb +120 -18
- data/lib/playwright/channel_owners/response.rb +113 -0
- data/lib/playwright/channel_owners/route.rb +181 -0
- data/lib/playwright/channel_owners/stream.rb +30 -0
- data/lib/playwright/channel_owners/tracing.rb +117 -0
- data/lib/playwright/channel_owners/web_socket.rb +96 -0
- data/lib/playwright/channel_owners/worker.rb +46 -0
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/clock_impl.rb +67 -0
- data/lib/playwright/connection.rb +111 -63
- data/lib/playwright/console_message_impl.rb +29 -0
- data/lib/playwright/download_impl.rb +32 -0
- data/lib/playwright/errors.rb +42 -5
- data/lib/playwright/event_emitter.rb +17 -3
- data/lib/playwright/event_emitter_proxy.rb +49 -0
- data/lib/playwright/events.rb +10 -5
- data/lib/playwright/file_chooser_impl.rb +24 -0
- data/lib/playwright/frame_locator_impl.rb +66 -0
- data/lib/playwright/har_router.rb +89 -0
- data/lib/playwright/http_headers.rb +14 -0
- data/lib/playwright/input_files.rb +102 -15
- data/lib/playwright/javascript/expression.rb +7 -11
- data/lib/playwright/javascript/regex.rb +23 -0
- data/lib/playwright/javascript/source_url.rb +16 -0
- data/lib/playwright/javascript/value_parser.rb +108 -19
- data/lib/playwright/javascript/value_serializer.rb +47 -8
- data/lib/playwright/javascript/visitor_info.rb +26 -0
- data/lib/playwright/javascript.rb +2 -10
- data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +6 -2
- data/lib/playwright/locator_assertions_impl.rb +571 -0
- data/lib/playwright/locator_impl.rb +544 -0
- data/lib/playwright/locator_utils.rb +136 -0
- data/lib/playwright/mouse_impl.rb +57 -0
- data/lib/playwright/page_assertions_impl.rb +154 -0
- data/lib/playwright/playwright_api.rb +102 -30
- data/lib/playwright/raw_headers.rb +61 -0
- data/lib/playwright/route_handler.rb +78 -0
- data/lib/playwright/select_option_values.rb +34 -13
- data/lib/playwright/selectors_impl.rb +45 -0
- data/lib/playwright/test.rb +102 -0
- data/lib/playwright/timeout_settings.rb +9 -4
- data/lib/playwright/touchscreen_impl.rb +14 -0
- data/lib/playwright/transport.rb +61 -10
- data/lib/playwright/url_matcher.rb +24 -2
- data/lib/playwright/utils.rb +48 -13
- data/lib/playwright/version.rb +2 -1
- data/lib/playwright/video.rb +54 -0
- data/lib/playwright/waiter.rb +166 -0
- data/lib/playwright/web_socket_client.rb +167 -0
- data/lib/playwright/web_socket_transport.rb +116 -0
- data/lib/playwright.rb +188 -11
- data/lib/playwright_api/android.rb +46 -11
- data/lib/playwright_api/android_device.rb +182 -31
- data/lib/playwright_api/android_input.rb +22 -13
- data/lib/playwright_api/android_socket.rb +18 -0
- data/lib/playwright_api/android_web_view.rb +24 -0
- data/lib/playwright_api/api_request.rb +26 -0
- data/lib/playwright_api/api_request_context.rb +311 -0
- data/lib/playwright_api/api_response.rb +92 -0
- data/lib/playwright_api/browser.rb +116 -103
- data/lib/playwright_api/browser_context.rb +290 -389
- data/lib/playwright_api/browser_type.rb +96 -118
- data/lib/playwright_api/cdp_session.rb +36 -39
- data/lib/playwright_api/clock.rb +121 -0
- data/lib/playwright_api/console_message.rb +35 -19
- data/lib/playwright_api/dialog.rb +53 -50
- data/lib/playwright_api/download.rb +49 -43
- data/lib/playwright_api/element_handle.rb +354 -402
- data/lib/playwright_api/file_chooser.rb +15 -18
- data/lib/playwright_api/frame.rb +703 -603
- data/lib/playwright_api/frame_locator.rb +285 -0
- data/lib/playwright_api/js_handle.rb +50 -76
- data/lib/playwright_api/keyboard.rb +67 -146
- data/lib/playwright_api/locator.rb +1304 -0
- data/lib/playwright_api/locator_assertions.rb +704 -0
- data/lib/playwright_api/mouse.rb +23 -29
- data/lib/playwright_api/page.rb +1196 -1176
- data/lib/playwright_api/page_assertions.rb +60 -0
- data/lib/playwright_api/playwright.rb +54 -122
- data/lib/playwright_api/request.rb +112 -74
- data/lib/playwright_api/response.rb +92 -20
- data/lib/playwright_api/route.rb +152 -62
- data/lib/playwright_api/selectors.rb +47 -61
- data/lib/playwright_api/touchscreen.rb +8 -2
- data/lib/playwright_api/tracing.rb +128 -0
- data/lib/playwright_api/web_socket.rb +43 -5
- data/lib/playwright_api/worker.rb +74 -34
- data/playwright.gemspec +14 -9
- data/sig/playwright.rbs +658 -0
- metadata +216 -50
- data/docs/api_coverage.md +0 -354
- data/lib/playwright/channel_owners/chromium_browser.rb +0 -8
- data/lib/playwright/channel_owners/chromium_browser_context.rb +0 -8
- data/lib/playwright/channel_owners/console_message.rb +0 -21
- data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
- data/lib/playwright/channel_owners/selectors.rb +0 -4
- data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
- data/lib/playwright/input_type.rb +0 -19
- data/lib/playwright/input_types/mouse.rb +0 -4
- data/lib/playwright/input_types/touchscreen.rb +0 -4
- data/lib/playwright/javascript/function.rb +0 -67
- data/lib/playwright/wait_helper.rb +0 -73
- data/lib/playwright_api/accessibility.rb +0 -93
- data/lib/playwright_api/binding_call.rb +0 -23
- data/lib/playwright_api/chromium_browser_context.rb +0 -57
- data/lib/playwright_api/video.rb +0 -24
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
module Playwright
|
|
2
2
|
define_channel_owner :BrowserType do
|
|
3
|
+
include Utils::PrepareBrowserContextOptions
|
|
4
|
+
|
|
5
|
+
private def after_initialize
|
|
6
|
+
@timeout_settings = TimeoutSettings.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
private def update_playwright(playwright)
|
|
10
|
+
@playwright = playwright
|
|
11
|
+
end
|
|
12
|
+
|
|
3
13
|
def name
|
|
4
14
|
@initializer['name']
|
|
5
15
|
end
|
|
@@ -9,8 +19,65 @@ module Playwright
|
|
|
9
19
|
end
|
|
10
20
|
|
|
11
21
|
def launch(options, &block)
|
|
12
|
-
|
|
22
|
+
params = options.dup
|
|
23
|
+
params[:timeout] ||= @timeout_settings.launch_timeout
|
|
24
|
+
resp = @channel.send_message_to_server('launch', params.compact)
|
|
13
25
|
browser = ChannelOwners::Browser.from(resp)
|
|
26
|
+
browser.send(:connect_to_browser_type, self, params[:tracesDir])
|
|
27
|
+
return browser unless block
|
|
28
|
+
|
|
29
|
+
begin
|
|
30
|
+
block.call(browser)
|
|
31
|
+
ensure
|
|
32
|
+
browser.close
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def launch_persistent_context(userDataDir, **options, &block)
|
|
37
|
+
params = options.dup
|
|
38
|
+
prepare_browser_context_options(params)
|
|
39
|
+
params['userDataDir'] = userDataDir
|
|
40
|
+
params[:timeout] ||= @timeout_settings.launch_timeout
|
|
41
|
+
|
|
42
|
+
result = @channel.send_message_to_server_result('launchPersistentContext', params.compact)
|
|
43
|
+
browser = ChannelOwners::Browser.from(result['browser'])
|
|
44
|
+
browser.send(:connect_to_browser_type, self, params[:tracesDir])
|
|
45
|
+
context = ChannelOwners::BrowserContext.from(result['context'])
|
|
46
|
+
context.send(:initialize_har_from_options,
|
|
47
|
+
record_har_content: params[:record_har_content],
|
|
48
|
+
record_har_mode: params[:record_har_mode],
|
|
49
|
+
record_har_omit_content: params[:record_har_omit_content],
|
|
50
|
+
record_har_path: params[:record_har_path],
|
|
51
|
+
record_har_url_filter: params[:record_har_url_filter],
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
return context unless block
|
|
55
|
+
|
|
56
|
+
begin
|
|
57
|
+
block.call(context)
|
|
58
|
+
ensure
|
|
59
|
+
context.close
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def connect_over_cdp(endpointURL, headers: nil, isLocal: nil, slowMo: nil, timeout: nil, &block)
|
|
64
|
+
raise 'Connecting over CDP is only supported in Chromium.' unless name == 'chromium'
|
|
65
|
+
|
|
66
|
+
params = {
|
|
67
|
+
endpointURL: endpointURL,
|
|
68
|
+
headers: headers,
|
|
69
|
+
isLocal: isLocal,
|
|
70
|
+
slowMo: slowMo,
|
|
71
|
+
timeout: @timeout_settings.timeout(timeout),
|
|
72
|
+
}.compact
|
|
73
|
+
|
|
74
|
+
if headers
|
|
75
|
+
params[:headers] = HttpHeaders.new(headers).as_serialized
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
result = @channel.send_message_to_server_result('connectOverCDP', params)
|
|
79
|
+
browser = ChannelOwners::Browser.from(result['browser'])
|
|
80
|
+
browser.send(:connect_to_browser_type, self, nil)
|
|
14
81
|
|
|
15
82
|
if block
|
|
16
83
|
begin
|
|
@@ -22,5 +89,27 @@ module Playwright
|
|
|
22
89
|
browser
|
|
23
90
|
end
|
|
24
91
|
end
|
|
92
|
+
|
|
93
|
+
private def did_create_context(context, context_options = {}, browser_options = {})
|
|
94
|
+
context.send(:update_options, context_options: context_options, browser_options: browser_options)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
private def update_with_playwright_selectors_options(options)
|
|
98
|
+
selectors = @playwright&.selectors
|
|
99
|
+
if selectors
|
|
100
|
+
selectors.send(:update_with_selector_options, options)
|
|
101
|
+
else
|
|
102
|
+
options
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
private def playwright_selectors_browser_contexts
|
|
107
|
+
selectors = @playwright&.selectors
|
|
108
|
+
if selectors
|
|
109
|
+
selectors.send(:contexts_for_selectors)
|
|
110
|
+
else
|
|
111
|
+
[]
|
|
112
|
+
end
|
|
113
|
+
end
|
|
25
114
|
end
|
|
26
115
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Playwright
|
|
2
|
+
define_channel_owner :CDPSession do
|
|
3
|
+
private def after_initialize
|
|
4
|
+
@channel.on('event', method(:on_event))
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
private def on_event(params)
|
|
8
|
+
emit(params['method'], params['params'])
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def send_message(method, params: {})
|
|
12
|
+
@channel.send_message_to_server('send', method: method, params: params)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def detach
|
|
16
|
+
@channel.send_message_to_server('detach')
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Playwright
|
|
2
|
+
define_channel_owner :Dialog do
|
|
3
|
+
def page
|
|
4
|
+
@page ||= ChannelOwners::Page.from_nullable(@initializer['page'])
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def type
|
|
8
|
+
@initializer['type']
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def message
|
|
12
|
+
@initializer['message']
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def default_value
|
|
16
|
+
@initializer['defaultValue']
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def accept(promptText: nil)
|
|
20
|
+
accept_async(promptText: promptText).value!
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def accept_async(promptText: nil)
|
|
24
|
+
params = { promptText: promptText }.compact
|
|
25
|
+
@channel.async_send_message_to_server('accept', params)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def dismiss
|
|
29
|
+
@channel.async_send_message_to_server('dismiss')
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -3,6 +3,11 @@ require_relative './js_handle'
|
|
|
3
3
|
module Playwright
|
|
4
4
|
module ChannelOwners
|
|
5
5
|
class ElementHandle < JSHandle
|
|
6
|
+
private def _timeout(timeout)
|
|
7
|
+
# @parent is Frame
|
|
8
|
+
@parent.send(:_timeout, timeout)
|
|
9
|
+
end
|
|
10
|
+
|
|
6
11
|
def as_element
|
|
7
12
|
self
|
|
8
13
|
end
|
|
@@ -69,20 +74,28 @@ module Playwright
|
|
|
69
74
|
|
|
70
75
|
def scroll_into_view_if_needed(timeout: nil)
|
|
71
76
|
params = {
|
|
72
|
-
timeout: timeout,
|
|
77
|
+
timeout: _timeout(timeout),
|
|
73
78
|
}.compact
|
|
74
79
|
@channel.send_message_to_server('scrollIntoViewIfNeeded', params)
|
|
75
80
|
|
|
76
81
|
nil
|
|
77
82
|
end
|
|
78
83
|
|
|
79
|
-
def hover(
|
|
84
|
+
def hover(
|
|
85
|
+
force: nil,
|
|
86
|
+
modifiers: nil,
|
|
87
|
+
noWaitAfter: nil,
|
|
88
|
+
position: nil,
|
|
89
|
+
timeout: nil,
|
|
90
|
+
trial: nil)
|
|
80
91
|
params = {
|
|
81
92
|
force: force,
|
|
82
93
|
modifiers: modifiers,
|
|
94
|
+
noWaitAfter: noWaitAfter,
|
|
83
95
|
position: position,
|
|
84
|
-
timeout: timeout,
|
|
85
|
-
|
|
96
|
+
timeout: _timeout(timeout),
|
|
97
|
+
trial: trial,
|
|
98
|
+
}.compact
|
|
86
99
|
@channel.send_message_to_server('hover', params)
|
|
87
100
|
|
|
88
101
|
nil
|
|
@@ -96,7 +109,9 @@ module Playwright
|
|
|
96
109
|
modifiers: nil,
|
|
97
110
|
noWaitAfter: nil,
|
|
98
111
|
position: nil,
|
|
99
|
-
timeout: nil
|
|
112
|
+
timeout: nil,
|
|
113
|
+
trial: nil,
|
|
114
|
+
steps: nil)
|
|
100
115
|
|
|
101
116
|
params = {
|
|
102
117
|
button: button,
|
|
@@ -106,7 +121,9 @@ module Playwright
|
|
|
106
121
|
modifiers: modifiers,
|
|
107
122
|
noWaitAfter: noWaitAfter,
|
|
108
123
|
position: position,
|
|
109
|
-
timeout: timeout,
|
|
124
|
+
timeout: _timeout(timeout),
|
|
125
|
+
trial: trial,
|
|
126
|
+
steps: steps,
|
|
110
127
|
}.compact
|
|
111
128
|
@channel.send_message_to_server('click', params)
|
|
112
129
|
|
|
@@ -120,7 +137,9 @@ module Playwright
|
|
|
120
137
|
modifiers: nil,
|
|
121
138
|
noWaitAfter: nil,
|
|
122
139
|
position: nil,
|
|
123
|
-
timeout: nil
|
|
140
|
+
timeout: nil,
|
|
141
|
+
trial: nil,
|
|
142
|
+
steps: nil)
|
|
124
143
|
|
|
125
144
|
params = {
|
|
126
145
|
button: button,
|
|
@@ -129,19 +148,31 @@ module Playwright
|
|
|
129
148
|
modifiers: modifiers,
|
|
130
149
|
noWaitAfter: noWaitAfter,
|
|
131
150
|
position: position,
|
|
132
|
-
timeout: timeout,
|
|
151
|
+
timeout: _timeout(timeout),
|
|
152
|
+
trial: trial,
|
|
153
|
+
steps: steps,
|
|
133
154
|
}.compact
|
|
134
155
|
@channel.send_message_to_server('dblclick', params)
|
|
135
156
|
|
|
136
157
|
nil
|
|
137
158
|
end
|
|
138
159
|
|
|
139
|
-
def select_option(
|
|
140
|
-
|
|
141
|
-
|
|
160
|
+
def select_option(
|
|
161
|
+
element: nil,
|
|
162
|
+
index: nil,
|
|
163
|
+
value: nil,
|
|
164
|
+
label: nil,
|
|
165
|
+
force: nil,
|
|
166
|
+
noWaitAfter: nil,
|
|
167
|
+
timeout: nil)
|
|
168
|
+
base_params = SelectOptionValues.new(
|
|
169
|
+
element: element,
|
|
170
|
+
index: index,
|
|
171
|
+
value: value,
|
|
172
|
+
label: label,
|
|
173
|
+
).as_params
|
|
174
|
+
params = base_params.merge({ force: force, noWaitAfter: noWaitAfter, timeout: _timeout(timeout) }.compact)
|
|
142
175
|
@channel.send_message_to_server('selectOption', params)
|
|
143
|
-
|
|
144
|
-
nil
|
|
145
176
|
end
|
|
146
177
|
|
|
147
178
|
def tap_point(
|
|
@@ -149,42 +180,55 @@ module Playwright
|
|
|
149
180
|
modifiers: nil,
|
|
150
181
|
noWaitAfter: nil,
|
|
151
182
|
position: nil,
|
|
152
|
-
timeout: nil
|
|
183
|
+
timeout: nil,
|
|
184
|
+
trial: nil)
|
|
153
185
|
|
|
154
186
|
params = {
|
|
155
187
|
force: force,
|
|
156
188
|
modifiers: modifiers,
|
|
157
189
|
noWaitAfter: noWaitAfter,
|
|
158
190
|
position: position,
|
|
159
|
-
timeout: timeout,
|
|
191
|
+
timeout: _timeout(timeout),
|
|
192
|
+
trial: trial,
|
|
160
193
|
}.compact
|
|
161
194
|
@channel.send_message_to_server('tap', params)
|
|
162
195
|
|
|
163
196
|
nil
|
|
164
197
|
end
|
|
165
198
|
|
|
166
|
-
def fill(value, noWaitAfter: nil, timeout: nil)
|
|
199
|
+
def fill(value, force: nil, noWaitAfter: nil, timeout: nil)
|
|
167
200
|
params = {
|
|
168
201
|
value: value,
|
|
202
|
+
force: force,
|
|
169
203
|
noWaitAfter: noWaitAfter,
|
|
170
|
-
timeout: timeout,
|
|
171
|
-
}
|
|
204
|
+
timeout: _timeout(timeout),
|
|
205
|
+
}.compact
|
|
172
206
|
@channel.send_message_to_server('fill', params)
|
|
173
207
|
|
|
174
208
|
nil
|
|
175
209
|
end
|
|
176
210
|
|
|
177
|
-
def select_text(timeout: nil)
|
|
178
|
-
params = { timeout: timeout }.compact
|
|
211
|
+
def select_text(force: nil, timeout: nil)
|
|
212
|
+
params = { force: force, timeout: _timeout(timeout) }.compact
|
|
179
213
|
@channel.send_message_to_server('selectText', params)
|
|
180
214
|
|
|
181
215
|
nil
|
|
182
216
|
end
|
|
183
217
|
|
|
218
|
+
def input_value(timeout: nil)
|
|
219
|
+
params = { timeout: _timeout(timeout) }.compact
|
|
220
|
+
@channel.send_message_to_server('inputValue', params)
|
|
221
|
+
end
|
|
222
|
+
|
|
184
223
|
def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
224
|
+
frame = owner_frame
|
|
225
|
+
unless frame
|
|
226
|
+
raise 'Cannot set input files to detached element'
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
method_name, params = InputFiles.new(frame.page.context, files).as_method_and_params
|
|
230
|
+
params.merge!({ noWaitAfter: noWaitAfter, timeout: _timeout(timeout) }.compact)
|
|
231
|
+
@channel.send_message_to_server(method_name, params)
|
|
188
232
|
|
|
189
233
|
nil
|
|
190
234
|
end
|
|
@@ -200,7 +244,7 @@ module Playwright
|
|
|
200
244
|
text: text,
|
|
201
245
|
delay: delay,
|
|
202
246
|
noWaitAfter: noWaitAfter,
|
|
203
|
-
timeout: timeout,
|
|
247
|
+
timeout: _timeout(timeout),
|
|
204
248
|
}.compact
|
|
205
249
|
@channel.send_message_to_server('type', params)
|
|
206
250
|
|
|
@@ -212,53 +256,81 @@ module Playwright
|
|
|
212
256
|
key: key,
|
|
213
257
|
delay: delay,
|
|
214
258
|
noWaitAfter: noWaitAfter,
|
|
215
|
-
timeout: timeout,
|
|
259
|
+
timeout: _timeout(timeout),
|
|
216
260
|
}.compact
|
|
217
261
|
@channel.send_message_to_server('press', params)
|
|
218
262
|
|
|
219
263
|
nil
|
|
220
264
|
end
|
|
221
265
|
|
|
222
|
-
def check(force: nil, noWaitAfter: nil, timeout: nil)
|
|
266
|
+
def check(force: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil)
|
|
223
267
|
params = {
|
|
224
268
|
force: force,
|
|
225
269
|
noWaitAfter: noWaitAfter,
|
|
226
|
-
|
|
270
|
+
position: position,
|
|
271
|
+
timeout: _timeout(timeout),
|
|
272
|
+
trial: trial,
|
|
227
273
|
}.compact
|
|
228
274
|
@channel.send_message_to_server('check', params)
|
|
229
275
|
|
|
230
276
|
nil
|
|
231
277
|
end
|
|
232
278
|
|
|
233
|
-
def uncheck(force: nil, noWaitAfter: nil, timeout: nil)
|
|
279
|
+
def uncheck(force: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil)
|
|
234
280
|
params = {
|
|
235
281
|
force: force,
|
|
236
282
|
noWaitAfter: noWaitAfter,
|
|
237
|
-
|
|
283
|
+
position: position,
|
|
284
|
+
timeout: _timeout(timeout),
|
|
285
|
+
trial: trial,
|
|
238
286
|
}.compact
|
|
239
287
|
@channel.send_message_to_server('uncheck', params)
|
|
240
288
|
|
|
241
289
|
nil
|
|
242
290
|
end
|
|
243
291
|
|
|
292
|
+
def set_checked(checked, **options)
|
|
293
|
+
if checked
|
|
294
|
+
check(**options)
|
|
295
|
+
else
|
|
296
|
+
uncheck(**options)
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
244
300
|
def bounding_box
|
|
245
301
|
@channel.send_message_to_server('boundingBox')
|
|
246
302
|
end
|
|
247
303
|
|
|
248
304
|
def screenshot(
|
|
305
|
+
animations: nil,
|
|
306
|
+
caret: nil,
|
|
307
|
+
mask: nil,
|
|
308
|
+
maskColor: nil,
|
|
249
309
|
omitBackground: nil,
|
|
250
310
|
path: nil,
|
|
251
311
|
quality: nil,
|
|
312
|
+
scale: nil,
|
|
313
|
+
style: nil,
|
|
252
314
|
timeout: nil,
|
|
253
315
|
type: nil)
|
|
254
316
|
|
|
255
317
|
params = {
|
|
318
|
+
animations: animations,
|
|
319
|
+
caret: caret,
|
|
320
|
+
maskColor: maskColor,
|
|
256
321
|
omitBackground: omitBackground,
|
|
257
322
|
path: path,
|
|
258
323
|
quality: quality,
|
|
259
|
-
|
|
324
|
+
scale: scale,
|
|
325
|
+
style: style,
|
|
326
|
+
timeout: _timeout(timeout),
|
|
260
327
|
type: type,
|
|
261
328
|
}.compact
|
|
329
|
+
if mask.is_a?(Enumerable)
|
|
330
|
+
params[:mask] = mask.map do |locator|
|
|
331
|
+
locator.send(:to_protocol)
|
|
332
|
+
end
|
|
333
|
+
end
|
|
262
334
|
encoded_binary = @channel.send_message_to_server('screenshot', params)
|
|
263
335
|
decoded_binary = Base64.strict_decode64(encoded_binary)
|
|
264
336
|
if path
|
|
@@ -281,30 +353,22 @@ module Playwright
|
|
|
281
353
|
end
|
|
282
354
|
|
|
283
355
|
def eval_on_selector(selector, pageFunction, arg: nil)
|
|
284
|
-
|
|
285
|
-
JavaScript::Function.new(pageFunction, arg).eval_on_selector(@channel, selector)
|
|
286
|
-
else
|
|
287
|
-
JavaScript::Expression.new(pageFunction).eval_on_selector(@channel, selector)
|
|
288
|
-
end
|
|
356
|
+
JavaScript::Expression.new(pageFunction, arg).eval_on_selector(@channel, selector)
|
|
289
357
|
end
|
|
290
358
|
|
|
291
359
|
def eval_on_selector_all(selector, pageFunction, arg: nil)
|
|
292
|
-
|
|
293
|
-
JavaScript::Function.new(pageFunction, arg).eval_on_selector_all(@channel, selector)
|
|
294
|
-
else
|
|
295
|
-
JavaScript::Expression.new(pageFunction).eval_on_selector_all(@channel, selector)
|
|
296
|
-
end
|
|
360
|
+
JavaScript::Expression.new(pageFunction, arg).eval_on_selector_all(@channel, selector)
|
|
297
361
|
end
|
|
298
362
|
|
|
299
363
|
def wait_for_element_state(state, timeout: nil)
|
|
300
|
-
params = { state: state, timeout: timeout }.compact
|
|
364
|
+
params = { state: state, timeout: _timeout(timeout) }.compact
|
|
301
365
|
@channel.send_message_to_server('waitForElementState', params)
|
|
302
366
|
|
|
303
367
|
nil
|
|
304
368
|
end
|
|
305
369
|
|
|
306
|
-
def wait_for_selector(selector, state: nil, timeout: nil)
|
|
307
|
-
params = { selector: selector, state: state, timeout: timeout }.compact
|
|
370
|
+
def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
|
|
371
|
+
params = { selector: selector, state: state, strict: strict, timeout: _timeout(timeout) }.compact
|
|
308
372
|
resp = @channel.send_message_to_server('waitForSelector', params)
|
|
309
373
|
|
|
310
374
|
ChannelOwners::ElementHandle.from_nullable(resp)
|