playwright-ruby-client 0.8.1 → 1.14.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/documentation/docs/api/accessibility.md +51 -1
- data/documentation/docs/api/browser_context.md +28 -0
- data/documentation/docs/api/download.md +97 -0
- data/documentation/docs/api/element_handle.md +28 -3
- data/documentation/docs/api/experimental/android.md +15 -2
- data/documentation/docs/api/frame.md +116 -114
- data/documentation/docs/api/locator.md +650 -0
- data/documentation/docs/api/mouse.md +3 -4
- data/documentation/docs/api/page.md +109 -19
- data/documentation/docs/api/request.md +15 -19
- data/documentation/docs/api/touchscreen.md +8 -0
- data/documentation/docs/api/tracing.md +13 -12
- data/documentation/docs/api/worker.md +37 -0
- data/documentation/docs/article/guides/inspector.md +31 -0
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +1 -1
- data/documentation/docs/article/guides/semi_automation.md +1 -1
- data/documentation/docs/include/api_coverage.md +70 -14
- data/lib/playwright.rb +0 -1
- data/lib/playwright/accessibility_impl.rb +50 -0
- data/lib/playwright/channel_owners/browser_context.rb +70 -0
- data/lib/playwright/channel_owners/frame.rb +79 -33
- data/lib/playwright/channel_owners/page.rb +133 -42
- data/lib/playwright/channel_owners/request.rb +8 -8
- data/lib/playwright/channel_owners/worker.rb +23 -0
- data/lib/playwright/{download.rb → download_impl.rb} +1 -1
- data/lib/playwright/javascript/expression.rb +5 -4
- data/lib/playwright/locator_impl.rb +314 -0
- data/lib/playwright/timeout_settings.rb +4 -4
- data/lib/playwright/touchscreen_impl.rb +7 -0
- data/lib/playwright/tracing_impl.rb +9 -8
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/accessibility.rb +1 -1
- data/lib/playwright_api/android.rb +21 -8
- data/lib/playwright_api/android_device.rb +6 -6
- data/lib/playwright_api/browser.rb +6 -6
- data/lib/playwright_api/browser_context.rb +16 -11
- data/lib/playwright_api/browser_type.rb +6 -6
- data/lib/playwright_api/cdp_session.rb +6 -6
- data/lib/playwright_api/console_message.rb +6 -6
- data/lib/playwright_api/dialog.rb +6 -6
- data/lib/playwright_api/download.rb +70 -0
- data/lib/playwright_api/element_handle.rb +34 -20
- data/lib/playwright_api/frame.rb +85 -53
- data/lib/playwright_api/js_handle.rb +6 -6
- data/lib/playwright_api/locator.rb +509 -0
- data/lib/playwright_api/page.rb +91 -57
- data/lib/playwright_api/playwright.rb +6 -6
- 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 +6 -6
- data/lib/playwright_api/touchscreen.rb +1 -1
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +16 -6
- metadata +13 -6
@@ -22,3 +22,40 @@ for worker in page.workers:
|
|
22
22
|
```
|
23
23
|
|
24
24
|
|
25
|
+
|
26
|
+
## evaluate
|
27
|
+
|
28
|
+
```
|
29
|
+
def evaluate(expression, arg: nil)
|
30
|
+
```
|
31
|
+
|
32
|
+
Returns the return value of `expression`.
|
33
|
+
|
34
|
+
If the function passed to the [Worker#evaluate](./worker#evaluate) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Worker#evaluate](./worker#evaluate) would
|
35
|
+
wait for the promise to resolve and return its value.
|
36
|
+
|
37
|
+
If the function passed to the [Worker#evaluate](./worker#evaluate) returns a non-[Serializable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description) value, then
|
38
|
+
[Worker#evaluate](./worker#evaluate) returns `undefined`. Playwright also supports transferring some additional values that are
|
39
|
+
not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
40
|
+
|
41
|
+
## evaluate_handle
|
42
|
+
|
43
|
+
```
|
44
|
+
def evaluate_handle(expression, arg: nil)
|
45
|
+
```
|
46
|
+
|
47
|
+
Returns the return value of `expression` as a [JSHandle](./js_handle).
|
48
|
+
|
49
|
+
The only difference between [Worker#evaluate](./worker#evaluate) and [Worker#evaluate_handle](./worker#evaluate_handle) is that
|
50
|
+
[Worker#evaluate_handle](./worker#evaluate_handle) returns [JSHandle](./js_handle).
|
51
|
+
|
52
|
+
If the function passed to the [Worker#evaluate_handle](./worker#evaluate_handle) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then
|
53
|
+
[Worker#evaluate_handle](./worker#evaluate_handle) would wait for the promise to resolve and return its value.
|
54
|
+
|
55
|
+
## url
|
56
|
+
|
57
|
+
```
|
58
|
+
def url
|
59
|
+
```
|
60
|
+
|
61
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 6
|
3
|
+
---
|
4
|
+
|
5
|
+
# Playwright inspector
|
6
|
+
|
7
|
+
Playwright provides an useful inspector.
|
8
|
+
https://playwright.dev/docs/inspector/
|
9
|
+
|
10
|
+
## Overview
|
11
|
+
|
12
|
+
```ruby {4,8}
|
13
|
+
playwright.chromium.launch(headless: false) do |browser|
|
14
|
+
browser.new_context do |context|
|
15
|
+
# This method call should be put just after creating BrowserContext.
|
16
|
+
context.enable_debug_console!
|
17
|
+
|
18
|
+
page = context.new_pagè
|
19
|
+
page.goto('http://example.com/')
|
20
|
+
page.pause
|
21
|
+
end
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
`page.pause` requires Playwright debug session, and it can be enabled by calling `BrowserContext#enable_debug_console!` in advance.
|
26
|
+
|
27
|
+
Note that since Ruby is not officially supported in Playwright, many limitations exist. We CANNOT
|
28
|
+
|
29
|
+
* Launch inspector via `PWDEBUG=1`
|
30
|
+
* Debug without inspector UI (`PWDEBUG=console` is not working well)
|
31
|
+
* Show Ruby code in inspector
|
@@ -14,7 +14,7 @@ Keep in mind repeatedly that persistent browser context is NOT RECOMMENDED for m
|
|
14
14
|
|
15
15
|
## Pause automation for manual operation
|
16
16
|
|
17
|
-
|
17
|
+
We can simply use `binding.pry` (with `pry-byebug` installed).
|
18
18
|
|
19
19
|
```ruby {4}
|
20
20
|
playwright.chromium.launch_persistent_context('./data/', headless: false) do |context|
|
@@ -65,7 +65,7 @@
|
|
65
65
|
|
66
66
|
## Touchscreen
|
67
67
|
|
68
|
-
*
|
68
|
+
* tap_point
|
69
69
|
|
70
70
|
## JSHandle
|
71
71
|
|
@@ -116,9 +116,9 @@
|
|
116
116
|
* wait_for_element_state
|
117
117
|
* wait_for_selector
|
118
118
|
|
119
|
-
##
|
119
|
+
## Accessibility
|
120
120
|
|
121
|
-
*
|
121
|
+
* snapshot
|
122
122
|
|
123
123
|
## FileChooser
|
124
124
|
|
@@ -158,6 +158,7 @@
|
|
158
158
|
* enabled?
|
159
159
|
* hidden?
|
160
160
|
* visible?
|
161
|
+
* locator
|
161
162
|
* name
|
162
163
|
* page
|
163
164
|
* parent_frame
|
@@ -177,14 +178,14 @@
|
|
177
178
|
* wait_for_load_state
|
178
179
|
* expect_navigation
|
179
180
|
* wait_for_selector
|
180
|
-
*
|
181
|
+
* wait_for_timeout
|
181
182
|
* wait_for_url
|
182
183
|
|
183
184
|
## Worker
|
184
185
|
|
185
|
-
*
|
186
|
-
*
|
187
|
-
*
|
186
|
+
* evaluate
|
187
|
+
* evaluate_handle
|
188
|
+
* url
|
188
189
|
|
189
190
|
## Selectors
|
190
191
|
|
@@ -205,6 +206,17 @@
|
|
205
206
|
* message
|
206
207
|
* type
|
207
208
|
|
209
|
+
## Download
|
210
|
+
|
211
|
+
* cancel
|
212
|
+
* delete
|
213
|
+
* failure
|
214
|
+
* page
|
215
|
+
* path
|
216
|
+
* save_as
|
217
|
+
* suggested_filename
|
218
|
+
* url
|
219
|
+
|
208
220
|
## Page
|
209
221
|
|
210
222
|
* add_init_script
|
@@ -245,9 +257,10 @@
|
|
245
257
|
* enabled?
|
246
258
|
* hidden?
|
247
259
|
* visible?
|
260
|
+
* locator
|
248
261
|
* main_frame
|
249
262
|
* opener
|
250
|
-
*
|
263
|
+
* pause
|
251
264
|
* pdf
|
252
265
|
* press
|
253
266
|
* query_selector
|
@@ -283,11 +296,11 @@
|
|
283
296
|
* expect_request_finished
|
284
297
|
* expect_response
|
285
298
|
* wait_for_selector
|
286
|
-
*
|
299
|
+
* wait_for_timeout
|
287
300
|
* wait_for_url
|
288
301
|
* expect_websocket
|
289
|
-
*
|
290
|
-
*
|
302
|
+
* expect_worker
|
303
|
+
* workers
|
291
304
|
* ~~wait_for_event~~
|
292
305
|
* accessibility
|
293
306
|
* keyboard
|
@@ -298,7 +311,7 @@
|
|
298
311
|
|
299
312
|
* add_cookies
|
300
313
|
* add_init_script
|
301
|
-
*
|
314
|
+
* background_pages
|
302
315
|
* browser
|
303
316
|
* clear_cookies
|
304
317
|
* clear_permissions
|
@@ -311,13 +324,13 @@
|
|
311
324
|
* new_page
|
312
325
|
* pages
|
313
326
|
* route
|
314
|
-
*
|
327
|
+
* service_workers
|
315
328
|
* set_default_navigation_timeout
|
316
329
|
* set_default_timeout
|
317
330
|
* set_extra_http_headers
|
318
331
|
* set_geolocation
|
319
332
|
* set_offline
|
320
|
-
*
|
333
|
+
* storage_state
|
321
334
|
* unroute
|
322
335
|
* expect_event
|
323
336
|
* expect_page
|
@@ -364,6 +377,49 @@
|
|
364
377
|
* start
|
365
378
|
* stop
|
366
379
|
|
380
|
+
## Locator
|
381
|
+
|
382
|
+
* all_inner_texts
|
383
|
+
* all_text_contents
|
384
|
+
* bounding_box
|
385
|
+
* check
|
386
|
+
* click
|
387
|
+
* count
|
388
|
+
* dblclick
|
389
|
+
* dispatch_event
|
390
|
+
* element_handle
|
391
|
+
* element_handles
|
392
|
+
* evaluate
|
393
|
+
* evaluate_all
|
394
|
+
* evaluate_handle
|
395
|
+
* fill
|
396
|
+
* first
|
397
|
+
* focus
|
398
|
+
* get_attribute
|
399
|
+
* hover
|
400
|
+
* inner_html
|
401
|
+
* inner_text
|
402
|
+
* input_value
|
403
|
+
* checked?
|
404
|
+
* disabled?
|
405
|
+
* editable?
|
406
|
+
* enabled?
|
407
|
+
* hidden?
|
408
|
+
* visible?
|
409
|
+
* last
|
410
|
+
* locator
|
411
|
+
* nth
|
412
|
+
* press
|
413
|
+
* screenshot
|
414
|
+
* scroll_into_view_if_needed
|
415
|
+
* select_option
|
416
|
+
* select_text
|
417
|
+
* set_input_files
|
418
|
+
* tap_point
|
419
|
+
* text_content
|
420
|
+
* type
|
421
|
+
* uncheck
|
422
|
+
|
367
423
|
## Android
|
368
424
|
|
369
425
|
* devices
|
data/lib/playwright.rb
CHANGED
@@ -17,7 +17,6 @@ require 'playwright/utils'
|
|
17
17
|
require 'playwright/api_implementation'
|
18
18
|
require 'playwright/channel'
|
19
19
|
require 'playwright/channel_owner'
|
20
|
-
require 'playwright/download'
|
21
20
|
require 'playwright/http_headers'
|
22
21
|
require 'playwright/input_files'
|
23
22
|
require 'playwright/connection'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Playwright
|
2
|
+
define_api_implementation :AccessibilityImpl do
|
3
|
+
def initialize(channel)
|
4
|
+
@channel = channel
|
5
|
+
end
|
6
|
+
|
7
|
+
def snapshot(interestingOnly: nil, root: nil)
|
8
|
+
params = {
|
9
|
+
interestingOnly: interestingOnly,
|
10
|
+
root: root&.channel,
|
11
|
+
}.compact
|
12
|
+
result = @channel.send_message_to_server('accessibilitySnapshot', params)
|
13
|
+
format_ax_node_from_protocol(result) if result
|
14
|
+
result
|
15
|
+
end
|
16
|
+
|
17
|
+
# original JS implementation create a new Hash from ax_node,
|
18
|
+
# but this implementation directly modify ax_node and don't return hash.
|
19
|
+
private def format_ax_node_from_protocol(ax_node)
|
20
|
+
value = ax_node.delete('valueNumber') || ax_node.delete('valueString')
|
21
|
+
ax_node['value'] = value unless value.nil?
|
22
|
+
|
23
|
+
checked =
|
24
|
+
case ax_node['checked']
|
25
|
+
when 'checked'
|
26
|
+
true
|
27
|
+
when 'unchecked'
|
28
|
+
false
|
29
|
+
else
|
30
|
+
ax_node['checked']
|
31
|
+
end
|
32
|
+
ax_node['checked'] = checked unless checked.nil?
|
33
|
+
|
34
|
+
pressed =
|
35
|
+
case ax_node['pressed']
|
36
|
+
when 'pressed'
|
37
|
+
true
|
38
|
+
when 'released'
|
39
|
+
false
|
40
|
+
else
|
41
|
+
ax_node['pressed']
|
42
|
+
end
|
43
|
+
ax_node['pressed'] = pressed unless pressed.nil?
|
44
|
+
|
45
|
+
ax_node['children']&.each do |child|
|
46
|
+
format_ax_node_from_protocol(child)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -11,6 +11,8 @@ module Playwright
|
|
11
11
|
@routes = []
|
12
12
|
@bindings = {}
|
13
13
|
@timeout_settings = TimeoutSettings.new
|
14
|
+
@service_workers = Set.new
|
15
|
+
@background_pages = Set.new
|
14
16
|
|
15
17
|
@tracing = TracingImpl.new(@channel, self)
|
16
18
|
@channel.on('bindingCall', ->(params) { on_binding(ChannelOwners::BindingCall.from(params['binding'])) })
|
@@ -19,6 +21,12 @@ module Playwright
|
|
19
21
|
@channel.on('route', ->(params) {
|
20
22
|
on_route(ChannelOwners::Route.from(params['route']), ChannelOwners::Request.from(params['request']))
|
21
23
|
})
|
24
|
+
@channel.on('backgroundPage', ->(params) {
|
25
|
+
on_background_page(ChannelOwners::Page.from(params['page']))
|
26
|
+
})
|
27
|
+
@channel.on('serviceWorker', ->(params) {
|
28
|
+
on_service_worker(ChannelOwners::Worker.from(params['worker']))
|
29
|
+
})
|
22
30
|
@channel.on('request', ->(params) {
|
23
31
|
on_request(
|
24
32
|
ChannelOwners::Request.from(params['request']),
|
@@ -56,6 +64,11 @@ module Playwright
|
|
56
64
|
page.send(:emit_popup_event_from_browser_context)
|
57
65
|
end
|
58
66
|
|
67
|
+
private def on_background_page(page)
|
68
|
+
@background_pages << page
|
69
|
+
emit(Events::BrowserContext::BackgroundPage, page)
|
70
|
+
end
|
71
|
+
|
59
72
|
private def on_route(route, request)
|
60
73
|
# It is not desired to use PlaywrightApi.wrap directly.
|
61
74
|
# However it is a little difficult to define wrapper for `handler` parameter in generate_api.
|
@@ -98,6 +111,20 @@ module Playwright
|
|
98
111
|
page&.emit(Events::Page::Response, response)
|
99
112
|
end
|
100
113
|
|
114
|
+
private def on_service_worker(worker)
|
115
|
+
worker.context = self
|
116
|
+
@service_workers << worker
|
117
|
+
emit(Events::BrowserContext::ServiceWorker, worker)
|
118
|
+
end
|
119
|
+
|
120
|
+
def background_pages
|
121
|
+
@background_pages.to_a
|
122
|
+
end
|
123
|
+
|
124
|
+
def service_workers
|
125
|
+
@service_workers.to_a
|
126
|
+
end
|
127
|
+
|
101
128
|
def new_cdp_session(page)
|
102
129
|
resp = @channel.send_message_to_server('newCDPSession', page: page.channel)
|
103
130
|
ChannelOwners::CDPSession.from(resp)
|
@@ -250,10 +277,45 @@ module Playwright
|
|
250
277
|
raise unless safe_close_error?(err)
|
251
278
|
end
|
252
279
|
|
280
|
+
# REMARK: enable_debug_console is playwright-ruby-client specific method.
|
281
|
+
def enable_debug_console!
|
282
|
+
# Ruby is not supported in Playwright officially,
|
283
|
+
# and causes error:
|
284
|
+
#
|
285
|
+
# Error:
|
286
|
+
# ===============================
|
287
|
+
# Unsupported language: 'ruby'
|
288
|
+
# ===============================
|
289
|
+
#
|
290
|
+
# So, launch inspector as Python app.
|
291
|
+
# NOTE: This should be used only for Page#pause at this moment.
|
292
|
+
@channel.send_message_to_server('recorderSupplementEnable', language: :python)
|
293
|
+
@debug_console_enabled = true
|
294
|
+
end
|
295
|
+
|
296
|
+
class DebugConsoleNotEnabledError < StandardError
|
297
|
+
def initialize
|
298
|
+
super('Debug console should be enabled in advance, by calling `browser_context.enable_debug_console!`')
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
253
302
|
def pause
|
303
|
+
unless @debug_console_enabled
|
304
|
+
raise DebugConsoleNotEnabledError.new
|
305
|
+
end
|
254
306
|
@channel.send_message_to_server('pause')
|
255
307
|
end
|
256
308
|
|
309
|
+
def storage_state(path: nil)
|
310
|
+
@channel.send_message_to_server_result('storageState', {}).tap do |result|
|
311
|
+
if path
|
312
|
+
File.open(path, 'w') do |f|
|
313
|
+
f.write(JSON.dump(result))
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
257
319
|
def expect_page(predicate: nil, timeout: nil)
|
258
320
|
params = {
|
259
321
|
predicate: predicate,
|
@@ -267,6 +329,14 @@ module Playwright
|
|
267
329
|
@pages.delete(page)
|
268
330
|
end
|
269
331
|
|
332
|
+
private def remove_background_page(page)
|
333
|
+
@background_pages.delete(page)
|
334
|
+
end
|
335
|
+
|
336
|
+
private def remove_service_worker(worker)
|
337
|
+
@service_workers.delete(worker)
|
338
|
+
end
|
339
|
+
|
270
340
|
# called from Page with send(:_timeout_settings), so keep private.
|
271
341
|
private def _timeout_settings
|
272
342
|
@timeout_settings
|
@@ -139,8 +139,12 @@ module Playwright
|
|
139
139
|
JavaScript::Expression.new(pageFunction, arg).evaluate_handle(@channel)
|
140
140
|
end
|
141
141
|
|
142
|
-
def query_selector(selector)
|
143
|
-
|
142
|
+
def query_selector(selector, strict: nil)
|
143
|
+
params = {
|
144
|
+
selector: selector,
|
145
|
+
strict: strict,
|
146
|
+
}.compact
|
147
|
+
resp = @channel.send_message_to_server('querySelector', params)
|
144
148
|
ChannelOwners::ElementHandle.from_nullable(resp)
|
145
149
|
end
|
146
150
|
|
@@ -150,48 +154,53 @@ module Playwright
|
|
150
154
|
end
|
151
155
|
end
|
152
156
|
|
153
|
-
def wait_for_selector(selector, state: nil, timeout: nil)
|
154
|
-
params = { selector: selector, state: state, timeout: timeout }.compact
|
157
|
+
def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
|
158
|
+
params = { selector: selector, state: state, strict: strict, timeout: timeout }.compact
|
155
159
|
resp = @channel.send_message_to_server('waitForSelector', params)
|
156
160
|
|
157
161
|
ChannelOwners::ElementHandle.from_nullable(resp)
|
158
162
|
end
|
159
163
|
|
160
|
-
def checked?(selector, timeout: nil)
|
161
|
-
params = { selector: selector, timeout: timeout }.compact
|
164
|
+
def checked?(selector, strict: nil, timeout: nil)
|
165
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
162
166
|
@channel.send_message_to_server('isChecked', params)
|
163
167
|
end
|
164
168
|
|
165
|
-
def disabled?(selector, timeout: nil)
|
166
|
-
params = { selector: selector, timeout: timeout }.compact
|
169
|
+
def disabled?(selector, strict: nil, timeout: nil)
|
170
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
167
171
|
@channel.send_message_to_server('isDisabled', params)
|
168
172
|
end
|
169
173
|
|
170
|
-
def editable?(selector, timeout: nil)
|
171
|
-
params = { selector: selector, timeout: timeout }.compact
|
174
|
+
def editable?(selector, strict: nil, timeout: nil)
|
175
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
172
176
|
@channel.send_message_to_server('isEditable', params)
|
173
177
|
end
|
174
178
|
|
175
|
-
def enabled?(selector, timeout: nil)
|
176
|
-
params = { selector: selector, timeout: timeout }.compact
|
179
|
+
def enabled?(selector, strict: nil, timeout: nil)
|
180
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
177
181
|
@channel.send_message_to_server('isEnabled', params)
|
178
182
|
end
|
179
183
|
|
180
|
-
def hidden?(selector, timeout: nil)
|
181
|
-
params = { selector: selector, timeout: timeout }.compact
|
184
|
+
def hidden?(selector, strict: nil, timeout: nil)
|
185
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
182
186
|
@channel.send_message_to_server('isHidden', params)
|
183
187
|
end
|
184
188
|
|
185
|
-
def visible?(selector, timeout: nil)
|
186
|
-
params = { selector: selector, timeout: timeout }.compact
|
189
|
+
def visible?(selector, strict: nil, timeout: nil)
|
190
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
187
191
|
@channel.send_message_to_server('isVisible', params)
|
188
192
|
end
|
189
193
|
|
190
|
-
def
|
194
|
+
def locator(selector)
|
195
|
+
LocatorImpl.new(frame: self, timeout_settings: @page.send(:timeout_settings), selector: selector)
|
196
|
+
end
|
197
|
+
|
198
|
+
def dispatch_event(selector, type, eventInit: nil, strict: nil, timeout: nil)
|
191
199
|
params = {
|
192
200
|
selector: selector,
|
193
201
|
type: type,
|
194
202
|
eventInit: JavaScript::ValueSerializer.new(eventInit).serialize,
|
203
|
+
strict: strict,
|
195
204
|
timeout: timeout,
|
196
205
|
}.compact
|
197
206
|
@channel.send_message_to_server('dispatchEvent', params)
|
@@ -199,8 +208,8 @@ module Playwright
|
|
199
208
|
nil
|
200
209
|
end
|
201
210
|
|
202
|
-
def eval_on_selector(selector, pageFunction, arg: nil)
|
203
|
-
JavaScript::Expression.new(pageFunction, arg).eval_on_selector(@channel, selector)
|
211
|
+
def eval_on_selector(selector, pageFunction, arg: nil, strict: nil)
|
212
|
+
JavaScript::Expression.new(pageFunction, arg).eval_on_selector(@channel, selector, strict: strict)
|
204
213
|
end
|
205
214
|
|
206
215
|
def eval_on_selector_all(selector, pageFunction, arg: nil)
|
@@ -273,6 +282,7 @@ module Playwright
|
|
273
282
|
modifiers: nil,
|
274
283
|
noWaitAfter: nil,
|
275
284
|
position: nil,
|
285
|
+
strict: nil,
|
276
286
|
timeout: nil,
|
277
287
|
trial: nil)
|
278
288
|
|
@@ -285,6 +295,7 @@ module Playwright
|
|
285
295
|
modifiers: modifiers,
|
286
296
|
noWaitAfter: noWaitAfter,
|
287
297
|
position: position,
|
298
|
+
strict: strict,
|
288
299
|
timeout: timeout,
|
289
300
|
trial: trial,
|
290
301
|
}.compact
|
@@ -298,13 +309,20 @@ module Playwright
|
|
298
309
|
target,
|
299
310
|
force: nil,
|
300
311
|
noWaitAfter: nil,
|
312
|
+
sourcePosition: nil,
|
313
|
+
strict: nil,
|
314
|
+
targetPosition: nil,
|
301
315
|
timeout: nil,
|
302
316
|
trial: nil)
|
317
|
+
|
303
318
|
params = {
|
304
319
|
source: source,
|
305
320
|
target: target,
|
306
321
|
force: force,
|
307
322
|
noWaitAfter: noWaitAfter,
|
323
|
+
sourcePosition: sourcePosition,
|
324
|
+
strict: strict,
|
325
|
+
targetPosition: targetPosition,
|
308
326
|
timeout: timeout,
|
309
327
|
trial: trial,
|
310
328
|
}.compact
|
@@ -321,6 +339,7 @@ module Playwright
|
|
321
339
|
modifiers: nil,
|
322
340
|
noWaitAfter: nil,
|
323
341
|
position: nil,
|
342
|
+
strict: nil,
|
324
343
|
timeout: nil,
|
325
344
|
trial: nil)
|
326
345
|
|
@@ -332,6 +351,7 @@ module Playwright
|
|
332
351
|
modifiers: modifiers,
|
333
352
|
noWaitAfter: noWaitAfter,
|
334
353
|
position: position,
|
354
|
+
strict: strict,
|
335
355
|
timeout: timeout,
|
336
356
|
trial: trial,
|
337
357
|
}.compact
|
@@ -346,6 +366,7 @@ module Playwright
|
|
346
366
|
modifiers: nil,
|
347
367
|
noWaitAfter: nil,
|
348
368
|
position: nil,
|
369
|
+
strict: nil,
|
349
370
|
timeout: nil,
|
350
371
|
trial: nil)
|
351
372
|
params = {
|
@@ -354,6 +375,7 @@ module Playwright
|
|
354
375
|
modifiers: modifiers,
|
355
376
|
noWaitAfter: noWaitAfter,
|
356
377
|
position: position,
|
378
|
+
strict: strict,
|
357
379
|
timeout: timeout,
|
358
380
|
trial: trial,
|
359
381
|
}.compact
|
@@ -367,12 +389,14 @@ module Playwright
|
|
367
389
|
value,
|
368
390
|
force: nil,
|
369
391
|
noWaitAfter: nil,
|
392
|
+
strict: nil,
|
370
393
|
timeout: nil)
|
371
394
|
params = {
|
372
395
|
selector: selector,
|
373
396
|
value: value,
|
374
397
|
force: force,
|
375
398
|
noWaitAfter: noWaitAfter,
|
399
|
+
strict: strict,
|
376
400
|
timeout: timeout,
|
377
401
|
}.compact
|
378
402
|
@channel.send_message_to_server('fill', params)
|
@@ -380,31 +404,32 @@ module Playwright
|
|
380
404
|
nil
|
381
405
|
end
|
382
406
|
|
383
|
-
def focus(selector, timeout: nil)
|
384
|
-
params = { selector: selector, timeout: timeout }.compact
|
407
|
+
def focus(selector, strict: nil, timeout: nil)
|
408
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
385
409
|
@channel.send_message_to_server('focus', params)
|
386
410
|
nil
|
387
411
|
end
|
388
412
|
|
389
|
-
def text_content(selector, timeout: nil)
|
390
|
-
params = { selector: selector, timeout: timeout }.compact
|
413
|
+
def text_content(selector, strict: nil, timeout: nil)
|
414
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
391
415
|
@channel.send_message_to_server('textContent', params)
|
392
416
|
end
|
393
417
|
|
394
|
-
def inner_text(selector, timeout: nil)
|
395
|
-
params = { selector: selector, timeout: timeout }.compact
|
418
|
+
def inner_text(selector, strict: nil, timeout: nil)
|
419
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
396
420
|
@channel.send_message_to_server('innerText', params)
|
397
421
|
end
|
398
422
|
|
399
|
-
def inner_html(selector, timeout: nil)
|
400
|
-
params = { selector: selector, timeout: timeout }.compact
|
423
|
+
def inner_html(selector, strict: nil, timeout: nil)
|
424
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
401
425
|
@channel.send_message_to_server('innerHTML', params)
|
402
426
|
end
|
403
427
|
|
404
|
-
def get_attribute(selector, name, timeout: nil)
|
428
|
+
def get_attribute(selector, name, strict: nil, timeout: nil)
|
405
429
|
params = {
|
406
430
|
selector: selector,
|
407
431
|
name: name,
|
432
|
+
strict: strict,
|
408
433
|
timeout: timeout,
|
409
434
|
}.compact
|
410
435
|
@channel.send_message_to_server('getAttribute', params)
|
@@ -415,6 +440,7 @@ module Playwright
|
|
415
440
|
force: nil,
|
416
441
|
modifiers: nil,
|
417
442
|
position: nil,
|
443
|
+
strict: nil,
|
418
444
|
timeout: nil,
|
419
445
|
trial: nil)
|
420
446
|
params = {
|
@@ -422,6 +448,7 @@ module Playwright
|
|
422
448
|
force: force,
|
423
449
|
modifiers: modifiers,
|
424
450
|
position: position,
|
451
|
+
strict: strict,
|
425
452
|
timeout: timeout,
|
426
453
|
trial: trial,
|
427
454
|
}.compact
|
@@ -438,6 +465,7 @@ module Playwright
|
|
438
465
|
label: nil,
|
439
466
|
force: nil,
|
440
467
|
noWaitAfter: nil,
|
468
|
+
strict: nil,
|
441
469
|
timeout: nil)
|
442
470
|
base_params = SelectOptionValues.new(
|
443
471
|
element: element,
|
@@ -445,18 +473,24 @@ module Playwright
|
|
445
473
|
value: value,
|
446
474
|
label: label,
|
447
475
|
).as_params
|
448
|
-
params = base_params.merge({ selector: selector, force: force, noWaitAfter: noWaitAfter, timeout: timeout }.compact)
|
476
|
+
params = base_params.merge({ selector: selector, force: force, noWaitAfter: noWaitAfter, strict: strict, timeout: timeout }.compact)
|
449
477
|
@channel.send_message_to_server('selectOption', params)
|
450
478
|
end
|
451
479
|
|
452
|
-
def input_value(selector, timeout: nil)
|
453
|
-
params = { selector: selector, timeout: timeout }.compact
|
480
|
+
def input_value(selector, strict: nil, timeout: nil)
|
481
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
454
482
|
@channel.send_message_to_server('inputValue', params)
|
455
483
|
end
|
456
484
|
|
457
|
-
def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
|
485
|
+
def set_input_files(selector, files, noWaitAfter: nil, strict: nil, timeout: nil)
|
458
486
|
file_payloads = InputFiles.new(files).as_params
|
459
|
-
params = {
|
487
|
+
params = {
|
488
|
+
files: file_payloads,
|
489
|
+
selector: selector,
|
490
|
+
noWaitAfter: noWaitAfter,
|
491
|
+
strict: strict,
|
492
|
+
timeout: timeout,
|
493
|
+
}.compact
|
460
494
|
@channel.send_message_to_server('setInputFiles', params)
|
461
495
|
|
462
496
|
nil
|
@@ -467,6 +501,7 @@ module Playwright
|
|
467
501
|
text,
|
468
502
|
delay: nil,
|
469
503
|
noWaitAfter: nil,
|
504
|
+
strict: nil,
|
470
505
|
timeout: nil)
|
471
506
|
|
472
507
|
params = {
|
@@ -474,6 +509,7 @@ module Playwright
|
|
474
509
|
text: text,
|
475
510
|
delay: delay,
|
476
511
|
noWaitAfter: noWaitAfter,
|
512
|
+
strict: strict,
|
477
513
|
timeout: timeout,
|
478
514
|
}.compact
|
479
515
|
@channel.send_message_to_server('type', params)
|
@@ -486,6 +522,7 @@ module Playwright
|
|
486
522
|
key,
|
487
523
|
delay: nil,
|
488
524
|
noWaitAfter: nil,
|
525
|
+
strict: nil,
|
489
526
|
timeout: nil)
|
490
527
|
|
491
528
|
params = {
|
@@ -493,6 +530,7 @@ module Playwright
|
|
493
530
|
key: key,
|
494
531
|
delay: delay,
|
495
532
|
noWaitAfter: noWaitAfter,
|
533
|
+
strict: strict,
|
496
534
|
timeout: timeout,
|
497
535
|
}.compact
|
498
536
|
@channel.send_message_to_server('press', params)
|
@@ -505,6 +543,7 @@ module Playwright
|
|
505
543
|
force: nil,
|
506
544
|
noWaitAfter: nil,
|
507
545
|
position: nil,
|
546
|
+
strict: nil,
|
508
547
|
timeout: nil,
|
509
548
|
trial: nil)
|
510
549
|
|
@@ -513,6 +552,7 @@ module Playwright
|
|
513
552
|
force: force,
|
514
553
|
noWaitAfter: noWaitAfter,
|
515
554
|
position: position,
|
555
|
+
strict: strict,
|
516
556
|
timeout: timeout,
|
517
557
|
trial: trial,
|
518
558
|
}.compact
|
@@ -526,6 +566,7 @@ module Playwright
|
|
526
566
|
force: nil,
|
527
567
|
noWaitAfter: nil,
|
528
568
|
position: nil,
|
569
|
+
strict: nil,
|
529
570
|
timeout: nil,
|
530
571
|
trial: nil)
|
531
572
|
|
@@ -534,6 +575,7 @@ module Playwright
|
|
534
575
|
force: force,
|
535
576
|
noWaitAfter: noWaitAfter,
|
536
577
|
position: position,
|
578
|
+
strict: strict,
|
537
579
|
timeout: timeout,
|
538
580
|
trial: trial,
|
539
581
|
}.compact
|
@@ -542,6 +584,10 @@ module Playwright
|
|
542
584
|
nil
|
543
585
|
end
|
544
586
|
|
587
|
+
def wait_for_timeout(timeout)
|
588
|
+
sleep(timeout / 1000.0)
|
589
|
+
end
|
590
|
+
|
545
591
|
def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
|
546
592
|
if polling.is_a?(String) && polling != 'raf'
|
547
593
|
raise ArgumentError.new("Unknown polling option: #{polling}")
|