playwright-ruby-client 0.9.0 → 1.14.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c0e5286a6e8faaa590ce17ed083f4e6f93c54fb6899571c5edc2a99c4148b15
4
- data.tar.gz: bccd47264ec992c5c901c94faf28ec346a606d75e4636ae80828e5d64a685bf0
3
+ metadata.gz: 301191e26a4aa496f59d5feb5bed3c8438d5de5dfaa3e769dea1dae12dfe091c
4
+ data.tar.gz: 19fb694b3528977da5f934eff87432fff83a89072de874531fae3ab489f30e41
5
5
  SHA512:
6
- metadata.gz: c34792ec1bb838c99b5a540833c7e02c718147738d2b6129eb9ba63f53e6d6d1460e5abc62f9e94fecec2bc9dd07321c9badc1c4e4173ae0548151ebcbc38e12
7
- data.tar.gz: 12b99906a534b8ec3a5eef041824ec4d0357fe70e3a1c696dc4f11a95c1b54edbe8c7a5d67694c7b9dc846bd34fa6e18fbb3d84f241aa345a1d89c8af4ac4a39
6
+ metadata.gz: b0c3f28732256000b39c835cc6d38cd1f942c6e9defaa6e1aaf2f4269ba3e121422c0feebb76653ec323b64420bc24418b73ca1fc1fa98a7188e257f6e0ab359
7
+ data.tar.gz: 1c7ba51eef58fe196bee1411fd9b3da95f3f1a66cf150ce69a614e51511aad081fb7a18b8befdcc9ce2f7ebacae82e8ecb90f0a099b01530d3b7897f22c12142
@@ -4,4 +4,55 @@ sidebar_position: 10
4
4
 
5
5
  # Accessibility
6
6
 
7
- Not Implemented
7
+ The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is used by
8
+ assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or
9
+ [switches](https://en.wikipedia.org/wiki/Switch_access).
10
+
11
+ Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might
12
+ have wildly different output.
13
+
14
+ Rendering engines of Chromium, Firefox and WebKit have a concept of "accessibility tree", which is then translated into
15
+ different platform-specific APIs. Accessibility namespace gives access to this Accessibility Tree.
16
+
17
+ Most of the accessibility tree gets filtered out when converting from internal browser AX Tree to Platform-specific
18
+ AX-Tree or by assistive technologies themselves. By default, Playwright tries to approximate this filtering, exposing
19
+ only the "interesting" nodes of the tree.
20
+
21
+ ## snapshot
22
+
23
+ ```
24
+ def snapshot(interestingOnly: nil, root: nil)
25
+ ```
26
+
27
+ Captures the current state of the accessibility tree. The returned object represents the root accessible node of the
28
+ page.
29
+
30
+ > NOTE: The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers.
31
+ Playwright will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`.
32
+
33
+ An example of dumping the entire accessibility tree:
34
+
35
+ ```python sync title=example_2e5019929403491cde0c78bed1e0e18e0c86ab423d7ac8715876c4de4814f483.py
36
+ snapshot = page.accessibility.snapshot()
37
+ print(snapshot)
38
+
39
+ ```
40
+
41
+ An example of logging the focused node's name:
42
+
43
+ ```python sync title=example_df2acadf9e261a7624d83399f0d8b0910293a6a7081c812474715f22f8af7a4a.py
44
+ def find_focused_node(node):
45
+ if (node.get("focused"))
46
+ return node
47
+ for child in (node.get("children") or []):
48
+ found_node = find_focused_node(child)
49
+ return found_node
50
+ return None
51
+
52
+ snapshot = page.accessibility.snapshot()
53
+ node = find_focused_node(snapshot)
54
+ if node:
55
+ print(node["name"])
56
+
57
+ ```
58
+
@@ -67,6 +67,16 @@ browser_context.add_init_script(path: "preload.js")
67
67
  > NOTE: The order of evaluation of multiple scripts installed via [BrowserContext#add_init_script](./browser_context#add_init_script) and
68
68
  [Page#add_init_script](./page#add_init_script) is not defined.
69
69
 
70
+ ## background_pages
71
+
72
+ ```
73
+ def background_pages
74
+ ```
75
+
76
+ > NOTE: Background pages are only supported on Chromium-based browsers.
77
+
78
+ All existing background pages in the context.
79
+
70
80
  ## browser
71
81
 
72
82
  ```
@@ -301,6 +311,16 @@ To remove a route with its handler you can use [BrowserContext#unroute](./browse
301
311
 
302
312
  > NOTE: Enabling routing disables http cache.
303
313
 
314
+ ## service_workers
315
+
316
+ ```
317
+ def service_workers
318
+ ```
319
+
320
+ > NOTE: Service workers are only supported on Chromium-based browsers.
321
+
322
+ All existing service workers in the context.
323
+
304
324
  ## set_default_navigation_timeout
305
325
 
306
326
  ```
@@ -369,6 +389,14 @@ alias: `offline=`
369
389
 
370
390
 
371
391
 
392
+ ## storage_state
393
+
394
+ ```
395
+ def storage_state(path: nil)
396
+ ```
397
+
398
+ Returns storage state for this browser context, contains current cookies and local storage snapshot.
399
+
372
400
  ## unroute
373
401
 
374
402
  ```
@@ -910,6 +910,17 @@ with sync_playwright() as playwright:
910
910
 
911
911
 
912
912
 
913
+ ## wait_for_timeout
914
+
915
+ ```
916
+ def wait_for_timeout(timeout)
917
+ ```
918
+
919
+ Waits for the given `timeout` in milliseconds.
920
+
921
+ Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to
922
+ be flaky. Use signals such as network events, selectors becoming visible and others instead.
923
+
913
924
  ## wait_for_url
914
925
 
915
926
  ```
@@ -1466,6 +1466,23 @@ end
1466
1466
 
1467
1467
 
1468
1468
 
1469
+ ## wait_for_timeout
1470
+
1471
+ ```
1472
+ def wait_for_timeout(timeout)
1473
+ ```
1474
+
1475
+ Waits for the given `timeout` in milliseconds.
1476
+
1477
+ Note that `page.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be
1478
+ flaky. Use signals such as network events, selectors becoming visible and others instead.
1479
+
1480
+ ```ruby
1481
+ page.wait_for_timeout(1000)
1482
+ ```
1483
+
1484
+ Shortcut for main frame's [Frame#wait_for_timeout](./frame#wait_for_timeout).
1485
+
1469
1486
  ## wait_for_url
1470
1487
 
1471
1488
  ```
@@ -1489,6 +1506,27 @@ def expect_websocket(predicate: nil, timeout: nil, &block)
1489
1506
 
1490
1507
  Performs action and waits for a new [WebSocket](./web_socket). If predicate is provided, it passes [WebSocket](./web_socket) value into the `predicate` function and waits for `predicate.call(web_socket)` to return a truthy value. Will throw an error if the page is closed before the WebSocket event is fired.
1491
1508
 
1509
+ ## expect_worker
1510
+
1511
+ ```
1512
+ def expect_worker(predicate: nil, timeout: nil, &block)
1513
+ ```
1514
+
1515
+ Performs action and waits for a new [Worker](./worker). If predicate is provided, it passes [Worker](./worker) value into the `predicate`
1516
+ function and waits for `predicate(worker)` to return a truthy value. Will throw an error if the page is closed before
1517
+ the worker event is fired.
1518
+
1519
+ ## workers
1520
+
1521
+ ```
1522
+ def workers
1523
+ ```
1524
+
1525
+ This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
1526
+ associated with the page.
1527
+
1528
+ > NOTE: This does not contain ServiceWorkers
1529
+
1492
1530
  ## accessibility
1493
1531
 
1494
1532
  ## keyboard
@@ -6,3 +6,11 @@ sidebar_position: 10
6
6
 
7
7
  The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the
8
8
  touchscreen can only be used in browser contexts that have been initialized with `hasTouch` set to true.
9
+
10
+ ## tap_point
11
+
12
+ ```
13
+ def tap_point(x, y)
14
+ ```
15
+
16
+ Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`).
@@ -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
+
@@ -65,7 +65,7 @@
65
65
 
66
66
  ## Touchscreen
67
67
 
68
- * ~~tap_point~~
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
- ## ~~Accessibility~~
119
+ ## Accessibility
120
120
 
121
- * ~~snapshot~~
121
+ * snapshot
122
122
 
123
123
  ## FileChooser
124
124
 
@@ -178,14 +178,14 @@
178
178
  * wait_for_load_state
179
179
  * expect_navigation
180
180
  * wait_for_selector
181
- * ~~wait_for_timeout~~
181
+ * wait_for_timeout
182
182
  * wait_for_url
183
183
 
184
184
  ## Worker
185
185
 
186
- * ~~evaluate~~
187
- * ~~evaluate_handle~~
188
- * ~~url~~
186
+ * evaluate
187
+ * evaluate_handle
188
+ * url
189
189
 
190
190
  ## Selectors
191
191
 
@@ -296,11 +296,11 @@
296
296
  * expect_request_finished
297
297
  * expect_response
298
298
  * wait_for_selector
299
- * ~~wait_for_timeout~~
299
+ * wait_for_timeout
300
300
  * wait_for_url
301
301
  * expect_websocket
302
- * ~~expect_worker~~
303
- * ~~workers~~
302
+ * expect_worker
303
+ * workers
304
304
  * ~~wait_for_event~~
305
305
  * accessibility
306
306
  * keyboard
@@ -311,7 +311,7 @@
311
311
 
312
312
  * add_cookies
313
313
  * add_init_script
314
- * ~~background_pages~~
314
+ * background_pages
315
315
  * browser
316
316
  * clear_cookies
317
317
  * clear_permissions
@@ -324,13 +324,13 @@
324
324
  * new_page
325
325
  * pages
326
326
  * route
327
- * ~~service_workers~~
327
+ * service_workers
328
328
  * set_default_navigation_timeout
329
329
  * set_default_timeout
330
330
  * set_extra_http_headers
331
331
  * set_geolocation
332
332
  * set_offline
333
- * ~~storage_state~~
333
+ * storage_state
334
334
  * unroute
335
335
  * expect_event
336
336
  * expect_page
@@ -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)
@@ -279,6 +306,16 @@ module Playwright
279
306
  @channel.send_message_to_server('pause')
280
307
  end
281
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
+
282
319
  def expect_page(predicate: nil, timeout: nil)
283
320
  params = {
284
321
  predicate: predicate,
@@ -292,6 +329,14 @@ module Playwright
292
329
  @pages.delete(page)
293
330
  end
294
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
+
295
340
  # called from Page with send(:_timeout_settings), so keep private.
296
341
  private def _timeout_settings
297
342
  @timeout_settings
@@ -579,6 +579,10 @@ module Playwright
579
579
  nil
580
580
  end
581
581
 
582
+ def wait_for_timeout(timeout)
583
+ sleep(timeout / 1000.0)
584
+ end
585
+
582
586
  def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
583
587
  if polling.is_a?(String) && polling != 'raf'
584
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 = 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,6 +21,7 @@ module Playwright
21
21
  }
22
22
  end
23
23
  @closed = false
24
+ @workers = Set.new
24
25
  @bindings = {}
25
26
  @routes = []
26
27
 
@@ -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
 
@@ -690,10 +698,18 @@ module Playwright
690
698
  trial: trial)
691
699
  end
692
700
 
701
+ def wait_for_timeout(timeout)
702
+ @main_frame.wait_for_timeout(timeout)
703
+ end
704
+
693
705
  def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
694
706
  @main_frame.wait_for_function(pageFunction, arg: arg, polling: polling, timeout: timeout)
695
707
  end
696
708
 
709
+ def workers
710
+ @workers.to_a
711
+ end
712
+
697
713
  def pause
698
714
  @browser_context.send(:pause)
699
715
  end
@@ -865,6 +881,10 @@ module Playwright
865
881
  expect_event(Events::Page::WebSocket, predicate: predicate, timeout: timeout, &block)
866
882
  end
867
883
 
884
+ def expect_worker(predicate: nil, timeout: nil, &block)
885
+ expect_event(Events::Page::Worker, predicate: predicate, timeout: timeout, &block)
886
+ end
887
+
868
888
  # called from Frame with send(:timeout_settings)
869
889
  private def timeout_settings
870
890
  @timeout_settings
@@ -875,6 +895,11 @@ module Playwright
875
895
  @bindings.key?(name)
876
896
  end
877
897
 
898
+ # called from Worker#on_close
899
+ private def remove_worker(worker)
900
+ @workers.delete(worker)
901
+ end
902
+
878
903
  # Expose guid for library developers.
879
904
  # Not intended to be used by users.
880
905
  def guid
@@ -1,4 +1,27 @@
1
1
  module Playwright
2
2
  define_channel_owner :Worker do
3
+ attr_writer :context, :page
4
+
5
+ private def after_initialize
6
+ @channel.once('close', ->(_) { on_close })
7
+ end
8
+
9
+ private def on_close
10
+ @page&.send(:remove_worker, self)
11
+ @context&.send(:remove_service_worker, self)
12
+ emit(Events::Worker::Close, self)
13
+ end
14
+
15
+ def url
16
+ @initializer['url']
17
+ end
18
+
19
+ def evaluate(expression, arg: nil)
20
+ JavaScript::Expression.new(expression, arg).evaluate(@channel)
21
+ end
22
+
23
+ def evaluate_handle(expression, arg: nil)
24
+ JavaScript::Expression.new(expression, arg).evaluate_handle(@channel)
25
+ end
3
26
  end
4
27
  end
@@ -3,5 +3,12 @@ module Playwright
3
3
  def initialize(channel)
4
4
  @channel = channel
5
5
  end
6
+
7
+ def tap_point(x, y)
8
+ @channel.send_message_to_server('touchscreenTap', {
9
+ x: x,
10
+ y: y,
11
+ })
12
+ end
6
13
  end
7
14
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playwright
4
- VERSION = '0.9.0'
4
+ VERSION = '1.14.beta1'
5
5
  COMPATIBLE_PLAYWRIGHT_VERSION = '1.14.0'
6
6
  end
@@ -44,7 +44,7 @@ module Playwright
44
44
  # print(node["name"])
45
45
  # ```
46
46
  def snapshot(interestingOnly: nil, root: nil)
47
- raise NotImplementedError.new('snapshot is not implemented yet.')
47
+ wrap_impl(@impl.snapshot(interestingOnly: unwrap_impl(interestingOnly), root: unwrap_impl(root)))
48
48
  end
49
49
  end
50
50
  end
@@ -59,7 +59,7 @@ module Playwright
59
59
  #
60
60
  # All existing background pages in the context.
61
61
  def background_pages
62
- raise NotImplementedError.new('background_pages is not implemented yet.')
62
+ wrap_impl(@impl.background_pages)
63
63
  end
64
64
 
65
65
  # Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
@@ -268,7 +268,7 @@ module Playwright
268
268
  #
269
269
  # All existing service workers in the context.
270
270
  def service_workers
271
- raise NotImplementedError.new('service_workers is not implemented yet.')
271
+ wrap_impl(@impl.service_workers)
272
272
  end
273
273
 
274
274
  # This setting will change the default maximum navigation time for the following methods and related shortcuts:
@@ -325,7 +325,7 @@ module Playwright
325
325
 
326
326
  # Returns storage state for this browser context, contains current cookies and local storage snapshot.
327
327
  def storage_state(path: nil)
328
- raise NotImplementedError.new('storage_state is not implemented yet.')
328
+ wrap_impl(@impl.storage_state(path: unwrap_impl(path)))
329
329
  end
330
330
 
331
331
  # Removes a route created with [`method: BrowserContext.route`]. When `handler` is not specified, removes all routes for
@@ -367,11 +367,6 @@ module Playwright
367
367
  wrap_impl(@impl.enable_debug_console!)
368
368
  end
369
369
 
370
- # @nodoc
371
- def pause
372
- wrap_impl(@impl.pause)
373
- end
374
-
375
370
  # @nodoc
376
371
  def browser=(req)
377
372
  wrap_impl(@impl.browser=(unwrap_impl(req)))
@@ -382,6 +377,11 @@ module Playwright
382
377
  wrap_impl(@impl.owner_page=(unwrap_impl(req)))
383
378
  end
384
379
 
380
+ # @nodoc
381
+ def pause
382
+ wrap_impl(@impl.pause)
383
+ end
384
+
385
385
  # @nodoc
386
386
  def options=(req)
387
387
  wrap_impl(@impl.options=(unwrap_impl(req)))
@@ -720,7 +720,7 @@ module Playwright
720
720
  # Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to
721
721
  # be flaky. Use signals such as network events, selectors becoming visible and others instead.
722
722
  def wait_for_timeout(timeout)
723
- raise NotImplementedError.new('wait_for_timeout is not implemented yet.')
723
+ wrap_impl(@impl.wait_for_timeout(unwrap_impl(timeout)))
724
724
  end
725
725
 
726
726
  # Waits for the frame to navigate to the given URL.
@@ -1274,7 +1274,7 @@ module Playwright
1274
1274
  #
1275
1275
  # Shortcut for main frame's [`method: Frame.waitForTimeout`].
1276
1276
  def wait_for_timeout(timeout)
1277
- raise NotImplementedError.new('wait_for_timeout is not implemented yet.')
1277
+ wrap_impl(@impl.wait_for_timeout(unwrap_impl(timeout)))
1278
1278
  end
1279
1279
 
1280
1280
  # Waits for the main frame to navigate to the given URL.
@@ -1299,8 +1299,8 @@ module Playwright
1299
1299
  # Performs action and waits for a new `Worker`. If predicate is provided, it passes `Worker` value into the `predicate`
1300
1300
  # function and waits for `predicate(worker)` to return a truthy value. Will throw an error if the page is closed before
1301
1301
  # the worker event is fired.
1302
- def expect_worker(predicate: nil, timeout: nil)
1303
- raise NotImplementedError.new('expect_worker is not implemented yet.')
1302
+ def expect_worker(predicate: nil, timeout: nil, &block)
1303
+ wrap_impl(@impl.expect_worker(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
1304
1304
  end
1305
1305
 
1306
1306
  # This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
@@ -1308,7 +1308,7 @@ module Playwright
1308
1308
  #
1309
1309
  # > NOTE: This does not contain ServiceWorkers
1310
1310
  def workers
1311
- raise NotImplementedError.new('workers is not implemented yet.')
1311
+ wrap_impl(@impl.workers)
1312
1312
  end
1313
1313
 
1314
1314
  # > NOTE: In most cases, you should use [`method: Page.waitForEvent`].
@@ -5,7 +5,7 @@ module Playwright
5
5
 
6
6
  # Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`).
7
7
  def tap_point(x, y)
8
- raise NotImplementedError.new('tap_point is not implemented yet.')
8
+ wrap_impl(@impl.tap_point(unwrap_impl(x), unwrap_impl(y)))
9
9
  end
10
10
  end
11
11
  end
@@ -25,7 +25,7 @@ module Playwright
25
25
  # [`method: Worker.evaluate`] returns `undefined`. Playwright also supports transferring some additional values that are
26
26
  # not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
27
27
  def evaluate(expression, arg: nil)
28
- raise NotImplementedError.new('evaluate is not implemented yet.')
28
+ wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
29
29
  end
30
30
 
31
31
  # Returns the return value of `expression` as a `JSHandle`.
@@ -36,11 +36,21 @@ module Playwright
36
36
  # If the function passed to the [`method: Worker.evaluateHandle`] returns a [Promise], then
37
37
  # [`method: Worker.evaluateHandle`] would wait for the promise to resolve and return its value.
38
38
  def evaluate_handle(expression, arg: nil)
39
- raise NotImplementedError.new('evaluate_handle is not implemented yet.')
39
+ wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
40
40
  end
41
41
 
42
42
  def url
43
- raise NotImplementedError.new('url is not implemented yet.')
43
+ wrap_impl(@impl.url)
44
+ end
45
+
46
+ # @nodoc
47
+ def context=(req)
48
+ wrap_impl(@impl.context=(unwrap_impl(req)))
49
+ end
50
+
51
+ # @nodoc
52
+ def page=(req)
53
+ wrap_impl(@impl.page=(unwrap_impl(req)))
44
54
  end
45
55
 
46
56
  # -- inherited from EventEmitter --
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playwright-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.14.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-03 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -267,6 +267,7 @@ files:
267
267
  - documentation/static/img/undraw_windows.svg
268
268
  - documentation/yarn.lock
269
269
  - lib/playwright.rb
270
+ - lib/playwright/accessibility_impl.rb
270
271
  - lib/playwright/android_input_impl.rb
271
272
  - lib/playwright/api_implementation.rb
272
273
  - lib/playwright/channel.rb
@@ -370,9 +371,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
370
371
  version: '2.4'
371
372
  required_rubygems_version: !ruby/object:Gem::Requirement
372
373
  requirements:
373
- - - ">="
374
+ - - ">"
374
375
  - !ruby/object:Gem::Version
375
- version: '0'
376
+ version: 1.3.1
376
377
  requirements: []
377
378
  rubygems_version: 3.2.22
378
379
  signing_key: