playwright-ruby-client 0.8.0 → 1.14.beta2

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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/accessibility.md +52 -1
  3. data/documentation/docs/api/browser.md +8 -2
  4. data/documentation/docs/api/browser_context.md +28 -0
  5. data/documentation/docs/api/browser_type.md +1 -0
  6. data/documentation/docs/api/download.md +97 -0
  7. data/documentation/docs/api/element_handle.md +28 -3
  8. data/documentation/docs/api/experimental/android_device.md +1 -0
  9. data/documentation/docs/api/frame.md +78 -18
  10. data/documentation/docs/api/keyboard.md +11 -20
  11. data/documentation/docs/api/locator.md +650 -0
  12. data/documentation/docs/api/page.md +124 -20
  13. data/documentation/docs/api/touchscreen.md +8 -0
  14. data/documentation/docs/api/worker.md +37 -0
  15. data/documentation/docs/article/guides/inspector.md +31 -0
  16. data/documentation/docs/article/guides/playwright_on_alpine_linux.md +91 -0
  17. data/documentation/docs/article/guides/semi_automation.md +5 -1
  18. data/documentation/docs/include/api_coverage.md +72 -15
  19. data/lib/playwright.rb +0 -1
  20. data/lib/playwright/accessibility_impl.rb +50 -0
  21. data/lib/playwright/channel_owners/artifact.rb +4 -0
  22. data/lib/playwright/channel_owners/browser_context.rb +77 -3
  23. data/lib/playwright/channel_owners/frame.rb +101 -35
  24. data/lib/playwright/channel_owners/page.rb +157 -56
  25. data/lib/playwright/channel_owners/worker.rb +23 -0
  26. data/lib/playwright/{download.rb → download_impl.rb} +5 -1
  27. data/lib/playwright/javascript/expression.rb +5 -4
  28. data/lib/playwright/locator_impl.rb +314 -0
  29. data/lib/playwright/route_handler_entry.rb +3 -2
  30. data/lib/playwright/timeout_settings.rb +4 -4
  31. data/lib/playwright/touchscreen_impl.rb +7 -0
  32. data/lib/playwright/tracing_impl.rb +9 -8
  33. data/lib/playwright/url_matcher.rb +12 -2
  34. data/lib/playwright/version.rb +2 -2
  35. data/lib/playwright_api/accessibility.rb +1 -1
  36. data/lib/playwright_api/android.rb +6 -6
  37. data/lib/playwright_api/android_device.rb +8 -7
  38. data/lib/playwright_api/browser.rb +16 -10
  39. data/lib/playwright_api/browser_context.rb +16 -11
  40. data/lib/playwright_api/browser_type.rb +8 -7
  41. data/lib/playwright_api/cdp_session.rb +6 -6
  42. data/lib/playwright_api/console_message.rb +6 -6
  43. data/lib/playwright_api/dialog.rb +6 -6
  44. data/lib/playwright_api/download.rb +70 -0
  45. data/lib/playwright_api/element_handle.rb +34 -20
  46. data/lib/playwright_api/frame.rb +94 -52
  47. data/lib/playwright_api/js_handle.rb +6 -6
  48. data/lib/playwright_api/locator.rb +509 -0
  49. data/lib/playwright_api/page.rb +101 -57
  50. data/lib/playwright_api/playwright.rb +6 -6
  51. data/lib/playwright_api/request.rb +6 -6
  52. data/lib/playwright_api/response.rb +6 -6
  53. data/lib/playwright_api/route.rb +6 -11
  54. data/lib/playwright_api/selectors.rb +6 -6
  55. data/lib/playwright_api/touchscreen.rb +1 -1
  56. data/lib/playwright_api/web_socket.rb +6 -6
  57. data/lib/playwright_api/worker.rb +16 -6
  58. metadata +14 -6
@@ -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
- resp = @channel.send_message_to_server('querySelector', selector: selector)
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 dispatch_event(selector, type, eventInit: nil, timeout: nil)
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,33 @@ 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
+ sourcePosition: nil,
313
+ strict: nil,
314
+ targetPosition: nil,
315
+ timeout: nil,
316
+ trial: nil)
317
+
318
+ params = {
319
+ source: source,
320
+ target: target,
321
+ force: force,
322
+ noWaitAfter: noWaitAfter,
323
+ sourcePosition: sourcePosition,
324
+ strict: strict,
325
+ targetPosition: targetPosition,
326
+ timeout: timeout,
327
+ trial: trial,
328
+ }.compact
329
+ @channel.send_message_to_server('dragAndDrop', params)
330
+
331
+ nil
332
+ end
333
+
296
334
  def dblclick(
297
335
  selector,
298
336
  button: nil,
@@ -301,6 +339,7 @@ module Playwright
301
339
  modifiers: nil,
302
340
  noWaitAfter: nil,
303
341
  position: nil,
342
+ strict: nil,
304
343
  timeout: nil,
305
344
  trial: nil)
306
345
 
@@ -312,6 +351,7 @@ module Playwright
312
351
  modifiers: modifiers,
313
352
  noWaitAfter: noWaitAfter,
314
353
  position: position,
354
+ strict: strict,
315
355
  timeout: timeout,
316
356
  trial: trial,
317
357
  }.compact
@@ -326,6 +366,7 @@ module Playwright
326
366
  modifiers: nil,
327
367
  noWaitAfter: nil,
328
368
  position: nil,
369
+ strict: nil,
329
370
  timeout: nil,
330
371
  trial: nil)
331
372
  params = {
@@ -334,6 +375,7 @@ module Playwright
334
375
  modifiers: modifiers,
335
376
  noWaitAfter: noWaitAfter,
336
377
  position: position,
378
+ strict: strict,
337
379
  timeout: timeout,
338
380
  trial: trial,
339
381
  }.compact
@@ -347,12 +389,14 @@ module Playwright
347
389
  value,
348
390
  force: nil,
349
391
  noWaitAfter: nil,
392
+ strict: nil,
350
393
  timeout: nil)
351
394
  params = {
352
395
  selector: selector,
353
396
  value: value,
354
397
  force: force,
355
398
  noWaitAfter: noWaitAfter,
399
+ strict: strict,
356
400
  timeout: timeout,
357
401
  }.compact
358
402
  @channel.send_message_to_server('fill', params)
@@ -360,31 +404,32 @@ module Playwright
360
404
  nil
361
405
  end
362
406
 
363
- def focus(selector, timeout: nil)
364
- params = { selector: selector, timeout: timeout }.compact
407
+ def focus(selector, strict: nil, timeout: nil)
408
+ params = { selector: selector, strict: strict, timeout: timeout }.compact
365
409
  @channel.send_message_to_server('focus', params)
366
410
  nil
367
411
  end
368
412
 
369
- def text_content(selector, timeout: nil)
370
- params = { selector: selector, timeout: timeout }.compact
413
+ def text_content(selector, strict: nil, timeout: nil)
414
+ params = { selector: selector, strict: strict, timeout: timeout }.compact
371
415
  @channel.send_message_to_server('textContent', params)
372
416
  end
373
417
 
374
- def inner_text(selector, timeout: nil)
375
- params = { selector: selector, timeout: timeout }.compact
418
+ def inner_text(selector, strict: nil, timeout: nil)
419
+ params = { selector: selector, strict: strict, timeout: timeout }.compact
376
420
  @channel.send_message_to_server('innerText', params)
377
421
  end
378
422
 
379
- def inner_html(selector, timeout: nil)
380
- params = { selector: selector, timeout: timeout }.compact
423
+ def inner_html(selector, strict: nil, timeout: nil)
424
+ params = { selector: selector, strict: strict, timeout: timeout }.compact
381
425
  @channel.send_message_to_server('innerHTML', params)
382
426
  end
383
427
 
384
- def get_attribute(selector, name, timeout: nil)
428
+ def get_attribute(selector, name, strict: nil, timeout: nil)
385
429
  params = {
386
430
  selector: selector,
387
431
  name: name,
432
+ strict: strict,
388
433
  timeout: timeout,
389
434
  }.compact
390
435
  @channel.send_message_to_server('getAttribute', params)
@@ -395,6 +440,7 @@ module Playwright
395
440
  force: nil,
396
441
  modifiers: nil,
397
442
  position: nil,
443
+ strict: nil,
398
444
  timeout: nil,
399
445
  trial: nil)
400
446
  params = {
@@ -402,6 +448,7 @@ module Playwright
402
448
  force: force,
403
449
  modifiers: modifiers,
404
450
  position: position,
451
+ strict: strict,
405
452
  timeout: timeout,
406
453
  trial: trial,
407
454
  }.compact
@@ -418,6 +465,7 @@ module Playwright
418
465
  label: nil,
419
466
  force: nil,
420
467
  noWaitAfter: nil,
468
+ strict: nil,
421
469
  timeout: nil)
422
470
  base_params = SelectOptionValues.new(
423
471
  element: element,
@@ -425,18 +473,24 @@ module Playwright
425
473
  value: value,
426
474
  label: label,
427
475
  ).as_params
428
- 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)
429
477
  @channel.send_message_to_server('selectOption', params)
430
478
  end
431
479
 
432
- def input_value(selector, timeout: nil)
433
- params = { selector: selector, timeout: timeout }.compact
480
+ def input_value(selector, strict: nil, timeout: nil)
481
+ params = { selector: selector, strict: strict, timeout: timeout }.compact
434
482
  @channel.send_message_to_server('inputValue', params)
435
483
  end
436
484
 
437
- def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
485
+ def set_input_files(selector, files, noWaitAfter: nil, strict: nil, timeout: nil)
438
486
  file_payloads = InputFiles.new(files).as_params
439
- params = { files: file_payloads, selector: selector, noWaitAfter: noWaitAfter, timeout: timeout }.compact
487
+ params = {
488
+ files: file_payloads,
489
+ selector: selector,
490
+ noWaitAfter: noWaitAfter,
491
+ strict: strict,
492
+ timeout: timeout,
493
+ }.compact
440
494
  @channel.send_message_to_server('setInputFiles', params)
441
495
 
442
496
  nil
@@ -447,6 +501,7 @@ module Playwright
447
501
  text,
448
502
  delay: nil,
449
503
  noWaitAfter: nil,
504
+ strict: nil,
450
505
  timeout: nil)
451
506
 
452
507
  params = {
@@ -454,6 +509,7 @@ module Playwright
454
509
  text: text,
455
510
  delay: delay,
456
511
  noWaitAfter: noWaitAfter,
512
+ strict: strict,
457
513
  timeout: timeout,
458
514
  }.compact
459
515
  @channel.send_message_to_server('type', params)
@@ -466,6 +522,7 @@ module Playwright
466
522
  key,
467
523
  delay: nil,
468
524
  noWaitAfter: nil,
525
+ strict: nil,
469
526
  timeout: nil)
470
527
 
471
528
  params = {
@@ -473,6 +530,7 @@ module Playwright
473
530
  key: key,
474
531
  delay: delay,
475
532
  noWaitAfter: noWaitAfter,
533
+ strict: strict,
476
534
  timeout: timeout,
477
535
  }.compact
478
536
  @channel.send_message_to_server('press', params)
@@ -485,6 +543,7 @@ module Playwright
485
543
  force: nil,
486
544
  noWaitAfter: nil,
487
545
  position: nil,
546
+ strict: nil,
488
547
  timeout: nil,
489
548
  trial: nil)
490
549
 
@@ -493,6 +552,7 @@ module Playwright
493
552
  force: force,
494
553
  noWaitAfter: noWaitAfter,
495
554
  position: position,
555
+ strict: strict,
496
556
  timeout: timeout,
497
557
  trial: trial,
498
558
  }.compact
@@ -506,6 +566,7 @@ module Playwright
506
566
  force: nil,
507
567
  noWaitAfter: nil,
508
568
  position: nil,
569
+ strict: nil,
509
570
  timeout: nil,
510
571
  trial: nil)
511
572
 
@@ -514,6 +575,7 @@ module Playwright
514
575
  force: force,
515
576
  noWaitAfter: noWaitAfter,
516
577
  position: position,
578
+ strict: strict,
517
579
  timeout: timeout,
518
580
  trial: trial,
519
581
  }.compact
@@ -522,6 +584,10 @@ module Playwright
522
584
  nil
523
585
  end
524
586
 
587
+ def wait_for_timeout(timeout)
588
+ sleep(timeout / 1000.0)
589
+ end
590
+
525
591
  def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
526
592
  if polling.is_a?(String) && polling != 'raf'
527
593
  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 = Accessibility.new(@channel)
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 = Set.new
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
- # on_worker(worker)
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 = Download.new(
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
- # ref: https://github.com/microsoft/playwright-python/blob/c4320c27cb080b385a5e45be46baa3cb7a9409ff/playwright/_impl/_helper.py#L104
188
- case url
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)
226
+ end
227
+
228
+ def checked?(selector, strict: nil, timeout: nil)
229
+ @main_frame.checked?(selector, strict: strict, timeout: timeout)
225
230
  end
226
231
 
227
- def checked?(selector, timeout: nil)
228
- @main_frame.checked?(selector, timeout: timeout)
232
+ def disabled?(selector, strict: nil, timeout: nil)
233
+ @main_frame.disabled?(selector, strict: strict, timeout: timeout)
229
234
  end
230
235
 
231
- def disabled?(selector, timeout: nil)
232
- @main_frame.disabled?(selector, timeout: timeout)
236
+ def editable?(selector, strict: nil, timeout: nil)
237
+ @main_frame.editable?(selector, strict: strict, timeout: timeout)
233
238
  end
234
239
 
235
- def editable?(selector, timeout: nil)
236
- @main_frame.editable?(selector, timeout: timeout)
240
+ def enabled?(selector, strict: nil, timeout: nil)
241
+ @main_frame.enabled?(selector, strict: strict, timeout: timeout)
237
242
  end
238
243
 
239
- def enabled?(selector, timeout: nil)
240
- @main_frame.enabled?(selector, timeout: timeout)
244
+ def hidden?(selector, strict: nil, timeout: nil)
245
+ @main_frame.hidden?(selector, strict: strict, timeout: timeout)
241
246
  end
242
247
 
243
- def hidden?(selector, timeout: nil)
244
- @main_frame.hidden?(selector, timeout: timeout)
248
+ def visible?(selector, strict: nil, timeout: nil)
249
+ @main_frame.visible?(selector, strict: strict, timeout: timeout)
245
250
  end
246
251
 
247
- def visible?(selector, timeout: nil)
248
- @main_frame.visible?(selector, timeout: timeout)
252
+ def locator(selector)
253
+ @main_frame.locator(selector)
249
254
  end
250
255
 
251
- def dispatch_event(selector, type, eventInit: nil, timeout: nil)
252
- @main_frame.dispatch_event(selector, type, eventInit: eventInit, timeout: timeout)
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 << entry
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,35 @@ 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
+ sourcePosition: nil,
479
+ strict: nil,
480
+ targetPosition: nil,
481
+ timeout: nil,
482
+ trial: nil)
483
+
484
+ @main_frame.drag_and_drop(
485
+ source,
486
+ target,
487
+ force: force,
488
+ noWaitAfter: noWaitAfter,
489
+ sourcePosition: sourcePosition,
490
+ strict: strict,
491
+ targetPosition: targetPosition,
492
+ timeout: timeout,
493
+ trial: trial)
494
+ end
495
+
466
496
  def dblclick(
467
497
  selector,
468
498
  button: nil,
@@ -471,6 +501,7 @@ module Playwright
471
501
  modifiers: nil,
472
502
  noWaitAfter: nil,
473
503
  position: nil,
504
+ strict: nil,
474
505
  timeout: nil,
475
506
  trial: nil)
476
507
  @main_frame.dblclick(
@@ -481,6 +512,7 @@ module Playwright
481
512
  modifiers: modifiers,
482
513
  noWaitAfter: noWaitAfter,
483
514
  position: position,
515
+ strict: strict,
484
516
  timeout: timeout,
485
517
  trial: trial,
486
518
  )
@@ -492,6 +524,7 @@ module Playwright
492
524
  modifiers: nil,
493
525
  noWaitAfter: nil,
494
526
  position: nil,
527
+ strict: nil,
495
528
  timeout: nil,
496
529
  trial: nil)
497
530
  @main_frame.tap_point(
@@ -500,6 +533,7 @@ module Playwright
500
533
  modifiers: modifiers,
501
534
  noWaitAfter: noWaitAfter,
502
535
  position: position,
536
+ strict: strict,
503
537
  timeout: timeout,
504
538
  trial: trial,
505
539
  )
@@ -510,28 +544,35 @@ module Playwright
510
544
  value,
511
545
  force: nil,
512
546
  noWaitAfter: nil,
547
+ strict: nil,
513
548
  timeout: nil)
514
- @main_frame.fill(selector, value, force: force, noWaitAfter: noWaitAfter, timeout: timeout)
549
+ @main_frame.fill(
550
+ selector,
551
+ value,
552
+ force: force,
553
+ noWaitAfter: noWaitAfter,
554
+ strict: strict,
555
+ timeout: timeout)
515
556
  end
516
557
 
517
- def focus(selector, timeout: nil)
518
- @main_frame.focus(selector, timeout: timeout)
558
+ def focus(selector, strict: nil, timeout: nil)
559
+ @main_frame.focus(selector, strict: strict, timeout: timeout)
519
560
  end
520
561
 
521
- def text_content(selector, timeout: nil)
522
- @main_frame.text_content(selector, timeout: timeout)
562
+ def text_content(selector, strict: nil, timeout: nil)
563
+ @main_frame.text_content(selector, strict: strict, timeout: timeout)
523
564
  end
524
565
 
525
- def inner_text(selector, timeout: nil)
526
- @main_frame.inner_text(selector, timeout: timeout)
566
+ def inner_text(selector, strict: nil, timeout: nil)
567
+ @main_frame.inner_text(selector, strict: strict, timeout: timeout)
527
568
  end
528
569
 
529
- def inner_html(selector, timeout: nil)
530
- @main_frame.inner_html(selector, timeout: timeout)
570
+ def inner_html(selector, strict: nil, timeout: nil)
571
+ @main_frame.inner_html(selector, strict: strict, timeout: timeout)
531
572
  end
532
573
 
533
- def get_attribute(selector, name, timeout: nil)
534
- @main_frame.get_attribute(selector, name, timeout: timeout)
574
+ def get_attribute(selector, name, strict: nil, timeout: nil)
575
+ @main_frame.get_attribute(selector, name, strict: strict, timeout: timeout)
535
576
  end
536
577
 
537
578
  def hover(
@@ -539,6 +580,7 @@ module Playwright
539
580
  force: nil,
540
581
  modifiers: nil,
541
582
  position: nil,
583
+ strict: nil,
542
584
  timeout: nil,
543
585
  trial: nil)
544
586
  @main_frame.hover(
@@ -546,6 +588,7 @@ module Playwright
546
588
  force: force,
547
589
  modifiers: modifiers,
548
590
  position: position,
591
+ strict: strict,
549
592
  timeout: timeout,
550
593
  trial: trial,
551
594
  )
@@ -559,6 +602,7 @@ module Playwright
559
602
  label: nil,
560
603
  force: nil,
561
604
  noWaitAfter: nil,
605
+ strict: nil,
562
606
  timeout: nil)
563
607
  @main_frame.select_option(
564
608
  selector,
@@ -568,16 +612,22 @@ module Playwright
568
612
  label: label,
569
613
  force: force,
570
614
  noWaitAfter: noWaitAfter,
615
+ strict: strict,
571
616
  timeout: timeout,
572
617
  )
573
618
  end
574
619
 
575
- def input_value(selector, timeout: nil)
576
- @main_frame.input_value(selector, timeout: timeout)
620
+ def input_value(selector, strict: nil, timeout: nil)
621
+ @main_frame.input_value(selector, strict: strict, timeout: timeout)
577
622
  end
578
623
 
579
- def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
580
- @main_frame.set_input_files(selector, files, noWaitAfter: noWaitAfter, timeout: timeout)
624
+ def set_input_files(selector, files, noWaitAfter: nil, strict: nil,timeout: nil)
625
+ @main_frame.set_input_files(
626
+ selector,
627
+ files,
628
+ noWaitAfter: noWaitAfter,
629
+ strict: strict,
630
+ timeout: timeout)
581
631
  end
582
632
 
583
633
  def type(
@@ -585,9 +635,16 @@ module Playwright
585
635
  text,
586
636
  delay: nil,
587
637
  noWaitAfter: nil,
638
+ strict: nil,
588
639
  timeout: nil)
589
640
 
590
- @main_frame.type(selector, text, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout)
641
+ @main_frame.type(
642
+ selector,
643
+ text,
644
+ delay: delay,
645
+ noWaitAfter: noWaitAfter,
646
+ strict: strict,
647
+ timeout: timeout)
591
648
  end
592
649
 
593
650
  def press(
@@ -595,9 +652,16 @@ module Playwright
595
652
  key,
596
653
  delay: nil,
597
654
  noWaitAfter: nil,
655
+ strict: nil,
598
656
  timeout: nil)
599
657
 
600
- @main_frame.press(selector, key, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout)
658
+ @main_frame.press(
659
+ selector,
660
+ key,
661
+ delay: delay,
662
+ noWaitAfter: noWaitAfter,
663
+ strict: strict,
664
+ timeout: timeout)
601
665
  end
602
666
 
603
667
  def check(
@@ -605,10 +669,18 @@ module Playwright
605
669
  force: nil,
606
670
  noWaitAfter: nil,
607
671
  position: nil,
672
+ strict: nil,
608
673
  timeout: nil,
609
674
  trial: nil)
610
675
 
611
- @main_frame.check(selector, force: force, noWaitAfter: noWaitAfter, position: position, timeout: timeout, trial: trial)
676
+ @main_frame.check(
677
+ selector,
678
+ force: force,
679
+ noWaitAfter: noWaitAfter,
680
+ position: position,
681
+ strict: strict,
682
+ timeout: timeout,
683
+ trial: trial)
612
684
  end
613
685
 
614
686
  def uncheck(
@@ -616,16 +688,36 @@ module Playwright
616
688
  force: nil,
617
689
  noWaitAfter: nil,
618
690
  position: nil,
691
+ strict: nil,
619
692
  timeout: nil,
620
693
  trial: nil)
621
694
 
622
- @main_frame.uncheck(selector, force: force, noWaitAfter: noWaitAfter, position: position, timeout: timeout, trial: trial)
695
+ @main_frame.uncheck(
696
+ selector,
697
+ force: force,
698
+ noWaitAfter: noWaitAfter,
699
+ position: position,
700
+ strict: strict,
701
+ timeout: timeout,
702
+ trial: trial)
703
+ end
704
+
705
+ def wait_for_timeout(timeout)
706
+ @main_frame.wait_for_timeout(timeout)
623
707
  end
624
708
 
625
709
  def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
626
710
  @main_frame.wait_for_function(pageFunction, arg: arg, polling: polling, timeout: timeout)
627
711
  end
628
712
 
713
+ def workers
714
+ @workers.to_a
715
+ end
716
+
717
+ def pause
718
+ @browser_context.send(:pause)
719
+ end
720
+
629
721
  def pdf(
630
722
  displayHeaderFooter: nil,
631
723
  footerTemplate: nil,
@@ -759,7 +851,7 @@ module Playwright
759
851
  predicate =
760
852
  case urlOrPredicate
761
853
  when String, Regexp
762
- url_matcher = UrlMatcher.new(urlOrPredicate)
854
+ url_matcher = UrlMatcher.new(urlOrPredicate, base_url: @browser_context.send(:base_url))
763
855
  -> (req){ url_matcher.match?(req.url) }
764
856
  when Proc
765
857
  urlOrPredicate
@@ -778,7 +870,7 @@ module Playwright
778
870
  predicate =
779
871
  case urlOrPredicate
780
872
  when String, Regexp
781
- url_matcher = UrlMatcher.new(urlOrPredicate)
873
+ url_matcher = UrlMatcher.new(urlOrPredicate, base_url: @browser_context.send(:base_url))
782
874
  -> (req){ url_matcher.match?(req.url) }
783
875
  when Proc
784
876
  urlOrPredicate
@@ -793,6 +885,10 @@ module Playwright
793
885
  expect_event(Events::Page::WebSocket, predicate: predicate, timeout: timeout, &block)
794
886
  end
795
887
 
888
+ def expect_worker(predicate: nil, timeout: nil, &block)
889
+ expect_event(Events::Page::Worker, predicate: predicate, timeout: timeout, &block)
890
+ end
891
+
796
892
  # called from Frame with send(:timeout_settings)
797
893
  private def timeout_settings
798
894
  @timeout_settings
@@ -803,6 +899,11 @@ module Playwright
803
899
  @bindings.key?(name)
804
900
  end
805
901
 
902
+ # called from Worker#on_close
903
+ private def remove_worker(worker)
904
+ @workers.delete(worker)
905
+ end
906
+
806
907
  # Expose guid for library developers.
807
908
  # Not intended to be used by users.
808
909
  def guid