playwright-ruby-client 0.0.5 → 0.1.0

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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +114 -2
  3. data/docs/api_coverage.md +351 -0
  4. data/lib/playwright.rb +7 -1
  5. data/lib/playwright/android_input_impl.rb +23 -0
  6. data/lib/playwright/api_implementation.rb +18 -0
  7. data/lib/playwright/channel.rb +7 -0
  8. data/lib/playwright/channel_owner.rb +3 -2
  9. data/lib/playwright/channel_owners/android.rb +10 -1
  10. data/lib/playwright/channel_owners/android_device.rb +163 -0
  11. data/lib/playwright/channel_owners/browser.rb +13 -13
  12. data/lib/playwright/channel_owners/browser_context.rb +9 -1
  13. data/lib/playwright/channel_owners/download.rb +27 -0
  14. data/lib/playwright/channel_owners/element_handle.rb +306 -0
  15. data/lib/playwright/channel_owners/frame.rb +371 -19
  16. data/lib/playwright/channel_owners/js_handle.rb +51 -0
  17. data/lib/playwright/channel_owners/page.rb +416 -19
  18. data/lib/playwright/channel_owners/request.rb +98 -0
  19. data/lib/playwright/channel_owners/webkit_browser.rb +1 -1
  20. data/lib/playwright/connection.rb +9 -6
  21. data/lib/playwright/errors.rb +2 -2
  22. data/lib/playwright/event_emitter.rb +8 -1
  23. data/lib/playwright/event_emitter_proxy.rb +49 -0
  24. data/lib/playwright/file_chooser_impl.rb +23 -0
  25. data/lib/playwright/http_headers.rb +20 -0
  26. data/lib/playwright/input_files.rb +42 -0
  27. data/lib/playwright/javascript/expression.rb +37 -0
  28. data/lib/playwright/javascript/function.rb +37 -0
  29. data/lib/playwright/javascript/value_parser.rb +1 -1
  30. data/lib/playwright/javascript/value_serializer.rb +11 -11
  31. data/lib/playwright/keyboard_impl.rb +36 -0
  32. data/lib/playwright/mouse_impl.rb +7 -0
  33. data/lib/playwright/playwright_api.rb +84 -29
  34. data/lib/playwright/select_option_values.rb +32 -0
  35. data/lib/playwright/timeout_settings.rb +2 -2
  36. data/lib/playwright/touchscreen_impl.rb +7 -0
  37. data/lib/playwright/url_matcher.rb +19 -0
  38. data/lib/playwright/utils.rb +18 -0
  39. data/lib/playwright/version.rb +1 -1
  40. data/lib/playwright/wait_helper.rb +1 -1
  41. data/lib/playwright_api/accessibility.rb +46 -6
  42. data/lib/playwright_api/android.rb +37 -0
  43. data/lib/playwright_api/android_device.rb +82 -0
  44. data/lib/playwright_api/android_input.rb +25 -0
  45. data/lib/playwright_api/binding_call.rb +10 -6
  46. data/lib/playwright_api/browser.rb +85 -18
  47. data/lib/playwright_api/browser_context.rb +269 -37
  48. data/lib/playwright_api/browser_type.rb +60 -11
  49. data/lib/playwright_api/cdp_session.rb +23 -1
  50. data/lib/playwright_api/chromium_browser_context.rb +18 -6
  51. data/lib/playwright_api/console_message.rb +14 -15
  52. data/lib/playwright_api/dialog.rb +48 -2
  53. data/lib/playwright_api/download.rb +47 -10
  54. data/lib/playwright_api/element_handle.rb +269 -110
  55. data/lib/playwright_api/file_chooser.rb +23 -7
  56. data/lib/playwright_api/frame.rb +439 -154
  57. data/lib/playwright_api/js_handle.rb +69 -24
  58. data/lib/playwright_api/keyboard.rb +99 -9
  59. data/lib/playwright_api/mouse.rb +22 -0
  60. data/lib/playwright_api/page.rb +856 -229
  61. data/lib/playwright_api/playwright.rb +108 -20
  62. data/lib/playwright_api/request.rb +77 -29
  63. data/lib/playwright_api/response.rb +10 -13
  64. data/lib/playwright_api/route.rb +49 -0
  65. data/lib/playwright_api/selectors.rb +20 -8
  66. data/lib/playwright_api/video.rb +8 -0
  67. data/lib/playwright_api/web_socket.rb +0 -8
  68. data/lib/playwright_api/worker.rb +25 -13
  69. data/playwright.gemspec +1 -0
  70. metadata +33 -2
@@ -10,9 +10,9 @@ module Playwright
10
10
  @browser_context = @parent
11
11
  @timeout_settings = TimeoutSettings.new(@browser_context.send(:_timeout_settings))
12
12
  @accessibility = Accessibility.new(@channel)
13
- @keyboard = Keyboard.new(@channel)
14
- @mouse = Mouse.new(@channel)
15
- @touchscreen = Touchscreen.new(@channel)
13
+ @keyboard = KeyboardImpl.new(@channel)
14
+ @mouse = MouseImpl.new(@channel)
15
+ @touchscreen = TouchscreenImpl.new(@channel)
16
16
 
17
17
  @viewport_size = @initializer['viewportSize']
18
18
  @closed = false
@@ -26,7 +26,19 @@ module Playwright
26
26
  console_message = ChannelOwners::ConsoleMessage.from(params['message'])
27
27
  emit(Events::Page::Console, console_message)
28
28
  })
29
+ @channel.on('crash', ->(_) { emit(Events::Page::Crash) })
30
+ @channel.on('dialog', method(:on_dialog))
29
31
  @channel.on('domcontentloaded', ->(_) { emit(Events::Page::DOMContentLoaded) })
32
+ @channel.on('download', ->(params) {
33
+ emit(Events::Page::Download, ChannelOwners::Download.from(params['download']))
34
+ })
35
+ @channel.on('fileChooser', ->(params) {
36
+ chooser = FileChooserImpl.new(
37
+ page: self,
38
+ element_handle: ChannelOwners::ElementHandle.from(params['element']),
39
+ is_multiple: params['isMultiple'])
40
+ emit(Events::Page::FileChooser, chooser)
41
+ })
30
42
  @channel.on('frameAttached', ->(params) {
31
43
  on_frame_attached(ChannelOwners::Frame.from(params['frame']))
32
44
  })
@@ -34,9 +46,43 @@ module Playwright
34
46
  on_frame_detached(ChannelOwners::Frame.from(params['frame']))
35
47
  })
36
48
  @channel.on('load', ->(_) { emit(Events::Page::Load) })
49
+ @channel.on('pageError', ->(params) {
50
+ emit(Events::Page::PageError, Error.parse(params['error']['error']))
51
+ })
37
52
  @channel.on('popup', ->(params) {
38
53
  emit(Events::Page::Popup, ChannelOwners::Page.from(params['page']))
39
54
  })
55
+ @channel.on('request', ->(params) {
56
+ emit(Events::Page::Request, ChannelOwners::Request.from(params['request']))
57
+ })
58
+ @channel.on('requestFailed', ->(params) {
59
+ on_request_failed(
60
+ ChannelOwners::Request.from(params['request']),
61
+ params['responseEndTiming'],
62
+ params['failureText'],
63
+ )
64
+ })
65
+ @channel.on('requestFinished', ->(params) {
66
+ on_request_finished(
67
+ ChannelOwners::Request.from(params['request']),
68
+ params['responseEndTiming'],
69
+ )
70
+ })
71
+ @channel.on('response', ->(params) {
72
+ emit(Events::Page::Response, ChannelOwners::Response.from(params['response']))
73
+ })
74
+ @channel.on('route', ->(params) {
75
+ on_route(ChannelOwners::Route.from(params['route']), ChannelOwners::Request.from(params['request']))
76
+ })
77
+ @channel.on('video', ->(params) {
78
+ video.send(:update_relative_path, params['relativePath'])
79
+ })
80
+ @channel.on('webSocket', ->(params) {
81
+ emit(Events::Page::WebSocket, ChannelOwners::WebSocket.from(params['webSocket']))
82
+ })
83
+ @channel.on('worker', ->(params) {
84
+ on_worker(ChannelOwners::Worker.from(params['worker']))
85
+ })
40
86
  end
41
87
 
42
88
  attr_reader \
@@ -47,6 +93,17 @@ module Playwright
47
93
  :viewport_size,
48
94
  :main_frame
49
95
 
96
+ private def on_request_failed(request, response_end_timing, failure_text)
97
+ request.send(:update_failure_text, failure_text)
98
+ request.send(:update_response_end_timing, response_end_timing)
99
+ emit(Events::Page::RequestFailed)
100
+ end
101
+
102
+ private def on_request_finished(request, response_end_timing)
103
+ request.send(:update_response_end_timing, response_end_timing)
104
+ emit(Events::Page::RequestFinished)
105
+ end
106
+
50
107
  private def on_frame_attached(frame)
51
108
  frame.send(:update_page_from_page, self)
52
109
  @frames << frame
@@ -59,12 +116,48 @@ module Playwright
59
116
  emit(Events::Page::FrameDetached, frame)
60
117
  end
61
118
 
119
+ private def on_route(route, request)
120
+ # @routes.each ...
121
+ @browser_context.send(:on_route, route, request)
122
+ end
123
+
62
124
  private def on_close
63
125
  @closed = true
64
126
  @browser_context.send(:remove_page, self)
65
127
  emit(Events::Page::Close)
66
128
  end
67
129
 
130
+ private def on_dialog(params)
131
+ dialog = ChannelOwners::Dialog.from(params['dialog'])
132
+ unless emit(Events::Page::Dialog, dialog)
133
+ dialog.dismiss # FIXME: this should be asynchronous
134
+ end
135
+ end
136
+
137
+ # @override
138
+ def on(event, callback)
139
+ if event == Events::Page::FileChooser && listener_count(event) == 0
140
+ @channel.send_no_reply('setFileChooserInterceptedNoReply', intercepted: true)
141
+ end
142
+ super
143
+ end
144
+
145
+ # @override
146
+ def once(event, callback)
147
+ if event == Events::Page::FileChooser && listener_count(event) == 0
148
+ @channel.send_no_reply('setFileChooserInterceptedNoReply', intercepted: true)
149
+ end
150
+ super
151
+ end
152
+
153
+ # @override
154
+ def off(event, callback)
155
+ super
156
+ if event == Events::Page::FileChooser && listener_count(event) == 0
157
+ @channel.send_no_reply('setFileChooserInterceptedNoReply', intercepted: false)
158
+ end
159
+ end
160
+
68
161
  def context
69
162
  @browser_context
70
163
  end
@@ -103,6 +196,56 @@ module Playwright
103
196
  @frames.to_a
104
197
  end
105
198
 
199
+ def set_default_navigation_timeout(timeout)
200
+ @timeout_settings.default_navigation_timeout = timeout
201
+ @channel.send_message_to_server('setDefaultNavigationTimeoutNoReply', timeout: timeout)
202
+ end
203
+
204
+ def set_default_timeout(timeout)
205
+ @timeout_settings.default_timeout = timeout
206
+ @channel.send_message_to_server('setDefaultTimeoutNoReply', timeout: timeout)
207
+ end
208
+
209
+ def query_selector(selector)
210
+ @main_frame.query_selector(selector)
211
+ end
212
+
213
+ def query_selector_all(selector)
214
+ @main_frame.query_selector_all(selector)
215
+ end
216
+
217
+ def wait_for_selector(selector, state: nil, timeout: nil)
218
+ @main_frame.wait_for_selector(selector, state: state, timeout: timeout)
219
+ end
220
+
221
+ def checked?(selector, timeout: nil)
222
+ @main_frame.checked?(selector, timeout: timeout)
223
+ end
224
+
225
+ def disabled?(selector, timeout: nil)
226
+ @main_frame.disabled?(selector, timeout: timeout)
227
+ end
228
+
229
+ def editable?(selector, timeout: nil)
230
+ @main_frame.editable?(selector, timeout: timeout)
231
+ end
232
+
233
+ def enabled?(selector, timeout: nil)
234
+ @main_frame.enabled?(selector, timeout: timeout)
235
+ end
236
+
237
+ def hidden?(selector, timeout: nil)
238
+ @main_frame.hidden?(selector, timeout: timeout)
239
+ end
240
+
241
+ def visible?(selector, timeout: nil)
242
+ @main_frame.visible?(selector, timeout: timeout)
243
+ end
244
+
245
+ def dispatch_event(selector, type, eventInit: nil, timeout: nil)
246
+ @main_frame.dispatch_event(selector, type, eventInit: eventInit, timeout: timeout)
247
+ end
248
+
106
249
  def evaluate(pageFunction, arg: nil)
107
250
  @main_frame.evaluate(pageFunction, arg: arg)
108
251
  end
@@ -111,6 +254,41 @@ module Playwright
111
254
  @main_frame.evaluate_handle(pageFunction, arg: arg)
112
255
  end
113
256
 
257
+ def eval_on_selector(selector, pageFunction, arg: nil)
258
+ @main_frame.eval_on_selector(selector, pageFunction, arg: arg)
259
+ end
260
+
261
+ def eval_on_selector_all(selector, pageFunction, arg: nil)
262
+ @main_frame.eval_on_selector_all(selector, pageFunction, arg: arg)
263
+ end
264
+
265
+ def add_script_tag(content: nil, path: nil, type: nil, url: nil)
266
+ @main_frame.add_script_tag(content: content, path: path, type: type, url: url)
267
+ end
268
+
269
+ def add_style_tag(content: nil, path: nil, url: nil)
270
+ @main_frame.add_style_tag(content: content, path: path, url: url)
271
+ end
272
+
273
+ def expose_function(name, callback)
274
+ @channel.send_message_to_server('exposeBinding', name: name)
275
+ @bindings[name] = ->(_source, *args) { callback.call(*args) }
276
+ end
277
+
278
+ def expose_binding(name, callback, handle: nil)
279
+ params = {
280
+ name: name,
281
+ needsHandle: handle,
282
+ }.compact
283
+ @channel.send_message_to_server('exposeBinding', params)
284
+ @bindings[name] = callback
285
+ end
286
+
287
+ def set_extra_http_headers(headers)
288
+ serialized_headers = HttpHeaders.new(headers).as_serialized
289
+ @channel.send_message_to_server('setExtraHTTPHeaders', headers: serialized_headers)
290
+ end
291
+
114
292
  def url
115
293
  @main_frame.url
116
294
  end
@@ -127,12 +305,58 @@ module Playwright
127
305
  @main_frame.goto(url, timeout: timeout, waitUntil: waitUntil, referer: referer)
128
306
  end
129
307
 
308
+ def reload(timeout: nil, waitUntil: nil)
309
+ params = {
310
+ timeout: timeout,
311
+ waitUntil: waitUntil,
312
+ }.compact
313
+ resp = @channel.send_message_to_server('reoad', params)
314
+ ChannelOwners::Response.from_nullable(resp)
315
+ end
316
+
317
+ def wait_for_load_state(state: nil, timeout: nil)
318
+ @main_frame.wait_for_load_state(state: state, timeout: timeout)
319
+ end
320
+
321
+ def go_back(timeout: nil, waitUntil: nil)
322
+ params = { timeout: timeout, waitUntil: waitUntil }.compact
323
+ resp = @channel.send_message_to_server('goBack', params)
324
+ ChannelOwners::Response.from_nullable(resp)
325
+ end
326
+
327
+ def go_forward(timeout: nil, waitUntil: nil)
328
+ params = { timeout: timeout, waitUntil: waitUntil }.compact
329
+ resp = @channel.send_message_to_server('goForward', params)
330
+ ChannelOwners::Response.from_nullable(resp)
331
+ end
332
+
333
+ def emulate_media(colorScheme: nil, media: nil)
334
+ params = {
335
+ colorScheme: colorScheme,
336
+ media: media,
337
+ }.compact
338
+ @channel.send_message_to_server('emulateMedia', params)
339
+
340
+ nil
341
+ end
342
+
130
343
  def set_viewport_size(viewportSize)
131
344
  @viewport_size = viewportSize
132
345
  @channel.send_message_to_server('setViewportSize', { viewportSize: viewportSize })
133
346
  nil
134
347
  end
135
348
 
349
+ def bring_to_front
350
+ @channel.send_message_to_server('bringToFront')
351
+ nil
352
+ end
353
+
354
+ def add_init_script(script, arg: nil)
355
+ @channel.send_message_to_server('addInitScript', source: script)
356
+ # FIXME: handling `arg` for function `script`
357
+ nil
358
+ end
359
+
136
360
  def screenshot(
137
361
  path: nil,
138
362
  type: nil,
@@ -151,7 +375,7 @@ module Playwright
151
375
  timeout: timeout,
152
376
  }.compact
153
377
  encoded_binary = @channel.send_message_to_server('screenshot', params)
154
- decoded_binary = Base64.decode64(encoded_binary)
378
+ decoded_binary = Base64.strict_decode64(encoded_binary)
155
379
  if path
156
380
  File.open(path, 'wb') do |f|
157
381
  f.write(decoded_binary)
@@ -177,18 +401,123 @@ module Playwright
177
401
  @closed
178
402
  end
179
403
 
404
+ def click(
405
+ selector,
406
+ button: nil,
407
+ clickCount: nil,
408
+ delay: nil,
409
+ force: nil,
410
+ modifiers: nil,
411
+ noWaitAfter: nil,
412
+ position: nil,
413
+ timeout: nil)
414
+
415
+ @main_frame.click(
416
+ selector,
417
+ button: button,
418
+ clickCount: clickCount,
419
+ delay: delay,
420
+ force: force,
421
+ modifiers: modifiers,
422
+ noWaitAfter: noWaitAfter,
423
+ position: position,
424
+ timeout: timeout,
425
+ )
426
+ end
427
+
428
+ def dblclick(
429
+ selector,
430
+ button: nil,
431
+ delay: nil,
432
+ force: nil,
433
+ modifiers: nil,
434
+ noWaitAfter: nil,
435
+ position: nil,
436
+ timeout: nil)
437
+ @main_frame.dblclick(
438
+ selector,
439
+ button: button,
440
+ delay: delay,
441
+ force: force,
442
+ modifiers: modifiers,
443
+ noWaitAfter: noWaitAfter,
444
+ position: position,
445
+ timeout: timeout,
446
+ )
447
+ end
448
+
449
+ def tap_point(
450
+ selector,
451
+ force: nil,
452
+ modifiers: nil,
453
+ noWaitAfter: nil,
454
+ position: nil,
455
+ timeout: nil)
456
+ @main_frame.tap_point(
457
+ selector,
458
+ force: force,
459
+ modifiers: modifiers,
460
+ noWaitAfter: noWaitAfter,
461
+ position: position,
462
+ timeout: timeout,
463
+ )
464
+ end
465
+
466
+ def fill(selector, value, noWaitAfter: nil, timeout: nil)
467
+ @main_frame.fill(selector, value, noWaitAfter: noWaitAfter, timeout: timeout)
468
+ end
469
+
180
470
  def focus(selector, timeout: nil)
181
471
  @main_frame.focus(selector, timeout: timeout)
182
472
  end
183
473
 
184
- def type_text(
474
+ def text_content(selector, timeout: nil)
475
+ @main_frame.text_content(selector, timeout: timeout)
476
+ end
477
+
478
+ def inner_text(selector, timeout: nil)
479
+ @main_frame.inner_text(selector, timeout: timeout)
480
+ end
481
+
482
+ def inner_html(selector, timeout: nil)
483
+ @main_frame.inner_html(selector, timeout: timeout)
484
+ end
485
+
486
+ def get_attribute(selector, name, timeout: nil)
487
+ @main_frame.get_attribute(selector, name, timeout: timeout)
488
+ end
489
+
490
+ def hover(
491
+ selector,
492
+ force: nil,
493
+ modifiers: nil,
494
+ position: nil,
495
+ timeout: nil)
496
+ @main_frame.hover(
497
+ selector,
498
+ force: force,
499
+ modifiers: modifiers,
500
+ position: position,
501
+ timeout: timeout,
502
+ )
503
+ end
504
+
505
+ def select_option(selector, values, noWaitAfter: nil, timeout: nil)
506
+ @main_frame.select_option(selector, values, noWaitAfter: noWaitAfter, timeout: timeout)
507
+ end
508
+
509
+ def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
510
+ @main_frame.set_input_files(selector, files, noWaitAfter: noWaitAfter, timeout: timeout)
511
+ end
512
+
513
+ def type(
185
514
  selector,
186
515
  text,
187
516
  delay: nil,
188
517
  noWaitAfter: nil,
189
518
  timeout: nil)
190
519
 
191
- @main_frame.type_text(selector, text, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout)
520
+ @main_frame.type(selector, text, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout)
192
521
  end
193
522
 
194
523
  def press(
@@ -201,6 +530,57 @@ module Playwright
201
530
  @main_frame.press(selector, key, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout)
202
531
  end
203
532
 
533
+ def check(selector, force: nil, noWaitAfter: nil, timeout: nil)
534
+ @main_frame.check(selector, force: force, noWaitAfter: noWaitAfter, timeout: timeout)
535
+ end
536
+
537
+ def uncheck(selector, force: nil, noWaitAfter: nil, timeout: nil)
538
+ @main_frame.uncheck(selector, force: force, noWaitAfter: noWaitAfter, timeout: timeout)
539
+ end
540
+
541
+ def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
542
+ @main_frame.wait_for_function(pageFunction, arg: arg, polling: polling, timeout: timeout)
543
+ end
544
+
545
+ def pdf(
546
+ displayHeaderFooter: nil,
547
+ footerTemplate: nil,
548
+ format: nil,
549
+ headerTemplate: nil,
550
+ height: nil,
551
+ landscape: nil,
552
+ margin: nil,
553
+ pageRanges: nil,
554
+ path: nil,
555
+ preferCSSPageSize: nil,
556
+ printBackground: nil,
557
+ scale: nil,
558
+ width: nil)
559
+
560
+ params = {
561
+ displayHeaderFooter: displayHeaderFooter,
562
+ footerTemplate: footerTemplate,
563
+ format: format,
564
+ headerTemplate: headerTemplate,
565
+ height: height,
566
+ landscape: landscape,
567
+ margin: margin,
568
+ pageRanges: pageRanges,
569
+ preferCSSPageSize: preferCSSPageSize,
570
+ printBackground: printBackground,
571
+ scale: scale,
572
+ width: width,
573
+ }.compact
574
+ encoded_binary = @channel.send_message_to_server('pdf', params)
575
+ decoded_binary = Base64.strict_decode64(encoded_binary)
576
+ if path
577
+ File.open(path, 'wb') do |f|
578
+ f.write(decoded_binary)
579
+ end
580
+ end
581
+ decoded_binary
582
+ end
583
+
204
584
  class CrashedError < StandardError
205
585
  def initialize
206
586
  super('Page crashed')
@@ -213,7 +593,13 @@ module Playwright
213
593
  end
214
594
  end
215
595
 
216
- def wait_for_event(event, optionsOrPredicate: nil, &block)
596
+ class FrameAlreadyDetachedError < StandardError
597
+ def initialize
598
+ super('Navigating frame was detached!')
599
+ end
600
+ end
601
+
602
+ def expect_event(event, optionsOrPredicate: nil, &block)
217
603
  predicate, timeout =
218
604
  case optionsOrPredicate
219
605
  when Proc
@@ -243,36 +629,42 @@ module Playwright
243
629
  wait_helper.promise.value!
244
630
  end
245
631
 
246
- def wait_for_request(urlOrPredicate, timeout: nil)
632
+ def expect_navigation(timeout: nil, url: nil, waitUntil: nil, &block)
633
+ @main_frame.expect_navigation(
634
+ timeout: timeout,
635
+ url: url,
636
+ waitUntil: waitUntil,
637
+ &block)
638
+ end
639
+
640
+ def expect_request(urlOrPredicate, timeout: nil)
247
641
  predicate =
248
642
  case urlOrPredicate
249
- when String
250
- -> (req){ req.url == urlOrPredicate }
251
- when Regexp
252
- -> (req){ urlOrPredicate.match?(req.url) }
643
+ when String, Regexp
644
+ url_matcher = UrlMatcher.new(urlOrPredicate)
645
+ -> (req){ url_matcher.match?(req.url) }
253
646
  when Proc
254
647
  urlOrPredicate
255
648
  else
256
649
  -> (_) { true }
257
650
  end
258
651
 
259
- wait_for_event(Events::Page::Request, optionsOrPredicate: { predicate: predicate, timeout: timeout})
652
+ expect_event(Events::Page::Request, optionsOrPredicate: { predicate: predicate, timeout: timeout})
260
653
  end
261
654
 
262
- def wait_for_response(urlOrPredicate, timeout: nil)
655
+ def expect_response(urlOrPredicate, timeout: nil)
263
656
  predicate =
264
657
  case urlOrPredicate
265
- when String
266
- -> (res){ res.url == urlOrPredicate }
267
- when Regexp
268
- -> (res){ urlOrPredicate.match?(res.url) }
658
+ when String, Regexp
659
+ url_matcher = UrlMatcher.new(urlOrPredicate)
660
+ -> (req){ url_matcher.match?(req.url) }
269
661
  when Proc
270
662
  urlOrPredicate
271
663
  else
272
664
  -> (_) { true }
273
665
  end
274
666
 
275
- wait_for_event(Events::Page::Response, optionsOrPredicate: { predicate: predicate, timeout: timeout})
667
+ expect_event(Events::Page::Response, optionsOrPredicate: { predicate: predicate, timeout: timeout})
276
668
  end
277
669
 
278
670
  # called from BrowserContext#on_page with send(:update_browser_context, page), so keep private.
@@ -280,5 +672,10 @@ module Playwright
280
672
  @browser_context = context
281
673
  @timeout_settings = TimeoutSettings.new(context.send(:_timeout_settings))
282
674
  end
675
+
676
+ # called from Frame with send(:timeout_settings)
677
+ private def timeout_settings
678
+ @timeout_settings
679
+ end
283
680
  end
284
681
  end