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
@@ -1,6 +1,6 @@
1
1
  module Playwright
2
- # Selectors can be used to install custom selector engines. See
3
- # [Working with selectors](./selectors.md#working-with-selectors) for more information.
2
+ # Selectors can be used to install custom selector engines. See [Working with selectors](./selectors.md) for more
3
+ # information.
4
4
  class Selectors < PlaywrightApi
5
5
 
6
6
  # An example of registering selector engine that queries elements based on a tag name:
@@ -40,26 +40,38 @@ module Playwright
40
40
  # await browser.close();
41
41
  # })();
42
42
  # ```
43
+ #
44
+ # ```python async
45
+ # # FIXME: add snippet
46
+ # ```
47
+ #
48
+ # ```python sync
49
+ # # FIXME: add snippet
50
+ # ```
43
51
  def register(name, script, contentScript: nil)
44
52
  raise NotImplementedError.new('register is not implemented yet.')
45
53
  end
46
54
 
47
55
  # -- inherited from EventEmitter --
48
56
  # @nodoc
49
- def off(event, callback)
50
- wrap_channel_owner(@channel_owner.off(event, callback))
57
+ def once(event, callback)
58
+ event_emitter_proxy.once(event, callback)
51
59
  end
52
60
 
53
61
  # -- inherited from EventEmitter --
54
62
  # @nodoc
55
- def once(event, callback)
56
- wrap_channel_owner(@channel_owner.once(event, callback))
63
+ def on(event, callback)
64
+ event_emitter_proxy.on(event, callback)
57
65
  end
58
66
 
59
67
  # -- inherited from EventEmitter --
60
68
  # @nodoc
61
- def on(event, callback)
62
- wrap_channel_owner(@channel_owner.on(event, callback))
69
+ def off(event, callback)
70
+ event_emitter_proxy.off(event, callback)
71
+ end
72
+
73
+ private def event_emitter_proxy
74
+ @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
63
75
  end
64
76
  end
65
77
  end
@@ -5,6 +5,14 @@ module Playwright
5
5
  # ```js
6
6
  # console.log(await page.video().path());
7
7
  # ```
8
+ #
9
+ # ```python async
10
+ # print(await page.video.path())
11
+ # ```
12
+ #
13
+ # ```python sync
14
+ # print(page.video.path())
15
+ # ```
8
16
  class Video < PlaywrightApi
9
17
 
10
18
  # Returns the file system path this video will be recorded to. The video is guaranteed to be written to the filesystem
@@ -11,13 +11,5 @@ module Playwright
11
11
  def url
12
12
  raise NotImplementedError.new('url is not implemented yet.')
13
13
  end
14
-
15
- # Returns the event data value.
16
- #
17
- # Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
18
- # value. Will throw an error if the webSocket is closed before the event is fired.
19
- def wait_for_event(event, optionsOrPredicate: nil)
20
- raise NotImplementedError.new('wait_for_event is not implemented yet.')
21
- end
22
14
  end
23
15
  end
@@ -14,28 +14,40 @@ module Playwright
14
14
  # for (const worker of page.workers())
15
15
  # console.log(' ' + worker.url());
16
16
  # ```
17
+ #
18
+ # ```py
19
+ # def handle_worker(worker):
20
+ # print("worker created: " + worker.url)
21
+ # worker.on("close", lambda: print("worker destroyed: " + worker.url))
22
+ #
23
+ # page.on('worker', handle_worker)
24
+ #
25
+ # print("current workers:")
26
+ # for worker in page.workers:
27
+ # print(" " + worker.url)
28
+ # ```
17
29
  class Worker < PlaywrightApi
18
30
 
19
- # Returns the return value of `pageFunction`
31
+ # Returns the return value of `expression`.
20
32
  #
21
- # If the function passed to the `worker.evaluate` returns a [Promise], then `worker.evaluate` would wait for the promise
22
- # to resolve and return its value.
33
+ # If the function passed to the [`method: Worker.evaluate`] returns a [Promise], then [`method: Worker.evaluate`] would
34
+ # wait for the promise to resolve and return its value.
23
35
  #
24
- # If the function passed to the `worker.evaluate` returns a non-[Serializable] value, then `worker.evaluate` returns
25
- # `undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`:
26
- # `-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
27
- def evaluate(pageFunction, arg: nil)
36
+ # If the function passed to the [`method: Worker.evaluate`] returns a non-[Serializable] value, then
37
+ # [`method: Worker.evaluate`] returns `undefined`. Playwright also supports transferring some additional values that are
38
+ # not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
39
+ def evaluate(expression, arg: nil)
28
40
  raise NotImplementedError.new('evaluate is not implemented yet.')
29
41
  end
30
42
 
31
- # Returns the return value of `pageFunction` as in-page object (JSHandle).
43
+ # Returns the return value of `expression` as a `JSHandle`.
32
44
  #
33
- # The only difference between `worker.evaluate` and `worker.evaluateHandle` is that `worker.evaluateHandle` returns
34
- # in-page object (JSHandle).
45
+ # The only difference between [`method: Worker.evaluate`] and [`method: Worker.evaluateHandle`] is that
46
+ # [`method: Worker.evaluateHandle`] returns `JSHandle`.
35
47
  #
36
- # If the function passed to the `worker.evaluateHandle` returns a [Promise], then `worker.evaluateHandle` would wait for
37
- # the promise to resolve and return its value.
38
- def evaluate_handle(pageFunction, arg: nil)
48
+ # If the function passed to the [`method: Worker.evaluateHandle`] returns a [Promise], then
49
+ # [`method: Worker.evaluateHandle`] would wait for the promise to resolve and return its value.
50
+ def evaluate_handle(expression, arg: nil)
39
51
  raise NotImplementedError.new('evaluate_handle is not implemented yet.')
40
52
  end
41
53
 
data/playwright.gemspec CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ['lib']
26
26
 
27
27
  spec.add_dependency 'concurrent-ruby'
28
+ spec.add_dependency 'mime-types', '>= 3.0'
28
29
  spec.add_development_dependency 'bundler', '~> 2.2.3'
29
30
  spec.add_development_dependency 'dry-inflector'
30
31
  spec.add_development_dependency 'pry-byebug'
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.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-23 00:00:00.000000000 Z
11
+ date: 2021-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mime-types
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -165,10 +179,14 @@ files:
165
179
  - Rakefile
166
180
  - bin/console
167
181
  - bin/setup
182
+ - docs/api_coverage.md
168
183
  - lib/playwright.rb
184
+ - lib/playwright/android_input_impl.rb
185
+ - lib/playwright/api_implementation.rb
169
186
  - lib/playwright/channel.rb
170
187
  - lib/playwright/channel_owner.rb
171
188
  - lib/playwright/channel_owners/android.rb
189
+ - lib/playwright/channel_owners/android_device.rb
172
190
  - lib/playwright/channel_owners/binding_call.rb
173
191
  - lib/playwright/channel_owners/browser.rb
174
192
  - lib/playwright/channel_owners/browser_context.rb
@@ -176,6 +194,7 @@ files:
176
194
  - lib/playwright/channel_owners/chromium_browser.rb
177
195
  - lib/playwright/channel_owners/chromium_browser_context.rb
178
196
  - lib/playwright/channel_owners/console_message.rb
197
+ - lib/playwright/channel_owners/download.rb
179
198
  - lib/playwright/channel_owners/electron.rb
180
199
  - lib/playwright/channel_owners/element_handle.rb
181
200
  - lib/playwright/channel_owners/firefox_browser.rb
@@ -190,19 +209,31 @@ files:
190
209
  - lib/playwright/connection.rb
191
210
  - lib/playwright/errors.rb
192
211
  - lib/playwright/event_emitter.rb
212
+ - lib/playwright/event_emitter_proxy.rb
193
213
  - lib/playwright/events.rb
214
+ - lib/playwright/file_chooser_impl.rb
215
+ - lib/playwright/http_headers.rb
216
+ - lib/playwright/input_files.rb
194
217
  - lib/playwright/javascript.rb
195
218
  - lib/playwright/javascript/expression.rb
196
219
  - lib/playwright/javascript/function.rb
197
220
  - lib/playwright/javascript/value_parser.rb
198
221
  - lib/playwright/javascript/value_serializer.rb
222
+ - lib/playwright/keyboard_impl.rb
223
+ - lib/playwright/mouse_impl.rb
199
224
  - lib/playwright/playwright_api.rb
225
+ - lib/playwright/select_option_values.rb
200
226
  - lib/playwright/timeout_settings.rb
227
+ - lib/playwright/touchscreen_impl.rb
201
228
  - lib/playwright/transport.rb
229
+ - lib/playwright/url_matcher.rb
202
230
  - lib/playwright/utils.rb
203
231
  - lib/playwright/version.rb
204
232
  - lib/playwright/wait_helper.rb
205
233
  - lib/playwright_api/accessibility.rb
234
+ - lib/playwright_api/android.rb
235
+ - lib/playwright_api/android_device.rb
236
+ - lib/playwright_api/android_input.rb
206
237
  - lib/playwright_api/binding_call.rb
207
238
  - lib/playwright_api/browser.rb
208
239
  - lib/playwright_api/browser_context.rb