playwright-ruby-client 0.5.10 → 0.6.4

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 (100) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/documentation/README.md +33 -0
  4. data/documentation/babel.config.js +3 -0
  5. data/documentation/docs/api/accessibility.md +7 -0
  6. data/documentation/docs/api/browser.md +188 -0
  7. data/documentation/docs/api/browser_context.md +397 -0
  8. data/documentation/docs/api/browser_type.md +105 -0
  9. data/documentation/docs/api/cdp_session.md +7 -0
  10. data/documentation/docs/api/console_message.md +41 -0
  11. data/documentation/docs/api/dialog.md +71 -0
  12. data/documentation/docs/api/element_handle.md +618 -0
  13. data/documentation/docs/api/experimental/_category_.yml +3 -0
  14. data/documentation/docs/api/experimental/android.md +26 -0
  15. data/documentation/docs/api/experimental/android_device.md +92 -0
  16. data/documentation/docs/api/experimental/android_input.md +38 -0
  17. data/documentation/docs/api/experimental/android_socket.md +7 -0
  18. data/documentation/docs/api/experimental/android_web_view.md +7 -0
  19. data/documentation/docs/api/file_chooser.md +50 -0
  20. data/documentation/docs/api/frame.md +866 -0
  21. data/documentation/docs/api/js_handle.md +113 -0
  22. data/documentation/docs/api/keyboard.md +157 -0
  23. data/documentation/docs/api/mouse.md +69 -0
  24. data/documentation/docs/api/page.md +1402 -0
  25. data/documentation/docs/api/playwright.md +63 -0
  26. data/documentation/docs/api/request.md +188 -0
  27. data/documentation/docs/api/response.md +97 -0
  28. data/documentation/docs/api/route.md +80 -0
  29. data/documentation/docs/api/selectors.md +23 -0
  30. data/documentation/docs/api/touchscreen.md +8 -0
  31. data/documentation/docs/api/tracing.md +47 -0
  32. data/documentation/docs/api/web_socket.md +7 -0
  33. data/documentation/docs/api/worker.md +24 -0
  34. data/documentation/docs/article/api_coverage.mdx +11 -0
  35. data/documentation/docs/article/getting_started.md +152 -0
  36. data/documentation/docs/article/guides/_category_.yml +3 -0
  37. data/documentation/docs/article/guides/download_playwright_driver.md +49 -0
  38. data/documentation/docs/article/guides/launch_browser.md +119 -0
  39. data/documentation/docs/article/guides/rails_integration.md +205 -0
  40. data/documentation/docs/article/guides/recording_video.md +79 -0
  41. data/{docs → documentation/docs/include}/api_coverage.md +11 -1
  42. data/documentation/docusaurus.config.js +107 -0
  43. data/documentation/package.json +39 -0
  44. data/documentation/sidebars.js +15 -0
  45. data/documentation/src/components/HomepageFeatures.js +61 -0
  46. data/documentation/src/components/HomepageFeatures.module.css +13 -0
  47. data/documentation/src/css/custom.css +44 -0
  48. data/documentation/src/pages/index.js +50 -0
  49. data/documentation/src/pages/index.module.css +41 -0
  50. data/documentation/src/pages/markdown-page.md +7 -0
  51. data/documentation/static/.nojekyll +0 -0
  52. data/documentation/static/img/playwright-logo.svg +9 -0
  53. data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
  54. data/documentation/static/img/undraw_web_development.svg +1 -0
  55. data/documentation/static/img/undraw_windows.svg +1 -0
  56. data/documentation/yarn.lock +8785 -0
  57. data/lib/playwright/channel_owners/binding_call.rb +33 -0
  58. data/lib/playwright/channel_owners/browser.rb +25 -12
  59. data/lib/playwright/channel_owners/browser_context.rb +67 -8
  60. data/lib/playwright/channel_owners/browser_type.rb +13 -9
  61. data/lib/playwright/channel_owners/element_handle.rb +17 -16
  62. data/lib/playwright/channel_owners/frame.rb +24 -34
  63. data/lib/playwright/channel_owners/js_handle.rb +2 -10
  64. data/lib/playwright/channel_owners/page.rb +37 -52
  65. data/lib/playwright/channel_owners/worker.rb +4 -0
  66. data/lib/playwright/download.rb +3 -2
  67. data/lib/playwright/events.rb +4 -0
  68. data/lib/playwright/input_files.rb +0 -8
  69. data/lib/playwright/javascript.rb +0 -10
  70. data/lib/playwright/javascript/expression.rb +2 -7
  71. data/lib/playwright/playwright_api.rb +16 -1
  72. data/lib/playwright/tracing_impl.rb +31 -0
  73. data/lib/playwright/version.rb +2 -2
  74. data/lib/playwright_api/accessibility.rb +7 -88
  75. data/lib/playwright_api/android.rb +11 -67
  76. data/lib/playwright_api/android_device.rb +10 -9
  77. data/lib/playwright_api/browser.rb +21 -129
  78. data/lib/playwright_api/browser_context.rb +70 -437
  79. data/lib/playwright_api/browser_type.rb +34 -84
  80. data/lib/playwright_api/cdp_session.rb +2 -25
  81. data/lib/playwright_api/console_message.rb +8 -6
  82. data/lib/playwright_api/dialog.rb +11 -69
  83. data/lib/playwright_api/element_handle.rb +102 -300
  84. data/lib/playwright_api/file_chooser.rb +0 -21
  85. data/lib/playwright_api/frame.rb +104 -570
  86. data/lib/playwright_api/js_handle.rb +16 -73
  87. data/lib/playwright_api/keyboard.rb +22 -166
  88. data/lib/playwright_api/mouse.rb +1 -45
  89. data/lib/playwright_api/page.rb +228 -1229
  90. data/lib/playwright_api/playwright.rb +16 -101
  91. data/lib/playwright_api/request.rb +15 -93
  92. data/lib/playwright_api/response.rb +7 -7
  93. data/lib/playwright_api/route.rb +9 -86
  94. data/lib/playwright_api/selectors.rb +6 -72
  95. data/lib/playwright_api/tracing.rb +33 -0
  96. data/lib/playwright_api/web_socket.rb +1 -1
  97. data/lib/playwright_api/worker.rb +28 -42
  98. data/playwright.gemspec +1 -1
  99. metadata +61 -20
  100. data/lib/playwright/javascript/function.rb +0 -67
@@ -4,73 +4,7 @@ module Playwright
4
4
  class Selectors < PlaywrightApi
5
5
 
6
6
  # An example of registering selector engine that queries elements based on a tag name:
7
- #
8
7
  #
9
- # ```js
10
- # const { selectors, firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
11
- #
12
- # (async () => {
13
- # // Must be a function that evaluates to a selector engine instance.
14
- # const createTagNameEngine = () => ({
15
- # // Returns the first element matching given selector in the root's subtree.
16
- # query(root, selector) {
17
- # return root.querySelector(selector);
18
- # },
19
- #
20
- # // Returns all elements matching given selector in the root's subtree.
21
- # queryAll(root, selector) {
22
- # return Array.from(root.querySelectorAll(selector));
23
- # }
24
- # });
25
- #
26
- # // Register the engine. Selectors will be prefixed with "tag=".
27
- # await selectors.register('tag', createTagNameEngine);
28
- #
29
- # const browser = await firefox.launch();
30
- # const page = await browser.newPage();
31
- # await page.setContent(`<div><button>Click me</button></div>`);
32
- #
33
- # // Use the selector prefixed with its name.
34
- # const button = await page.$('tag=button');
35
- # // Combine it with other selector engines.
36
- # await page.click('tag=div >> text="Click me"');
37
- # // Can use it in any methods supporting selectors.
38
- # const buttonCount = await page.$$eval('tag=button', buttons => buttons.length);
39
- #
40
- # await browser.close();
41
- # })();
42
- # ```
43
- #
44
- # ```java
45
- # // Script that evaluates to a selector engine instance.
46
- # String createTagNameEngine = "{\n" +
47
- # " // Returns the first element matching given selector in the root's subtree.\n" +
48
- # " query(root, selector) {\n" +
49
- # " return root.querySelector(selector);\n" +
50
- # " },\n" +
51
- # " // Returns all elements matching given selector in the root's subtree.\n" +
52
- # " queryAll(root, selector) {\n" +
53
- # " return Array.from(root.querySelectorAll(selector));\n" +
54
- # " }\n" +
55
- # "}";
56
- # // Register the engine. Selectors will be prefixed with "tag=".
57
- # playwright.selectors().register("tag", createTagNameEngine);
58
- # Browser browser = playwright.firefox().launch();
59
- # Page page = browser.newPage();
60
- # page.setContent("<div><button>Click me</button></div>");
61
- # // Use the selector prefixed with its name.
62
- # ElementHandle button = page.querySelector("tag=button");
63
- # // Combine it with other selector engines.
64
- # page.click("tag=div >> text=\"Click me\"");
65
- # // Can use it in any methods supporting selectors.
66
- # int buttonCount = (int) page.evalOnSelectorAll("tag=button", "buttons => buttons.length");
67
- # browser.close();
68
- # ```
69
- #
70
- # ```python async
71
- # # FIXME: add snippet
72
- # ```
73
- #
74
8
  # ```python sync
75
9
  # # FIXME: add snippet
76
10
  # ```
@@ -78,12 +12,6 @@ module Playwright
78
12
  wrap_impl(@impl.register(unwrap_impl(name), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path), script: unwrap_impl(script)))
79
13
  end
80
14
 
81
- # -- inherited from EventEmitter --
82
- # @nodoc
83
- def off(event, callback)
84
- event_emitter_proxy.off(event, callback)
85
- end
86
-
87
15
  # -- inherited from EventEmitter --
88
16
  # @nodoc
89
17
  def once(event, callback)
@@ -96,6 +24,12 @@ module Playwright
96
24
  event_emitter_proxy.on(event, callback)
97
25
  end
98
26
 
27
+ # -- inherited from EventEmitter --
28
+ # @nodoc
29
+ def off(event, callback)
30
+ event_emitter_proxy.off(event, callback)
31
+ end
32
+
99
33
  private def event_emitter_proxy
100
34
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
101
35
  end
@@ -0,0 +1,33 @@
1
+ module Playwright
2
+ # API for collecting and saving Playwright traces. Playwright traces can be opened using the Playwright CLI after
3
+ # Playwright script runs.
4
+ #
5
+ # Start with specifying the folder traces will be stored in:
6
+ #
7
+ # ```python sync
8
+ # browser = chromium.launch()
9
+ # context = browser.new_context()
10
+ # context.tracing.start(screenshots=True, snapshots=True)
11
+ # page.goto("https://playwright.dev")
12
+ # context.tracing.stop(path = "trace.zip")
13
+ # ```
14
+ class Tracing < PlaywrightApi
15
+
16
+ # Start tracing.
17
+ #
18
+ # ```python sync
19
+ # context.tracing.start(name="trace", screenshots=True, snapshots=True)
20
+ # page.goto("https://playwright.dev")
21
+ # context.tracing.stop()
22
+ # context.tracing.stop(path = "trace.zip")
23
+ # ```
24
+ def start(name: nil, screenshots: nil, snapshots: nil)
25
+ wrap_impl(@impl.start(name: unwrap_impl(name), screenshots: unwrap_impl(screenshots), snapshots: unwrap_impl(snapshots)))
26
+ end
27
+
28
+ # Stop tracing.
29
+ def stop(path: nil)
30
+ wrap_impl(@impl.stop(path: unwrap_impl(path)))
31
+ end
32
+ end
33
+ end
@@ -19,7 +19,7 @@ module Playwright
19
19
  end
20
20
 
21
21
  # > NOTE: In most cases, you should use [`method: WebSocket.waitForEvent`].
22
- #
22
+ #
23
23
  # Waits for given `event` to fire. If predicate is provided, it passes event's value into the `predicate` function and
24
24
  # waits for `predicate(event)` to return a truthy value. Will throw an error if the socket is closed before the `event` is
25
25
  # fired.
@@ -2,61 +2,25 @@ module Playwright
2
2
  # The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). `worker`
3
3
  # event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the
4
4
  # worker is gone.
5
- #
6
5
  #
7
- # ```js
8
- # page.on('worker', worker => {
9
- # console.log('Worker created: ' + worker.url());
10
- # worker.on('close', worker => console.log('Worker destroyed: ' + worker.url()));
11
- # });
12
- #
13
- # console.log('Current workers:');
14
- # for (const worker of page.workers())
15
- # console.log(' ' + worker.url());
16
- # ```
17
- #
18
- # ```java
19
- # page.onWorker(worker -> {
20
- # System.out.println("Worker created: " + worker.url());
21
- # worker.onClose(worker1 -> System.out.println("Worker destroyed: " + worker1.url()));
22
- # });
23
- # System.out.println("Current workers:");
24
- # for (Worker worker : page.workers())
25
- # System.out.println(" " + worker.url());
26
- # ```
27
- #
28
6
  # ```py
29
7
  # def handle_worker(worker):
30
8
  # print("worker created: " + worker.url)
31
9
  # worker.on("close", lambda: print("worker destroyed: " + worker.url))
32
- #
10
+ #
33
11
  # page.on('worker', handle_worker)
34
- #
12
+ #
35
13
  # print("current workers:")
36
14
  # for worker in page.workers:
37
15
  # print(" " + worker.url)
38
16
  # ```
39
- #
40
- # ```csharp
41
- # Page.Worker += (_, worker) =>
42
- # {
43
- # Console.WriteLine($"Worker created: {worker.Url}");
44
- # worker.Close += (_, _) => Console.WriteLine($"Worker closed {worker.Url}");
45
- # };
46
- #
47
- # Console.WriteLine("Current Workers:");
48
- # foreach(var pageWorker in Page.Workers)
49
- # {
50
- # Console.WriteLine($"\tWorker: {pageWorker.Url}");
51
- # }
52
- # ```
53
17
  class Worker < PlaywrightApi
54
18
 
55
19
  # Returns the return value of `expression`.
56
- #
20
+ #
57
21
  # If the function passed to the [`method: Worker.evaluate`] returns a [Promise], then [`method: Worker.evaluate`] would
58
22
  # wait for the promise to resolve and return its value.
59
- #
23
+ #
60
24
  # If the function passed to the [`method: Worker.evaluate`] returns a non-[Serializable] value, then
61
25
  # [`method: Worker.evaluate`] returns `undefined`. Playwright also supports transferring some additional values that are
62
26
  # not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
@@ -65,10 +29,10 @@ module Playwright
65
29
  end
66
30
 
67
31
  # Returns the return value of `expression` as a `JSHandle`.
68
- #
32
+ #
69
33
  # The only difference between [`method: Worker.evaluate`] and [`method: Worker.evaluateHandle`] is that
70
34
  # [`method: Worker.evaluateHandle`] returns `JSHandle`.
71
- #
35
+ #
72
36
  # If the function passed to the [`method: Worker.evaluateHandle`] returns a [Promise], then
73
37
  # [`method: Worker.evaluateHandle`] would wait for the promise to resolve and return its value.
74
38
  def evaluate_handle(expression, arg: nil)
@@ -78,5 +42,27 @@ module Playwright
78
42
  def url
79
43
  raise NotImplementedError.new('url is not implemented yet.')
80
44
  end
45
+
46
+ # -- inherited from EventEmitter --
47
+ # @nodoc
48
+ def once(event, callback)
49
+ event_emitter_proxy.once(event, callback)
50
+ end
51
+
52
+ # -- inherited from EventEmitter --
53
+ # @nodoc
54
+ def on(event, callback)
55
+ event_emitter_proxy.on(event, callback)
56
+ end
57
+
58
+ # -- inherited from EventEmitter --
59
+ # @nodoc
60
+ def off(event, callback)
61
+ event_emitter_proxy.off(event, callback)
62
+ end
63
+
64
+ private def event_emitter_proxy
65
+ @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
66
+ end
81
67
  end
82
68
  end
data/playwright.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
26
 
27
+ spec.required_ruby_version = '>= 2.4'
27
28
  spec.add_dependency 'concurrent-ruby', '>= 1.1.6'
28
29
  spec.add_dependency 'mime-types', '>= 3.0'
29
30
  spec.add_development_dependency 'bundler', '~> 2.2.3'
@@ -33,7 +34,6 @@ Gem::Specification.new do |spec|
33
34
  spec.add_development_dependency 'rake', '~> 13.0.3'
34
35
  spec.add_development_dependency 'rspec', '~> 3.10.0 '
35
36
  spec.add_development_dependency 'rspec_junit_formatter' # for CircleCI.
36
- spec.add_development_dependency 'rubocop', '~> 1.7.0'
37
37
  spec.add_development_dependency 'rubocop-rspec'
38
38
  spec.add_development_dependency 'sinatra'
39
39
  spec.add_development_dependency 'webrick'
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.5.10
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2021-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -136,20 +136,6 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 1.7.0
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 1.7.0
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: rubocop-rspec
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -207,7 +193,60 @@ files:
207
193
  - Rakefile
208
194
  - bin/console
209
195
  - bin/setup
210
- - docs/api_coverage.md
196
+ - documentation/README.md
197
+ - documentation/babel.config.js
198
+ - documentation/docs/api/accessibility.md
199
+ - documentation/docs/api/browser.md
200
+ - documentation/docs/api/browser_context.md
201
+ - documentation/docs/api/browser_type.md
202
+ - documentation/docs/api/cdp_session.md
203
+ - documentation/docs/api/console_message.md
204
+ - documentation/docs/api/dialog.md
205
+ - documentation/docs/api/element_handle.md
206
+ - documentation/docs/api/experimental/_category_.yml
207
+ - documentation/docs/api/experimental/android.md
208
+ - documentation/docs/api/experimental/android_device.md
209
+ - documentation/docs/api/experimental/android_input.md
210
+ - documentation/docs/api/experimental/android_socket.md
211
+ - documentation/docs/api/experimental/android_web_view.md
212
+ - documentation/docs/api/file_chooser.md
213
+ - documentation/docs/api/frame.md
214
+ - documentation/docs/api/js_handle.md
215
+ - documentation/docs/api/keyboard.md
216
+ - documentation/docs/api/mouse.md
217
+ - documentation/docs/api/page.md
218
+ - documentation/docs/api/playwright.md
219
+ - documentation/docs/api/request.md
220
+ - documentation/docs/api/response.md
221
+ - documentation/docs/api/route.md
222
+ - documentation/docs/api/selectors.md
223
+ - documentation/docs/api/touchscreen.md
224
+ - documentation/docs/api/tracing.md
225
+ - documentation/docs/api/web_socket.md
226
+ - documentation/docs/api/worker.md
227
+ - documentation/docs/article/api_coverage.mdx
228
+ - documentation/docs/article/getting_started.md
229
+ - documentation/docs/article/guides/_category_.yml
230
+ - documentation/docs/article/guides/download_playwright_driver.md
231
+ - documentation/docs/article/guides/launch_browser.md
232
+ - documentation/docs/article/guides/rails_integration.md
233
+ - documentation/docs/article/guides/recording_video.md
234
+ - documentation/docs/include/api_coverage.md
235
+ - documentation/docusaurus.config.js
236
+ - documentation/package.json
237
+ - documentation/sidebars.js
238
+ - documentation/src/components/HomepageFeatures.js
239
+ - documentation/src/components/HomepageFeatures.module.css
240
+ - documentation/src/css/custom.css
241
+ - documentation/src/pages/index.js
242
+ - documentation/src/pages/index.module.css
243
+ - documentation/src/pages/markdown-page.md
244
+ - documentation/static/.nojekyll
245
+ - documentation/static/img/playwright-logo.svg
246
+ - documentation/static/img/undraw_dropdown_menu.svg
247
+ - documentation/static/img/undraw_web_development.svg
248
+ - documentation/static/img/undraw_windows.svg
249
+ - documentation/yarn.lock
211
250
  - lib/playwright.rb
212
251
  - lib/playwright/android_input_impl.rb
213
252
  - lib/playwright/api_implementation.rb
@@ -233,6 +272,7 @@ files:
233
272
  - lib/playwright/channel_owners/route.rb
234
273
  - lib/playwright/channel_owners/selectors.rb
235
274
  - lib/playwright/channel_owners/stream.rb
275
+ - lib/playwright/channel_owners/worker.rb
236
276
  - lib/playwright/connection.rb
237
277
  - lib/playwright/download.rb
238
278
  - lib/playwright/errors.rb
@@ -244,7 +284,6 @@ files:
244
284
  - lib/playwright/input_files.rb
245
285
  - lib/playwright/javascript.rb
246
286
  - lib/playwright/javascript/expression.rb
247
- - lib/playwright/javascript/function.rb
248
287
  - lib/playwright/javascript/value_parser.rb
249
288
  - lib/playwright/javascript/value_serializer.rb
250
289
  - lib/playwright/keyboard_impl.rb
@@ -254,6 +293,7 @@ files:
254
293
  - lib/playwright/select_option_values.rb
255
294
  - lib/playwright/timeout_settings.rb
256
295
  - lib/playwright/touchscreen_impl.rb
296
+ - lib/playwright/tracing_impl.rb
257
297
  - lib/playwright/transport.rb
258
298
  - lib/playwright/url_matcher.rb
259
299
  - lib/playwright/utils.rb
@@ -285,6 +325,7 @@ files:
285
325
  - lib/playwright_api/route.rb
286
326
  - lib/playwright_api/selectors.rb
287
327
  - lib/playwright_api/touchscreen.rb
328
+ - lib/playwright_api/tracing.rb
288
329
  - lib/playwright_api/web_socket.rb
289
330
  - lib/playwright_api/worker.rb
290
331
  - playwright.gemspec
@@ -300,7 +341,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
300
341
  requirements:
301
342
  - - ">="
302
343
  - !ruby/object:Gem::Version
303
- version: '0'
344
+ version: '2.4'
304
345
  required_rubygems_version: !ruby/object:Gem::Requirement
305
346
  requirements:
306
347
  - - ">="
@@ -310,5 +351,5 @@ requirements: []
310
351
  rubygems_version: 3.2.15
311
352
  signing_key:
312
353
  specification_version: 4
313
- summary: The Ruby binding of playwright driver 1.11.0
354
+ summary: The Ruby binding of playwright driver 1.12.0
314
355
  test_files: []
@@ -1,67 +0,0 @@
1
- module Playwright
2
- module JavaScript
3
- class Function
4
- def initialize(definition, arg)
5
- @definition = definition
6
- @serialized_arg = ValueSerializer.new(arg).serialize
7
- end
8
-
9
- def evaluate(channel)
10
- value = channel.send_message_to_server(
11
- 'evaluateExpression',
12
- expression: @definition,
13
- isFunction: true,
14
- arg: @serialized_arg,
15
- )
16
- ValueParser.new(value).parse
17
- end
18
-
19
- def evaluate_handle(channel)
20
- resp = channel.send_message_to_server(
21
- 'evaluateExpressionHandle',
22
- expression: @definition,
23
- isFunction: true,
24
- arg: @serialized_arg,
25
- )
26
- ::Playwright::ChannelOwner.from(resp)
27
- end
28
-
29
- def eval_on_selector(channel, selector)
30
- value = channel.send_message_to_server(
31
- 'evalOnSelector',
32
- selector: selector,
33
- expression: @definition,
34
- isFunction: true,
35
- arg: @serialized_arg,
36
- )
37
- ValueParser.new(value).parse
38
- end
39
-
40
- def eval_on_selector_all(channel, selector)
41
- value = channel.send_message_to_server(
42
- 'evalOnSelectorAll',
43
- selector: selector,
44
- expression: @definition,
45
- isFunction: true,
46
- arg: @serialized_arg,
47
- )
48
- ValueParser.new(value).parse
49
- end
50
-
51
- def wait_for_function(channel, polling:, timeout:)
52
- params = {
53
- expression: @definition,
54
- isFunction: true,
55
- arg: @serialized_arg,
56
- polling: polling,
57
- timeout: timeout,
58
- }.compact
59
- if polling.is_a?(Numeric)
60
- params[:pollingInterval] = polling
61
- end
62
- resp = channel.send_message_to_server('waitForFunction', params)
63
- ChannelOwners::JSHandle.from(resp)
64
- end
65
- end
66
- end
67
- end