playwright-ruby-client 0.5.10 → 0.6.4
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 +188 -0
- data/documentation/docs/api/browser_context.md +397 -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 +71 -0
- data/documentation/docs/api/element_handle.md +618 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +26 -0
- data/documentation/docs/api/experimental/android_device.md +92 -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 +50 -0
- data/documentation/docs/api/frame.md +866 -0
- data/documentation/docs/api/js_handle.md +113 -0
- data/documentation/docs/api/keyboard.md +157 -0
- data/documentation/docs/api/mouse.md +69 -0
- data/documentation/docs/api/page.md +1402 -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 +47 -0
- data/documentation/docs/api/web_socket.md +7 -0
- data/documentation/docs/api/worker.md +24 -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 +205 -0
- data/documentation/docs/article/guides/recording_video.md +79 -0
- data/{docs → documentation/docs/include}/api_coverage.md +11 -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 +8785 -0
- data/lib/playwright/channel_owners/binding_call.rb +33 -0
- data/lib/playwright/channel_owners/browser.rb +25 -12
- data/lib/playwright/channel_owners/browser_context.rb +67 -8
- data/lib/playwright/channel_owners/browser_type.rb +13 -9
- data/lib/playwright/channel_owners/element_handle.rb +17 -16
- data/lib/playwright/channel_owners/frame.rb +24 -34
- data/lib/playwright/channel_owners/js_handle.rb +2 -10
- data/lib/playwright/channel_owners/page.rb +37 -52
- data/lib/playwright/channel_owners/worker.rb +4 -0
- 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 +16 -1
- data/lib/playwright/tracing_impl.rb +31 -0
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/accessibility.rb +7 -88
- data/lib/playwright_api/android.rb +11 -67
- data/lib/playwright_api/android_device.rb +10 -9
- data/lib/playwright_api/browser.rb +21 -129
- data/lib/playwright_api/browser_context.rb +70 -437
- data/lib/playwright_api/browser_type.rb +34 -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 +104 -570
- 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 +228 -1229
- data/lib/playwright_api/playwright.rb +16 -101
- 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 +33 -0
- data/lib/playwright_api/web_socket.rb +1 -1
- data/lib/playwright_api/worker.rb +28 -42
- data/playwright.gemspec +1 -1
- metadata +61 -20
- data/lib/playwright/javascript/function.rb +0 -67
|
@@ -3,5 +3,38 @@ module Playwright
|
|
|
3
3
|
def name
|
|
4
4
|
@initializer['name']
|
|
5
5
|
end
|
|
6
|
+
|
|
7
|
+
def call_async(callback)
|
|
8
|
+
Thread.new(callback) { call(callback) }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @param callback [Proc]
|
|
12
|
+
def call(callback)
|
|
13
|
+
frame = ChannelOwners::Frame.from(@initializer['frame'])
|
|
14
|
+
# It is not desired to use PlaywrightApi.wrap directly.
|
|
15
|
+
# However it is a little difficult to define wrapper for `source` parameter in generate_api.
|
|
16
|
+
# Just a workaround...
|
|
17
|
+
source = {
|
|
18
|
+
context: PlaywrightApi.wrap(frame.page.context),
|
|
19
|
+
page: PlaywrightApi.wrap(frame.page),
|
|
20
|
+
frame: PlaywrightApi.wrap(frame),
|
|
21
|
+
}
|
|
22
|
+
args =
|
|
23
|
+
if @initializer['handle']
|
|
24
|
+
handle = ChannelOwners::ElementHandle.from(@initializer['handle'])
|
|
25
|
+
[handle]
|
|
26
|
+
else
|
|
27
|
+
@initializer['args'].map do |arg|
|
|
28
|
+
JavaScript::ValueParser.new(arg).parse
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
begin
|
|
33
|
+
result = PlaywrightApi.unwrap(callback.call(source, *args))
|
|
34
|
+
@channel.send_message_to_server('resolve', result: JavaScript::ValueSerializer.new(result).serialize)
|
|
35
|
+
rescue => err
|
|
36
|
+
@channel.send_message_to_server('reject', error: { error: { message: err.message, name: 'Error' }})
|
|
37
|
+
end
|
|
38
|
+
end
|
|
6
39
|
end
|
|
7
40
|
end
|
|
@@ -5,6 +5,10 @@ module Playwright
|
|
|
5
5
|
include Utils::PrepareBrowserContextOptions
|
|
6
6
|
|
|
7
7
|
private def after_initialize
|
|
8
|
+
@connected = true
|
|
9
|
+
@closed_or_closing = false
|
|
10
|
+
@remote = false
|
|
11
|
+
|
|
8
12
|
@contexts = Set.new
|
|
9
13
|
@channel.on('close', method(:on_close))
|
|
10
14
|
end
|
|
@@ -26,24 +30,28 @@ module Playwright
|
|
|
26
30
|
@contexts << context
|
|
27
31
|
context.browser = self
|
|
28
32
|
context.options = params
|
|
33
|
+
return context unless block
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
context.close
|
|
35
|
-
end
|
|
36
|
-
else
|
|
37
|
-
context
|
|
35
|
+
begin
|
|
36
|
+
block.call(context)
|
|
37
|
+
ensure
|
|
38
|
+
context.close
|
|
38
39
|
end
|
|
39
40
|
end
|
|
40
41
|
|
|
41
|
-
def new_page(**options)
|
|
42
|
+
def new_page(**options, &block)
|
|
42
43
|
context = new_context(**options)
|
|
43
44
|
page = context.new_page
|
|
44
45
|
page.owned_context = context
|
|
45
46
|
context.owner_page = page
|
|
46
|
-
|
|
47
|
+
|
|
48
|
+
return page unless block
|
|
49
|
+
|
|
50
|
+
begin
|
|
51
|
+
block.call(page)
|
|
52
|
+
ensure
|
|
53
|
+
page.close
|
|
54
|
+
end
|
|
47
55
|
end
|
|
48
56
|
|
|
49
57
|
def close
|
|
@@ -77,8 +85,8 @@ module Playwright
|
|
|
77
85
|
|
|
78
86
|
private def on_close(_ = {})
|
|
79
87
|
@connected = false
|
|
80
|
-
emit(Events::Browser::Disconnected)
|
|
81
|
-
@closed_or_closing =
|
|
88
|
+
emit(Events::Browser::Disconnected, self)
|
|
89
|
+
@closed_or_closing = true
|
|
82
90
|
end
|
|
83
91
|
|
|
84
92
|
# called from BrowserType#connectOverCDP
|
|
@@ -86,6 +94,11 @@ module Playwright
|
|
|
86
94
|
@contexts << context
|
|
87
95
|
end
|
|
88
96
|
|
|
97
|
+
# called from BrowserType#connectOverCDP
|
|
98
|
+
private def update_as_remote
|
|
99
|
+
@remote = true
|
|
100
|
+
end
|
|
101
|
+
|
|
89
102
|
# called from BrowserContext#on_close with send(:remove_context), so keep private.
|
|
90
103
|
private def remove_context(context)
|
|
91
104
|
@contexts.delete(context)
|
|
@@ -4,6 +4,7 @@ module Playwright
|
|
|
4
4
|
include Utils::Errors::SafeCloseError
|
|
5
5
|
attr_accessor :browser
|
|
6
6
|
attr_writer :owner_page, :options
|
|
7
|
+
attr_reader :tracing
|
|
7
8
|
|
|
8
9
|
private def after_initialize
|
|
9
10
|
@pages = Set.new
|
|
@@ -11,16 +12,45 @@ module Playwright
|
|
|
11
12
|
@bindings = {}
|
|
12
13
|
@timeout_settings = TimeoutSettings.new
|
|
13
14
|
|
|
15
|
+
@tracing = TracingImpl.new(@channel, self)
|
|
14
16
|
@channel.on('bindingCall', ->(params) { on_binding(ChannelOwners::BindingCall.from(params['binding'])) })
|
|
15
17
|
@channel.once('close', ->(_) { on_close })
|
|
16
18
|
@channel.on('page', ->(params) { on_page(ChannelOwners::Page.from(params['page']) )})
|
|
17
19
|
@channel.on('route', ->(params) {
|
|
18
20
|
on_route(ChannelOwners::Route.from(params['route']), ChannelOwners::Request.from(params['request']))
|
|
19
21
|
})
|
|
22
|
+
@channel.on('request', ->(params) {
|
|
23
|
+
on_request(
|
|
24
|
+
ChannelOwners::Request.from(params['request']),
|
|
25
|
+
ChannelOwners::Request.from_nullable(params['page']),
|
|
26
|
+
)
|
|
27
|
+
})
|
|
28
|
+
@channel.on('requestFailed', ->(params) {
|
|
29
|
+
on_request_failed(
|
|
30
|
+
ChannelOwners::Request.from(params['request']),
|
|
31
|
+
params['responseEndTiming'],
|
|
32
|
+
params['failureText'],
|
|
33
|
+
ChannelOwners::Request.from_nullable(params['page']),
|
|
34
|
+
)
|
|
35
|
+
})
|
|
36
|
+
@channel.on('requestFinished', ->(params) {
|
|
37
|
+
on_request_finished(
|
|
38
|
+
ChannelOwners::Request.from(params['request']),
|
|
39
|
+
params['responseEndTiming'],
|
|
40
|
+
ChannelOwners::Request.from_nullable(params['page']),
|
|
41
|
+
)
|
|
42
|
+
})
|
|
43
|
+
@channel.on('response', ->(params) {
|
|
44
|
+
on_response(
|
|
45
|
+
ChannelOwners::Response.from(params['response']),
|
|
46
|
+
ChannelOwners::Request.from_nullable(params['page']),
|
|
47
|
+
)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
@closed_promise = Concurrent::Promises.resolvable_future
|
|
20
51
|
end
|
|
21
52
|
|
|
22
53
|
private def on_page(page)
|
|
23
|
-
page.send(:update_browser_context, self)
|
|
24
54
|
@pages << page
|
|
25
55
|
emit(Events::BrowserContext::Page, page)
|
|
26
56
|
page.send(:emit_popup_event_from_browser_context)
|
|
@@ -39,12 +69,35 @@ module Playwright
|
|
|
39
69
|
end
|
|
40
70
|
|
|
41
71
|
private def on_binding(binding_call)
|
|
42
|
-
func = @
|
|
72
|
+
func = @bindings[binding_call.name]
|
|
43
73
|
if func
|
|
44
|
-
binding_call.
|
|
74
|
+
binding_call.call_async(func)
|
|
45
75
|
end
|
|
46
76
|
end
|
|
47
77
|
|
|
78
|
+
private def on_request_failed(request, response_end_timing, failure_text, page)
|
|
79
|
+
request.send(:update_failure_text, failure_text)
|
|
80
|
+
request.send(:update_response_end_timing, response_end_timing)
|
|
81
|
+
emit(Events::BrowserContext::RequestFailed, request)
|
|
82
|
+
page&.emit(Events::Page::RequestFailed, request)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
private def on_request_finished(request, response_end_timing, page)
|
|
86
|
+
request.send(:update_response_end_timing, response_end_timing)
|
|
87
|
+
emit(Events::BrowserContext::RequestFinished, request)
|
|
88
|
+
page&.emit(Events::Page::RequestFinished, request)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
private def on_request(request, page)
|
|
92
|
+
emit(Events::BrowserContext::Request, request)
|
|
93
|
+
page&.emit(Events::Page::Request, request)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
private def on_response(response, page)
|
|
97
|
+
emit(Events::BrowserContext::Response, response)
|
|
98
|
+
page&.emit(Events::Page::Response, response)
|
|
99
|
+
end
|
|
100
|
+
|
|
48
101
|
def set_default_navigation_timeout(timeout)
|
|
49
102
|
@timeout_settings.default_navigation_timeout = timeout
|
|
50
103
|
@channel.send_message_to_server('setDefaultNavigationTimeoutNoReply', timeout: timeout)
|
|
@@ -60,10 +113,17 @@ module Playwright
|
|
|
60
113
|
end
|
|
61
114
|
|
|
62
115
|
# @returns [Playwright::Page]
|
|
63
|
-
def new_page
|
|
116
|
+
def new_page(&block)
|
|
64
117
|
raise 'Please use browser.new_context' if @owner_page
|
|
65
118
|
resp = @channel.send_message_to_server('newPage')
|
|
66
|
-
ChannelOwners::Page.from(resp)
|
|
119
|
+
page = ChannelOwners::Page.from(resp)
|
|
120
|
+
return page unless block
|
|
121
|
+
|
|
122
|
+
begin
|
|
123
|
+
block.call(page)
|
|
124
|
+
ensure
|
|
125
|
+
page.close
|
|
126
|
+
end
|
|
67
127
|
end
|
|
68
128
|
|
|
69
129
|
def cookies(urls: nil)
|
|
@@ -172,15 +232,14 @@ module Playwright
|
|
|
172
232
|
end
|
|
173
233
|
|
|
174
234
|
private def on_close
|
|
175
|
-
@closed_or_closing = true
|
|
176
235
|
@browser&.send(:remove_context, self)
|
|
177
236
|
emit(Events::BrowserContext::Close)
|
|
237
|
+
@closed_promise.fulfill(true)
|
|
178
238
|
end
|
|
179
239
|
|
|
180
240
|
def close
|
|
181
|
-
return if @closed_or_closing
|
|
182
|
-
@closed_or_closing = true
|
|
183
241
|
@channel.send_message_to_server('close')
|
|
242
|
+
@closed_promise.value!
|
|
184
243
|
nil
|
|
185
244
|
rescue => err
|
|
186
245
|
raise unless safe_close_error?(err)
|
|
@@ -11,29 +11,33 @@ module Playwright
|
|
|
11
11
|
def launch(options, &block)
|
|
12
12
|
resp = @channel.send_message_to_server('launch', options.compact)
|
|
13
13
|
browser = ChannelOwners::Browser.from(resp)
|
|
14
|
+
return browser unless block
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
browser.close
|
|
20
|
-
end
|
|
21
|
-
else
|
|
22
|
-
browser
|
|
16
|
+
begin
|
|
17
|
+
block.call(browser)
|
|
18
|
+
ensure
|
|
19
|
+
browser.close
|
|
23
20
|
end
|
|
24
21
|
end
|
|
25
22
|
|
|
26
|
-
def connect_over_cdp(endpointURL, slowMo: nil, timeout: nil, &block)
|
|
23
|
+
def connect_over_cdp(endpointURL, headers: nil, slowMo: nil, timeout: nil, &block)
|
|
27
24
|
raise 'Connecting over CDP is only supported in Chromium.' unless name == 'chromium'
|
|
28
25
|
|
|
29
26
|
params = {
|
|
30
27
|
sdkLanguage: 'ruby',
|
|
31
28
|
endpointURL: endpointURL,
|
|
29
|
+
headers: headers,
|
|
32
30
|
slowMo: slowMo,
|
|
33
31
|
timeout: timeout,
|
|
34
32
|
}.compact
|
|
33
|
+
|
|
34
|
+
if headers
|
|
35
|
+
params[:headers] = HttpHeaders.new(headers).as_serialized
|
|
36
|
+
end
|
|
37
|
+
|
|
35
38
|
result = @channel.send_message_to_server_result('connectOverCDP', params)
|
|
36
39
|
browser = ChannelOwners::Browser.from(result['browser'])
|
|
40
|
+
browser.send(:update_as_remote)
|
|
37
41
|
|
|
38
42
|
if result['defaultContext']
|
|
39
43
|
context = ChannelOwners::BrowserContext.from(result['defaultContext'])
|
|
@@ -76,12 +76,13 @@ module Playwright
|
|
|
76
76
|
nil
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
def hover(force: nil, modifiers: nil, position: nil, timeout: nil)
|
|
79
|
+
def hover(force: nil, modifiers: nil, position: nil, timeout: nil, trial: nil)
|
|
80
80
|
params = {
|
|
81
81
|
force: force,
|
|
82
82
|
modifiers: modifiers,
|
|
83
83
|
position: position,
|
|
84
84
|
timeout: timeout,
|
|
85
|
+
trial: trial,
|
|
85
86
|
}.compact
|
|
86
87
|
@channel.send_message_to_server('hover', params)
|
|
87
88
|
|
|
@@ -96,7 +97,8 @@ module Playwright
|
|
|
96
97
|
modifiers: nil,
|
|
97
98
|
noWaitAfter: nil,
|
|
98
99
|
position: nil,
|
|
99
|
-
timeout: nil
|
|
100
|
+
timeout: nil,
|
|
101
|
+
trial: nil)
|
|
100
102
|
|
|
101
103
|
params = {
|
|
102
104
|
button: button,
|
|
@@ -107,6 +109,7 @@ module Playwright
|
|
|
107
109
|
noWaitAfter: noWaitAfter,
|
|
108
110
|
position: position,
|
|
109
111
|
timeout: timeout,
|
|
112
|
+
trial: trial,
|
|
110
113
|
}.compact
|
|
111
114
|
@channel.send_message_to_server('click', params)
|
|
112
115
|
|
|
@@ -120,7 +123,8 @@ module Playwright
|
|
|
120
123
|
modifiers: nil,
|
|
121
124
|
noWaitAfter: nil,
|
|
122
125
|
position: nil,
|
|
123
|
-
timeout: nil
|
|
126
|
+
timeout: nil,
|
|
127
|
+
trial: nil)
|
|
124
128
|
|
|
125
129
|
params = {
|
|
126
130
|
button: button,
|
|
@@ -130,6 +134,7 @@ module Playwright
|
|
|
130
134
|
noWaitAfter: noWaitAfter,
|
|
131
135
|
position: position,
|
|
132
136
|
timeout: timeout,
|
|
137
|
+
trial: trial,
|
|
133
138
|
}.compact
|
|
134
139
|
@channel.send_message_to_server('dblclick', params)
|
|
135
140
|
|
|
@@ -158,7 +163,8 @@ module Playwright
|
|
|
158
163
|
modifiers: nil,
|
|
159
164
|
noWaitAfter: nil,
|
|
160
165
|
position: nil,
|
|
161
|
-
timeout: nil
|
|
166
|
+
timeout: nil,
|
|
167
|
+
trial: nil)
|
|
162
168
|
|
|
163
169
|
params = {
|
|
164
170
|
force: force,
|
|
@@ -166,6 +172,7 @@ module Playwright
|
|
|
166
172
|
noWaitAfter: noWaitAfter,
|
|
167
173
|
position: position,
|
|
168
174
|
timeout: timeout,
|
|
175
|
+
trial: trial,
|
|
169
176
|
}.compact
|
|
170
177
|
@channel.send_message_to_server('tap', params)
|
|
171
178
|
|
|
@@ -228,24 +235,26 @@ module Playwright
|
|
|
228
235
|
nil
|
|
229
236
|
end
|
|
230
237
|
|
|
231
|
-
def check(force: nil, noWaitAfter: nil, position: nil, timeout: nil)
|
|
238
|
+
def check(force: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil)
|
|
232
239
|
params = {
|
|
233
240
|
force: force,
|
|
234
241
|
noWaitAfter: noWaitAfter,
|
|
235
242
|
position: position,
|
|
236
243
|
timeout: timeout,
|
|
244
|
+
trial: trial,
|
|
237
245
|
}.compact
|
|
238
246
|
@channel.send_message_to_server('check', params)
|
|
239
247
|
|
|
240
248
|
nil
|
|
241
249
|
end
|
|
242
250
|
|
|
243
|
-
def uncheck(force: nil, noWaitAfter: nil, position: nil, timeout: nil)
|
|
251
|
+
def uncheck(force: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil)
|
|
244
252
|
params = {
|
|
245
253
|
force: force,
|
|
246
254
|
noWaitAfter: noWaitAfter,
|
|
247
255
|
position: position,
|
|
248
256
|
timeout: timeout,
|
|
257
|
+
trial: trial,
|
|
249
258
|
}.compact
|
|
250
259
|
@channel.send_message_to_server('uncheck', params)
|
|
251
260
|
|
|
@@ -292,19 +301,11 @@ module Playwright
|
|
|
292
301
|
end
|
|
293
302
|
|
|
294
303
|
def eval_on_selector(selector, pageFunction, arg: nil)
|
|
295
|
-
|
|
296
|
-
JavaScript::Function.new(pageFunction, arg).eval_on_selector(@channel, selector)
|
|
297
|
-
else
|
|
298
|
-
JavaScript::Expression.new(pageFunction).eval_on_selector(@channel, selector)
|
|
299
|
-
end
|
|
304
|
+
JavaScript::Expression.new(pageFunction, arg).eval_on_selector(@channel, selector)
|
|
300
305
|
end
|
|
301
306
|
|
|
302
307
|
def eval_on_selector_all(selector, pageFunction, arg: nil)
|
|
303
|
-
|
|
304
|
-
JavaScript::Function.new(pageFunction, arg).eval_on_selector_all(@channel, selector)
|
|
305
|
-
else
|
|
306
|
-
JavaScript::Expression.new(pageFunction).eval_on_selector_all(@channel, selector)
|
|
307
|
-
end
|
|
308
|
+
JavaScript::Expression.new(pageFunction, arg).eval_on_selector_all(@channel, selector)
|
|
308
309
|
end
|
|
309
310
|
|
|
310
311
|
def wait_for_element_state(state, timeout: nil)
|
|
@@ -132,19 +132,11 @@ module Playwright
|
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
def evaluate(pageFunction, arg: nil)
|
|
135
|
-
|
|
136
|
-
JavaScript::Function.new(pageFunction, arg).evaluate(@channel)
|
|
137
|
-
else
|
|
138
|
-
JavaScript::Expression.new(pageFunction).evaluate(@channel)
|
|
139
|
-
end
|
|
135
|
+
JavaScript::Expression.new(pageFunction, arg).evaluate(@channel)
|
|
140
136
|
end
|
|
141
137
|
|
|
142
138
|
def evaluate_handle(pageFunction, arg: nil)
|
|
143
|
-
|
|
144
|
-
JavaScript::Function.new(pageFunction, arg).evaluate_handle(@channel)
|
|
145
|
-
else
|
|
146
|
-
JavaScript::Expression.new(pageFunction).evaluate_handle(@channel)
|
|
147
|
-
end
|
|
139
|
+
JavaScript::Expression.new(pageFunction, arg).evaluate_handle(@channel)
|
|
148
140
|
end
|
|
149
141
|
|
|
150
142
|
def query_selector(selector)
|
|
@@ -208,19 +200,11 @@ module Playwright
|
|
|
208
200
|
end
|
|
209
201
|
|
|
210
202
|
def eval_on_selector(selector, pageFunction, arg: nil)
|
|
211
|
-
|
|
212
|
-
JavaScript::Function.new(pageFunction, arg).eval_on_selector(@channel, selector)
|
|
213
|
-
else
|
|
214
|
-
JavaScript::Expression.new(pageFunction).eval_on_selector(@channel, selector)
|
|
215
|
-
end
|
|
203
|
+
JavaScript::Expression.new(pageFunction, arg).eval_on_selector(@channel, selector)
|
|
216
204
|
end
|
|
217
205
|
|
|
218
206
|
def eval_on_selector_all(selector, pageFunction, arg: nil)
|
|
219
|
-
|
|
220
|
-
JavaScript::Function.new(pageFunction, arg).eval_on_selector_all(@channel, selector)
|
|
221
|
-
else
|
|
222
|
-
JavaScript::Expression.new(pageFunction).eval_on_selector_all(@channel, selector)
|
|
223
|
-
end
|
|
207
|
+
JavaScript::Expression.new(pageFunction, arg).eval_on_selector_all(@channel, selector)
|
|
224
208
|
end
|
|
225
209
|
|
|
226
210
|
def content
|
|
@@ -289,7 +273,8 @@ module Playwright
|
|
|
289
273
|
modifiers: nil,
|
|
290
274
|
noWaitAfter: nil,
|
|
291
275
|
position: nil,
|
|
292
|
-
timeout: nil
|
|
276
|
+
timeout: nil,
|
|
277
|
+
trial: nil)
|
|
293
278
|
|
|
294
279
|
params = {
|
|
295
280
|
selector: selector,
|
|
@@ -301,6 +286,7 @@ module Playwright
|
|
|
301
286
|
noWaitAfter: noWaitAfter,
|
|
302
287
|
position: position,
|
|
303
288
|
timeout: timeout,
|
|
289
|
+
trial: trial,
|
|
304
290
|
}.compact
|
|
305
291
|
@channel.send_message_to_server('click', params)
|
|
306
292
|
|
|
@@ -315,7 +301,8 @@ module Playwright
|
|
|
315
301
|
modifiers: nil,
|
|
316
302
|
noWaitAfter: nil,
|
|
317
303
|
position: nil,
|
|
318
|
-
timeout: nil
|
|
304
|
+
timeout: nil,
|
|
305
|
+
trial: nil)
|
|
319
306
|
|
|
320
307
|
params = {
|
|
321
308
|
selector: selector,
|
|
@@ -326,6 +313,7 @@ module Playwright
|
|
|
326
313
|
noWaitAfter: noWaitAfter,
|
|
327
314
|
position: position,
|
|
328
315
|
timeout: timeout,
|
|
316
|
+
trial: trial,
|
|
329
317
|
}.compact
|
|
330
318
|
@channel.send_message_to_server('dblclick', params)
|
|
331
319
|
|
|
@@ -338,7 +326,8 @@ module Playwright
|
|
|
338
326
|
modifiers: nil,
|
|
339
327
|
noWaitAfter: nil,
|
|
340
328
|
position: nil,
|
|
341
|
-
timeout: nil
|
|
329
|
+
timeout: nil,
|
|
330
|
+
trial: nil)
|
|
342
331
|
params = {
|
|
343
332
|
selector: selector,
|
|
344
333
|
force: force,
|
|
@@ -346,6 +335,7 @@ module Playwright
|
|
|
346
335
|
noWaitAfter: noWaitAfter,
|
|
347
336
|
position: position,
|
|
348
337
|
timeout: timeout,
|
|
338
|
+
trial: trial,
|
|
349
339
|
}.compact
|
|
350
340
|
@channel.send_message_to_server('tap', params)
|
|
351
341
|
|
|
@@ -399,13 +389,15 @@ module Playwright
|
|
|
399
389
|
force: nil,
|
|
400
390
|
modifiers: nil,
|
|
401
391
|
position: nil,
|
|
402
|
-
timeout: nil
|
|
392
|
+
timeout: nil,
|
|
393
|
+
trial: nil)
|
|
403
394
|
params = {
|
|
404
395
|
selector: selector,
|
|
405
396
|
force: force,
|
|
406
397
|
modifiers: modifiers,
|
|
407
398
|
position: position,
|
|
408
399
|
timeout: timeout,
|
|
400
|
+
trial: trial,
|
|
409
401
|
}.compact
|
|
410
402
|
@channel.send_message_to_server('hover', params)
|
|
411
403
|
|
|
@@ -481,7 +473,8 @@ module Playwright
|
|
|
481
473
|
force: nil,
|
|
482
474
|
noWaitAfter: nil,
|
|
483
475
|
position: nil,
|
|
484
|
-
timeout: nil
|
|
476
|
+
timeout: nil,
|
|
477
|
+
trial: nil)
|
|
485
478
|
|
|
486
479
|
params = {
|
|
487
480
|
selector: selector,
|
|
@@ -489,6 +482,7 @@ module Playwright
|
|
|
489
482
|
noWaitAfter: noWaitAfter,
|
|
490
483
|
position: position,
|
|
491
484
|
timeout: timeout,
|
|
485
|
+
trial: trial,
|
|
492
486
|
}.compact
|
|
493
487
|
@channel.send_message_to_server('check', params)
|
|
494
488
|
|
|
@@ -500,7 +494,8 @@ module Playwright
|
|
|
500
494
|
force: nil,
|
|
501
495
|
noWaitAfter: nil,
|
|
502
496
|
position: nil,
|
|
503
|
-
timeout: nil
|
|
497
|
+
timeout: nil,
|
|
498
|
+
trial: nil)
|
|
504
499
|
|
|
505
500
|
params = {
|
|
506
501
|
selector: selector,
|
|
@@ -508,6 +503,7 @@ module Playwright
|
|
|
508
503
|
noWaitAfter: noWaitAfter,
|
|
509
504
|
position: position,
|
|
510
505
|
timeout: timeout,
|
|
506
|
+
trial: trial,
|
|
511
507
|
}.compact
|
|
512
508
|
@channel.send_message_to_server('uncheck', params)
|
|
513
509
|
|
|
@@ -519,14 +515,8 @@ module Playwright
|
|
|
519
515
|
raise ArgumentError.new("Unknown polling option: #{polling}")
|
|
520
516
|
end
|
|
521
517
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
JavaScript::Function.new(pageFunction, arg)
|
|
525
|
-
else
|
|
526
|
-
JavaScript::Expression.new(pageFunction)
|
|
527
|
-
end
|
|
528
|
-
|
|
529
|
-
function_or_expression.wait_for_function(@channel, polling: polling, timeout: timeout)
|
|
518
|
+
expression = JavaScript::Expression.new(pageFunction, arg)
|
|
519
|
+
expression.wait_for_function(@channel, polling: polling, timeout: timeout)
|
|
530
520
|
end
|
|
531
521
|
|
|
532
522
|
def title
|