playwright-ruby-client 0.7.1 → 1.14.beta1
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 +26 -0
- data/documentation/docs/api/accessibility.md +52 -1
- data/documentation/docs/api/browser.md +8 -2
- data/documentation/docs/api/browser_context.md +28 -0
- data/documentation/docs/api/browser_type.md +1 -0
- data/documentation/docs/api/download.md +97 -0
- data/documentation/docs/api/element_handle.md +38 -4
- data/documentation/docs/api/experimental/android_device.md +1 -0
- data/documentation/docs/api/frame.md +89 -17
- data/documentation/docs/api/keyboard.md +11 -20
- data/documentation/docs/api/locator.md +650 -0
- data/documentation/docs/api/page.md +135 -19
- data/documentation/docs/api/response.md +16 -0
- data/documentation/docs/api/touchscreen.md +8 -0
- 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 +91 -0
- data/documentation/docs/article/guides/semi_automation.md +5 -1
- data/documentation/docs/include/api_coverage.md +77 -14
- data/lib/playwright.rb +36 -4
- data/lib/playwright/accessibility_impl.rb +50 -0
- data/lib/playwright/channel_owners/artifact.rb +4 -0
- data/lib/playwright/channel_owners/browser_context.rb +77 -3
- data/lib/playwright/channel_owners/element_handle.rb +11 -4
- data/lib/playwright/channel_owners/frame.rb +107 -34
- data/lib/playwright/channel_owners/page.rb +163 -55
- data/lib/playwright/channel_owners/response.rb +8 -0
- data/lib/playwright/channel_owners/worker.rb +23 -0
- data/lib/playwright/connection.rb +2 -4
- data/lib/playwright/{download.rb → download_impl.rb} +5 -1
- data/lib/playwright/javascript/expression.rb +5 -4
- data/lib/playwright/locator_impl.rb +314 -0
- data/lib/playwright/route_handler_entry.rb +3 -2
- data/lib/playwright/timeout_settings.rb +4 -4
- data/lib/playwright/touchscreen_impl.rb +7 -0
- data/lib/playwright/transport.rb +0 -1
- data/lib/playwright/url_matcher.rb +12 -2
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright/web_socket_client.rb +164 -0
- data/lib/playwright/web_socket_transport.rb +104 -0
- data/lib/playwright_api/accessibility.rb +1 -1
- data/lib/playwright_api/android_device.rb +6 -5
- data/lib/playwright_api/browser.rb +10 -4
- data/lib/playwright_api/browser_context.rb +12 -7
- data/lib/playwright_api/browser_type.rb +2 -1
- data/lib/playwright_api/cdp_session.rb +6 -6
- data/lib/playwright_api/download.rb +70 -0
- data/lib/playwright_api/element_handle.rb +38 -18
- data/lib/playwright_api/frame.rb +95 -44
- data/lib/playwright_api/locator.rb +509 -0
- data/lib/playwright_api/page.rb +102 -49
- data/lib/playwright_api/response.rb +10 -0
- data/lib/playwright_api/touchscreen.rb +1 -1
- data/lib/playwright_api/worker.rb +13 -3
- metadata +17 -7
@@ -146,6 +146,7 @@ module Playwright
|
|
146
146
|
index: nil,
|
147
147
|
value: nil,
|
148
148
|
label: nil,
|
149
|
+
force: nil,
|
149
150
|
noWaitAfter: nil,
|
150
151
|
timeout: nil)
|
151
152
|
base_params = SelectOptionValues.new(
|
@@ -154,7 +155,7 @@ module Playwright
|
|
154
155
|
value: value,
|
155
156
|
label: label,
|
156
157
|
).as_params
|
157
|
-
params = base_params.merge({ noWaitAfter: noWaitAfter, timeout: timeout }.compact)
|
158
|
+
params = base_params.merge({ force: force, noWaitAfter: noWaitAfter, timeout: timeout }.compact)
|
158
159
|
@channel.send_message_to_server('selectOption', params)
|
159
160
|
end
|
160
161
|
|
@@ -179,9 +180,10 @@ module Playwright
|
|
179
180
|
nil
|
180
181
|
end
|
181
182
|
|
182
|
-
def fill(value, noWaitAfter: nil, timeout: nil)
|
183
|
+
def fill(value, force: nil, noWaitAfter: nil, timeout: nil)
|
183
184
|
params = {
|
184
185
|
value: value,
|
186
|
+
force: force,
|
185
187
|
noWaitAfter: noWaitAfter,
|
186
188
|
timeout: timeout,
|
187
189
|
}.compact
|
@@ -190,13 +192,18 @@ module Playwright
|
|
190
192
|
nil
|
191
193
|
end
|
192
194
|
|
193
|
-
def select_text(timeout: nil)
|
194
|
-
params = { timeout: timeout }.compact
|
195
|
+
def select_text(force: nil, timeout: nil)
|
196
|
+
params = { force: force, timeout: timeout }.compact
|
195
197
|
@channel.send_message_to_server('selectText', params)
|
196
198
|
|
197
199
|
nil
|
198
200
|
end
|
199
201
|
|
202
|
+
def input_value(timeout: nil)
|
203
|
+
params = { timeout: timeout }.compact
|
204
|
+
@channel.send_message_to_server('inputValue', params)
|
205
|
+
end
|
206
|
+
|
200
207
|
def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
201
208
|
file_payloads = InputFiles.new(files).as_params
|
202
209
|
params = { files: file_payloads, noWaitAfter: noWaitAfter, timeout: timeout }.compact
|
@@ -71,7 +71,7 @@ module Playwright
|
|
71
71
|
|
72
72
|
predicate =
|
73
73
|
if url
|
74
|
-
matcher = UrlMatcher.new(url)
|
74
|
+
matcher = UrlMatcher.new(url, base_url: @page.context.send(:base_url))
|
75
75
|
->(event) { event['error'] || matcher.match?(event['url']) }
|
76
76
|
else
|
77
77
|
->(_) { true }
|
@@ -99,7 +99,7 @@ module Playwright
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def wait_for_url(url, timeout: nil, waitUntil: nil)
|
102
|
-
matcher = UrlMatcher.new(url)
|
102
|
+
matcher = UrlMatcher.new(url, base_url: @page.context.send(:base_url))
|
103
103
|
if matcher.match?(@url)
|
104
104
|
wait_for_load_state(state: waitUntil, timeout: timeout)
|
105
105
|
else
|
@@ -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
|
@@ -293,6 +304,28 @@ module Playwright
|
|
293
304
|
nil
|
294
305
|
end
|
295
306
|
|
307
|
+
def drag_and_drop(
|
308
|
+
source,
|
309
|
+
target,
|
310
|
+
force: nil,
|
311
|
+
noWaitAfter: nil,
|
312
|
+
strict: nil,
|
313
|
+
timeout: nil,
|
314
|
+
trial: nil)
|
315
|
+
params = {
|
316
|
+
source: source,
|
317
|
+
target: target,
|
318
|
+
force: force,
|
319
|
+
noWaitAfter: noWaitAfter,
|
320
|
+
strict: strict,
|
321
|
+
timeout: timeout,
|
322
|
+
trial: trial,
|
323
|
+
}.compact
|
324
|
+
@channel.send_message_to_server('dragAndDrop', params)
|
325
|
+
|
326
|
+
nil
|
327
|
+
end
|
328
|
+
|
296
329
|
def dblclick(
|
297
330
|
selector,
|
298
331
|
button: nil,
|
@@ -301,6 +334,7 @@ module Playwright
|
|
301
334
|
modifiers: nil,
|
302
335
|
noWaitAfter: nil,
|
303
336
|
position: nil,
|
337
|
+
strict: nil,
|
304
338
|
timeout: nil,
|
305
339
|
trial: nil)
|
306
340
|
|
@@ -312,6 +346,7 @@ module Playwright
|
|
312
346
|
modifiers: modifiers,
|
313
347
|
noWaitAfter: noWaitAfter,
|
314
348
|
position: position,
|
349
|
+
strict: strict,
|
315
350
|
timeout: timeout,
|
316
351
|
trial: trial,
|
317
352
|
}.compact
|
@@ -326,6 +361,7 @@ module Playwright
|
|
326
361
|
modifiers: nil,
|
327
362
|
noWaitAfter: nil,
|
328
363
|
position: nil,
|
364
|
+
strict: nil,
|
329
365
|
timeout: nil,
|
330
366
|
trial: nil)
|
331
367
|
params = {
|
@@ -334,6 +370,7 @@ module Playwright
|
|
334
370
|
modifiers: modifiers,
|
335
371
|
noWaitAfter: noWaitAfter,
|
336
372
|
position: position,
|
373
|
+
strict: strict,
|
337
374
|
timeout: timeout,
|
338
375
|
trial: trial,
|
339
376
|
}.compact
|
@@ -342,11 +379,19 @@ module Playwright
|
|
342
379
|
nil
|
343
380
|
end
|
344
381
|
|
345
|
-
def fill(
|
382
|
+
def fill(
|
383
|
+
selector,
|
384
|
+
value,
|
385
|
+
force: nil,
|
386
|
+
noWaitAfter: nil,
|
387
|
+
strict: nil,
|
388
|
+
timeout: nil)
|
346
389
|
params = {
|
347
390
|
selector: selector,
|
348
391
|
value: value,
|
392
|
+
force: force,
|
349
393
|
noWaitAfter: noWaitAfter,
|
394
|
+
strict: strict,
|
350
395
|
timeout: timeout,
|
351
396
|
}.compact
|
352
397
|
@channel.send_message_to_server('fill', params)
|
@@ -354,31 +399,32 @@ module Playwright
|
|
354
399
|
nil
|
355
400
|
end
|
356
401
|
|
357
|
-
def focus(selector, timeout: nil)
|
358
|
-
params = { selector: selector, timeout: timeout }.compact
|
402
|
+
def focus(selector, strict: nil, timeout: nil)
|
403
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
359
404
|
@channel.send_message_to_server('focus', params)
|
360
405
|
nil
|
361
406
|
end
|
362
407
|
|
363
|
-
def text_content(selector, timeout: nil)
|
364
|
-
params = { selector: selector, timeout: timeout }.compact
|
408
|
+
def text_content(selector, strict: nil, timeout: nil)
|
409
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
365
410
|
@channel.send_message_to_server('textContent', params)
|
366
411
|
end
|
367
412
|
|
368
|
-
def inner_text(selector, timeout: nil)
|
369
|
-
params = { selector: selector, timeout: timeout }.compact
|
413
|
+
def inner_text(selector, strict: nil, timeout: nil)
|
414
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
370
415
|
@channel.send_message_to_server('innerText', params)
|
371
416
|
end
|
372
417
|
|
373
|
-
def inner_html(selector, timeout: nil)
|
374
|
-
params = { selector: selector, timeout: timeout }.compact
|
418
|
+
def inner_html(selector, strict: nil, timeout: nil)
|
419
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
375
420
|
@channel.send_message_to_server('innerHTML', params)
|
376
421
|
end
|
377
422
|
|
378
|
-
def get_attribute(selector, name, timeout: nil)
|
423
|
+
def get_attribute(selector, name, strict: nil, timeout: nil)
|
379
424
|
params = {
|
380
425
|
selector: selector,
|
381
426
|
name: name,
|
427
|
+
strict: strict,
|
382
428
|
timeout: timeout,
|
383
429
|
}.compact
|
384
430
|
@channel.send_message_to_server('getAttribute', params)
|
@@ -389,6 +435,7 @@ module Playwright
|
|
389
435
|
force: nil,
|
390
436
|
modifiers: nil,
|
391
437
|
position: nil,
|
438
|
+
strict: nil,
|
392
439
|
timeout: nil,
|
393
440
|
trial: nil)
|
394
441
|
params = {
|
@@ -396,6 +443,7 @@ module Playwright
|
|
396
443
|
force: force,
|
397
444
|
modifiers: modifiers,
|
398
445
|
position: position,
|
446
|
+
strict: strict,
|
399
447
|
timeout: timeout,
|
400
448
|
trial: trial,
|
401
449
|
}.compact
|
@@ -410,7 +458,9 @@ module Playwright
|
|
410
458
|
index: nil,
|
411
459
|
value: nil,
|
412
460
|
label: nil,
|
461
|
+
force: nil,
|
413
462
|
noWaitAfter: nil,
|
463
|
+
strict: nil,
|
414
464
|
timeout: nil)
|
415
465
|
base_params = SelectOptionValues.new(
|
416
466
|
element: element,
|
@@ -418,13 +468,24 @@ module Playwright
|
|
418
468
|
value: value,
|
419
469
|
label: label,
|
420
470
|
).as_params
|
421
|
-
params = base_params.merge({ selector: selector, noWaitAfter: noWaitAfter, timeout: timeout }.compact)
|
471
|
+
params = base_params.merge({ selector: selector, force: force, noWaitAfter: noWaitAfter, strict: strict, timeout: timeout }.compact)
|
422
472
|
@channel.send_message_to_server('selectOption', params)
|
423
473
|
end
|
424
474
|
|
425
|
-
def
|
475
|
+
def input_value(selector, strict: nil, timeout: nil)
|
476
|
+
params = { selector: selector, strict: strict, timeout: timeout }.compact
|
477
|
+
@channel.send_message_to_server('inputValue', params)
|
478
|
+
end
|
479
|
+
|
480
|
+
def set_input_files(selector, files, noWaitAfter: nil, strict: nil, timeout: nil)
|
426
481
|
file_payloads = InputFiles.new(files).as_params
|
427
|
-
params = {
|
482
|
+
params = {
|
483
|
+
files: file_payloads,
|
484
|
+
selector: selector,
|
485
|
+
noWaitAfter: noWaitAfter,
|
486
|
+
strict: strict,
|
487
|
+
timeout: timeout,
|
488
|
+
}.compact
|
428
489
|
@channel.send_message_to_server('setInputFiles', params)
|
429
490
|
|
430
491
|
nil
|
@@ -435,6 +496,7 @@ module Playwright
|
|
435
496
|
text,
|
436
497
|
delay: nil,
|
437
498
|
noWaitAfter: nil,
|
499
|
+
strict: nil,
|
438
500
|
timeout: nil)
|
439
501
|
|
440
502
|
params = {
|
@@ -442,6 +504,7 @@ module Playwright
|
|
442
504
|
text: text,
|
443
505
|
delay: delay,
|
444
506
|
noWaitAfter: noWaitAfter,
|
507
|
+
strict: strict,
|
445
508
|
timeout: timeout,
|
446
509
|
}.compact
|
447
510
|
@channel.send_message_to_server('type', params)
|
@@ -454,6 +517,7 @@ module Playwright
|
|
454
517
|
key,
|
455
518
|
delay: nil,
|
456
519
|
noWaitAfter: nil,
|
520
|
+
strict: nil,
|
457
521
|
timeout: nil)
|
458
522
|
|
459
523
|
params = {
|
@@ -461,6 +525,7 @@ module Playwright
|
|
461
525
|
key: key,
|
462
526
|
delay: delay,
|
463
527
|
noWaitAfter: noWaitAfter,
|
528
|
+
strict: strict,
|
464
529
|
timeout: timeout,
|
465
530
|
}.compact
|
466
531
|
@channel.send_message_to_server('press', params)
|
@@ -473,6 +538,7 @@ module Playwright
|
|
473
538
|
force: nil,
|
474
539
|
noWaitAfter: nil,
|
475
540
|
position: nil,
|
541
|
+
strict: nil,
|
476
542
|
timeout: nil,
|
477
543
|
trial: nil)
|
478
544
|
|
@@ -481,6 +547,7 @@ module Playwright
|
|
481
547
|
force: force,
|
482
548
|
noWaitAfter: noWaitAfter,
|
483
549
|
position: position,
|
550
|
+
strict: strict,
|
484
551
|
timeout: timeout,
|
485
552
|
trial: trial,
|
486
553
|
}.compact
|
@@ -494,6 +561,7 @@ module Playwright
|
|
494
561
|
force: nil,
|
495
562
|
noWaitAfter: nil,
|
496
563
|
position: nil,
|
564
|
+
strict: nil,
|
497
565
|
timeout: nil,
|
498
566
|
trial: nil)
|
499
567
|
|
@@ -502,6 +570,7 @@ module Playwright
|
|
502
570
|
force: force,
|
503
571
|
noWaitAfter: noWaitAfter,
|
504
572
|
position: position,
|
573
|
+
strict: strict,
|
505
574
|
timeout: timeout,
|
506
575
|
trial: trial,
|
507
576
|
}.compact
|
@@ -510,6 +579,10 @@ module Playwright
|
|
510
579
|
nil
|
511
580
|
end
|
512
581
|
|
582
|
+
def wait_for_timeout(timeout)
|
583
|
+
sleep(timeout / 1000.0)
|
584
|
+
end
|
585
|
+
|
513
586
|
def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
|
514
587
|
if polling.is_a?(String) && polling != 'raf'
|
515
588
|
raise ArgumentError.new("Unknown polling option: #{polling}")
|
@@ -9,7 +9,7 @@ module Playwright
|
|
9
9
|
private def after_initialize
|
10
10
|
@browser_context = @parent
|
11
11
|
@timeout_settings = TimeoutSettings.new(@browser_context.send(:_timeout_settings))
|
12
|
-
@accessibility =
|
12
|
+
@accessibility = AccessibilityImpl.new(@channel)
|
13
13
|
@keyboard = KeyboardImpl.new(@channel)
|
14
14
|
@mouse = MouseImpl.new(@channel)
|
15
15
|
@touchscreen = TouchscreenImpl.new(@channel)
|
@@ -21,8 +21,9 @@ module Playwright
|
|
21
21
|
}
|
22
22
|
end
|
23
23
|
@closed = false
|
24
|
+
@workers = Set.new
|
24
25
|
@bindings = {}
|
25
|
-
@routes =
|
26
|
+
@routes = []
|
26
27
|
|
27
28
|
@main_frame = ChannelOwners::Frame.from(@initializer['mainFrame'])
|
28
29
|
@main_frame.send(:update_page_from_page, self)
|
@@ -66,7 +67,7 @@ module Playwright
|
|
66
67
|
})
|
67
68
|
@channel.on('worker', ->(params) {
|
68
69
|
worker = ChannelOwners::Worker.from(params['worker'])
|
69
|
-
|
70
|
+
on_worker(worker)
|
70
71
|
})
|
71
72
|
end
|
72
73
|
|
@@ -110,9 +111,16 @@ module Playwright
|
|
110
111
|
@browser_context.send(:on_binding, binding_call)
|
111
112
|
end
|
112
113
|
|
114
|
+
private def on_worker(worker)
|
115
|
+
worker.page = self
|
116
|
+
@workers << worker
|
117
|
+
emit(Events::Page::Worker, worker)
|
118
|
+
end
|
119
|
+
|
113
120
|
private def on_close
|
114
121
|
@closed = true
|
115
122
|
@browser_context.send(:remove_page, self)
|
123
|
+
@browser_context.send(:remove_background_page, self)
|
116
124
|
emit(Events::Page::Close)
|
117
125
|
end
|
118
126
|
|
@@ -124,7 +132,7 @@ module Playwright
|
|
124
132
|
end
|
125
133
|
|
126
134
|
private def on_download(params)
|
127
|
-
download =
|
135
|
+
download = DownloadImpl.new(
|
128
136
|
page: self,
|
129
137
|
url: params['url'],
|
130
138
|
suggested_filename: params['suggestedFilename'],
|
@@ -184,15 +192,8 @@ module Playwright
|
|
184
192
|
if name
|
185
193
|
@frames.find { |f| f.name == name }
|
186
194
|
elsif url
|
187
|
-
|
188
|
-
|
189
|
-
when String
|
190
|
-
@frames.find { |f| f.url == url }
|
191
|
-
when Regexp
|
192
|
-
@frames.find { |f| url.match?(f.url) }
|
193
|
-
else
|
194
|
-
raise NotImplementedError.new('Page#frame with url is not completely implemented yet')
|
195
|
-
end
|
195
|
+
matcher = UrlMatcher.new(url, base_url: @browser_context.send(:base_url))
|
196
|
+
@frames.find { |f| matcher.match?(f.url) }
|
196
197
|
else
|
197
198
|
raise ArgumentError.new('Either name or url matcher should be specified')
|
198
199
|
end
|
@@ -212,44 +213,48 @@ module Playwright
|
|
212
213
|
@channel.send_message_to_server('setDefaultTimeoutNoReply', timeout: timeout)
|
213
214
|
end
|
214
215
|
|
215
|
-
def query_selector(selector)
|
216
|
-
@main_frame.query_selector(selector)
|
216
|
+
def query_selector(selector, strict: nil)
|
217
|
+
@main_frame.query_selector(selector, strict: strict)
|
217
218
|
end
|
218
219
|
|
219
220
|
def query_selector_all(selector)
|
220
221
|
@main_frame.query_selector_all(selector)
|
221
222
|
end
|
222
223
|
|
223
|
-
def wait_for_selector(selector, state: nil, timeout: nil)
|
224
|
-
@main_frame.wait_for_selector(selector, state: state, timeout: timeout)
|
224
|
+
def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
|
225
|
+
@main_frame.wait_for_selector(selector, state: state, strict: strict, timeout: timeout)
|
225
226
|
end
|
226
227
|
|
227
|
-
def checked?(selector, timeout: nil)
|
228
|
-
@main_frame.checked?(selector, timeout: timeout)
|
228
|
+
def checked?(selector, strict: nil, timeout: nil)
|
229
|
+
@main_frame.checked?(selector, strict: strict, timeout: timeout)
|
229
230
|
end
|
230
231
|
|
231
|
-
def disabled?(selector, timeout: nil)
|
232
|
-
@main_frame.disabled?(selector, timeout: timeout)
|
232
|
+
def disabled?(selector, strict: nil, timeout: nil)
|
233
|
+
@main_frame.disabled?(selector, strict: strict, timeout: timeout)
|
233
234
|
end
|
234
235
|
|
235
|
-
def editable?(selector, timeout: nil)
|
236
|
-
@main_frame.editable?(selector, timeout: timeout)
|
236
|
+
def editable?(selector, strict: nil, timeout: nil)
|
237
|
+
@main_frame.editable?(selector, strict: strict, timeout: timeout)
|
237
238
|
end
|
238
239
|
|
239
|
-
def enabled?(selector, timeout: nil)
|
240
|
-
@main_frame.enabled?(selector, timeout: timeout)
|
240
|
+
def enabled?(selector, strict: nil, timeout: nil)
|
241
|
+
@main_frame.enabled?(selector, strict: strict, timeout: timeout)
|
241
242
|
end
|
242
243
|
|
243
|
-
def hidden?(selector, timeout: nil)
|
244
|
-
@main_frame.hidden?(selector, timeout: timeout)
|
244
|
+
def hidden?(selector, strict: nil, timeout: nil)
|
245
|
+
@main_frame.hidden?(selector, strict: strict, timeout: timeout)
|
245
246
|
end
|
246
247
|
|
247
|
-
def visible?(selector, timeout: nil)
|
248
|
-
@main_frame.visible?(selector, timeout: timeout)
|
248
|
+
def visible?(selector, strict: nil, timeout: nil)
|
249
|
+
@main_frame.visible?(selector, strict: strict, timeout: timeout)
|
249
250
|
end
|
250
251
|
|
251
|
-
def
|
252
|
-
@main_frame.
|
252
|
+
def locator(selector)
|
253
|
+
@main_frame.locator(selector)
|
254
|
+
end
|
255
|
+
|
256
|
+
def dispatch_event(selector, type, eventInit: nil, strict: nil, timeout: nil)
|
257
|
+
@main_frame.dispatch_event(selector, type, eventInit: eventInit, strict: strict, timeout: timeout)
|
253
258
|
end
|
254
259
|
|
255
260
|
def evaluate(pageFunction, arg: nil)
|
@@ -260,8 +265,8 @@ module Playwright
|
|
260
265
|
@main_frame.evaluate_handle(pageFunction, arg: arg)
|
261
266
|
end
|
262
267
|
|
263
|
-
def eval_on_selector(selector, pageFunction, arg: nil)
|
264
|
-
@main_frame.eval_on_selector(selector, pageFunction, arg: arg)
|
268
|
+
def eval_on_selector(selector, pageFunction, arg: nil, strict: nil)
|
269
|
+
@main_frame.eval_on_selector(selector, pageFunction, arg: arg, strict: strict)
|
265
270
|
end
|
266
271
|
|
267
272
|
def eval_on_selector_all(selector, pageFunction, arg: nil)
|
@@ -377,8 +382,8 @@ module Playwright
|
|
377
382
|
end
|
378
383
|
|
379
384
|
def route(url, handler)
|
380
|
-
entry = RouteHandlerEntry.new(url, handler)
|
381
|
-
@routes
|
385
|
+
entry = RouteHandlerEntry.new(url, @browser_context.send(:base_url), handler)
|
386
|
+
@routes.unshift(entry)
|
382
387
|
if @routes.count >= 1
|
383
388
|
@channel.send_message_to_server('setNetworkInterceptionEnabled', enabled: true)
|
384
389
|
end
|
@@ -446,6 +451,7 @@ module Playwright
|
|
446
451
|
modifiers: nil,
|
447
452
|
noWaitAfter: nil,
|
448
453
|
position: nil,
|
454
|
+
strict: nil,
|
449
455
|
timeout: nil,
|
450
456
|
trial: nil)
|
451
457
|
|
@@ -458,11 +464,31 @@ module Playwright
|
|
458
464
|
modifiers: modifiers,
|
459
465
|
noWaitAfter: noWaitAfter,
|
460
466
|
position: position,
|
467
|
+
strict: strict,
|
461
468
|
timeout: timeout,
|
462
469
|
trial: trial,
|
463
470
|
)
|
464
471
|
end
|
465
472
|
|
473
|
+
def drag_and_drop(
|
474
|
+
source,
|
475
|
+
target,
|
476
|
+
force: nil,
|
477
|
+
noWaitAfter: nil,
|
478
|
+
strict: nil,
|
479
|
+
timeout: nil,
|
480
|
+
trial: nil)
|
481
|
+
|
482
|
+
@main_frame.drag_and_drop(
|
483
|
+
source,
|
484
|
+
target,
|
485
|
+
force: force,
|
486
|
+
noWaitAfter: noWaitAfter,
|
487
|
+
strict: strict,
|
488
|
+
timeout: timeout,
|
489
|
+
trial: trial)
|
490
|
+
end
|
491
|
+
|
466
492
|
def dblclick(
|
467
493
|
selector,
|
468
494
|
button: nil,
|
@@ -471,6 +497,7 @@ module Playwright
|
|
471
497
|
modifiers: nil,
|
472
498
|
noWaitAfter: nil,
|
473
499
|
position: nil,
|
500
|
+
strict: nil,
|
474
501
|
timeout: nil,
|
475
502
|
trial: nil)
|
476
503
|
@main_frame.dblclick(
|
@@ -481,6 +508,7 @@ module Playwright
|
|
481
508
|
modifiers: modifiers,
|
482
509
|
noWaitAfter: noWaitAfter,
|
483
510
|
position: position,
|
511
|
+
strict: strict,
|
484
512
|
timeout: timeout,
|
485
513
|
trial: trial,
|
486
514
|
)
|
@@ -492,6 +520,7 @@ module Playwright
|
|
492
520
|
modifiers: nil,
|
493
521
|
noWaitAfter: nil,
|
494
522
|
position: nil,
|
523
|
+
strict: nil,
|
495
524
|
timeout: nil,
|
496
525
|
trial: nil)
|
497
526
|
@main_frame.tap_point(
|
@@ -500,33 +529,46 @@ module Playwright
|
|
500
529
|
modifiers: modifiers,
|
501
530
|
noWaitAfter: noWaitAfter,
|
502
531
|
position: position,
|
532
|
+
strict: strict,
|
503
533
|
timeout: timeout,
|
504
534
|
trial: trial,
|
505
535
|
)
|
506
536
|
end
|
507
537
|
|
508
|
-
def fill(
|
509
|
-
|
538
|
+
def fill(
|
539
|
+
selector,
|
540
|
+
value,
|
541
|
+
force: nil,
|
542
|
+
noWaitAfter: nil,
|
543
|
+
strict: nil,
|
544
|
+
timeout: nil)
|
545
|
+
@main_frame.fill(
|
546
|
+
selector,
|
547
|
+
value,
|
548
|
+
force: force,
|
549
|
+
noWaitAfter: noWaitAfter,
|
550
|
+
strict: strict,
|
551
|
+
timeout: timeout)
|
510
552
|
end
|
511
553
|
|
512
|
-
def focus(selector, timeout: nil)
|
513
|
-
@main_frame.focus(selector, timeout: timeout)
|
554
|
+
def focus(selector, strict: nil, timeout: nil)
|
555
|
+
@main_frame.focus(selector, strict: strict, timeout: timeout)
|
514
556
|
end
|
515
557
|
|
516
|
-
def text_content(selector, timeout: nil)
|
517
|
-
@main_frame.text_content(selector, timeout: timeout)
|
558
|
+
def text_content(selector, strict: nil, timeout: nil)
|
559
|
+
@main_frame.text_content(selector, strict: strict, timeout: timeout)
|
518
560
|
end
|
519
561
|
|
520
|
-
def inner_text(selector, timeout: nil)
|
521
|
-
@main_frame.inner_text(selector, timeout: timeout)
|
562
|
+
def inner_text(selector, strict: nil, timeout: nil)
|
563
|
+
@main_frame.inner_text(selector, strict: strict, timeout: timeout)
|
522
564
|
end
|
523
565
|
|
524
|
-
def inner_html(selector, timeout: nil)
|
525
|
-
@main_frame.inner_html(selector, timeout: timeout)
|
566
|
+
def inner_html(selector, strict: nil, timeout: nil)
|
567
|
+
@main_frame.inner_html(selector, strict: strict, timeout: timeout)
|
526
568
|
end
|
527
569
|
|
528
|
-
def get_attribute(selector, name, timeout: nil)
|
529
|
-
@main_frame.get_attribute(selector, name, timeout: timeout)
|
570
|
+
def get_attribute(selector, name, strict: nil, timeout: nil)
|
571
|
+
@main_frame.get_attribute(selector, name, strict: strict, timeout: timeout)
|
530
572
|
end
|
531
573
|
|
532
574
|
def hover(
|
@@ -534,6 +576,7 @@ module Playwright
|
|
534
576
|
force: nil,
|
535
577
|
modifiers: nil,
|
536
578
|
position: nil,
|
579
|
+
strict: nil,
|
537
580
|
timeout: nil,
|
538
581
|
trial: nil)
|
539
582
|
@main_frame.hover(
|
@@ -541,6 +584,7 @@ module Playwright
|
|
541
584
|
force: force,
|
542
585
|
modifiers: modifiers,
|
543
586
|
position: position,
|
587
|
+
strict: strict,
|
544
588
|
timeout: timeout,
|
545
589
|
trial: trial,
|
546
590
|
)
|
@@ -552,7 +596,9 @@ module Playwright
|
|
552
596
|
index: nil,
|
553
597
|
value: nil,
|
554
598
|
label: nil,
|
599
|
+
force: nil,
|
555
600
|
noWaitAfter: nil,
|
601
|
+
strict: nil,
|
556
602
|
timeout: nil)
|
557
603
|
@main_frame.select_option(
|
558
604
|
selector,
|
@@ -560,13 +606,24 @@ module Playwright
|
|
560
606
|
index: index,
|
561
607
|
value: value,
|
562
608
|
label: label,
|
609
|
+
force: force,
|
563
610
|
noWaitAfter: noWaitAfter,
|
611
|
+
strict: strict,
|
564
612
|
timeout: timeout,
|
565
613
|
)
|
566
614
|
end
|
567
615
|
|
568
|
-
def
|
569
|
-
@main_frame.
|
616
|
+
def input_value(selector, strict: nil, timeout: nil)
|
617
|
+
@main_frame.input_value(selector, strict: strict, timeout: timeout)
|
618
|
+
end
|
619
|
+
|
620
|
+
def set_input_files(selector, files, noWaitAfter: nil, strict: nil,timeout: nil)
|
621
|
+
@main_frame.set_input_files(
|
622
|
+
selector,
|
623
|
+
files,
|
624
|
+
noWaitAfter: noWaitAfter,
|
625
|
+
strict: strict,
|
626
|
+
timeout: timeout)
|
570
627
|
end
|
571
628
|
|
572
629
|
def type(
|
@@ -574,9 +631,16 @@ module Playwright
|
|
574
631
|
text,
|
575
632
|
delay: nil,
|
576
633
|
noWaitAfter: nil,
|
634
|
+
strict: nil,
|
577
635
|
timeout: nil)
|
578
636
|
|
579
|
-
@main_frame.type(
|
637
|
+
@main_frame.type(
|
638
|
+
selector,
|
639
|
+
text,
|
640
|
+
delay: delay,
|
641
|
+
noWaitAfter: noWaitAfter,
|
642
|
+
strict: strict,
|
643
|
+
timeout: timeout)
|
580
644
|
end
|
581
645
|
|
582
646
|
def press(
|
@@ -584,9 +648,16 @@ module Playwright
|
|
584
648
|
key,
|
585
649
|
delay: nil,
|
586
650
|
noWaitAfter: nil,
|
651
|
+
strict: nil,
|
587
652
|
timeout: nil)
|
588
653
|
|
589
|
-
@main_frame.press(
|
654
|
+
@main_frame.press(
|
655
|
+
selector,
|
656
|
+
key,
|
657
|
+
delay: delay,
|
658
|
+
noWaitAfter: noWaitAfter,
|
659
|
+
strict: strict,
|
660
|
+
timeout: timeout)
|
590
661
|
end
|
591
662
|
|
592
663
|
def check(
|
@@ -594,10 +665,18 @@ module Playwright
|
|
594
665
|
force: nil,
|
595
666
|
noWaitAfter: nil,
|
596
667
|
position: nil,
|
668
|
+
strict: nil,
|
597
669
|
timeout: nil,
|
598
670
|
trial: nil)
|
599
671
|
|
600
|
-
@main_frame.check(
|
672
|
+
@main_frame.check(
|
673
|
+
selector,
|
674
|
+
force: force,
|
675
|
+
noWaitAfter: noWaitAfter,
|
676
|
+
position: position,
|
677
|
+
strict: strict,
|
678
|
+
timeout: timeout,
|
679
|
+
trial: trial)
|
601
680
|
end
|
602
681
|
|
603
682
|
def uncheck(
|
@@ -605,16 +684,36 @@ module Playwright
|
|
605
684
|
force: nil,
|
606
685
|
noWaitAfter: nil,
|
607
686
|
position: nil,
|
687
|
+
strict: nil,
|
608
688
|
timeout: nil,
|
609
689
|
trial: nil)
|
610
690
|
|
611
|
-
@main_frame.uncheck(
|
691
|
+
@main_frame.uncheck(
|
692
|
+
selector,
|
693
|
+
force: force,
|
694
|
+
noWaitAfter: noWaitAfter,
|
695
|
+
position: position,
|
696
|
+
strict: strict,
|
697
|
+
timeout: timeout,
|
698
|
+
trial: trial)
|
699
|
+
end
|
700
|
+
|
701
|
+
def wait_for_timeout(timeout)
|
702
|
+
@main_frame.wait_for_timeout(timeout)
|
612
703
|
end
|
613
704
|
|
614
705
|
def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
|
615
706
|
@main_frame.wait_for_function(pageFunction, arg: arg, polling: polling, timeout: timeout)
|
616
707
|
end
|
617
708
|
|
709
|
+
def workers
|
710
|
+
@workers.to_a
|
711
|
+
end
|
712
|
+
|
713
|
+
def pause
|
714
|
+
@browser_context.send(:pause)
|
715
|
+
end
|
716
|
+
|
618
717
|
def pdf(
|
619
718
|
displayHeaderFooter: nil,
|
620
719
|
footerTemplate: nil,
|
@@ -748,7 +847,7 @@ module Playwright
|
|
748
847
|
predicate =
|
749
848
|
case urlOrPredicate
|
750
849
|
when String, Regexp
|
751
|
-
url_matcher = UrlMatcher.new(urlOrPredicate)
|
850
|
+
url_matcher = UrlMatcher.new(urlOrPredicate, base_url: @browser_context.send(:base_url))
|
752
851
|
-> (req){ url_matcher.match?(req.url) }
|
753
852
|
when Proc
|
754
853
|
urlOrPredicate
|
@@ -767,7 +866,7 @@ module Playwright
|
|
767
866
|
predicate =
|
768
867
|
case urlOrPredicate
|
769
868
|
when String, Regexp
|
770
|
-
url_matcher = UrlMatcher.new(urlOrPredicate)
|
869
|
+
url_matcher = UrlMatcher.new(urlOrPredicate, base_url: @browser_context.send(:base_url))
|
771
870
|
-> (req){ url_matcher.match?(req.url) }
|
772
871
|
when Proc
|
773
872
|
urlOrPredicate
|
@@ -782,6 +881,10 @@ module Playwright
|
|
782
881
|
expect_event(Events::Page::WebSocket, predicate: predicate, timeout: timeout, &block)
|
783
882
|
end
|
784
883
|
|
884
|
+
def expect_worker(predicate: nil, timeout: nil, &block)
|
885
|
+
expect_event(Events::Page::Worker, predicate: predicate, timeout: timeout, &block)
|
886
|
+
end
|
887
|
+
|
785
888
|
# called from Frame with send(:timeout_settings)
|
786
889
|
private def timeout_settings
|
787
890
|
@timeout_settings
|
@@ -792,6 +895,11 @@ module Playwright
|
|
792
895
|
@bindings.key?(name)
|
793
896
|
end
|
794
897
|
|
898
|
+
# called from Worker#on_close
|
899
|
+
private def remove_worker(worker)
|
900
|
+
@workers.delete(worker)
|
901
|
+
end
|
902
|
+
|
795
903
|
# Expose guid for library developers.
|
796
904
|
# Not intended to be used by users.
|
797
905
|
def guid
|