playwright-ruby-client 0.6.3 → 0.7.1

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/browser.md +12 -1
  3. data/documentation/docs/api/browser_context.md +11 -1
  4. data/documentation/docs/api/browser_type.md +54 -1
  5. data/documentation/docs/api/cdp_session.md +41 -1
  6. data/documentation/docs/api/experimental/android.md +3 -2
  7. data/documentation/docs/api/page.md +18 -0
  8. data/documentation/docs/api/route.md +20 -21
  9. data/documentation/docs/api/tracing.md +8 -15
  10. data/documentation/docs/api/web_socket.md +38 -1
  11. data/documentation/docs/article/guides/launch_browser.md +2 -0
  12. data/documentation/docs/article/guides/rails_integration.md +45 -2
  13. data/documentation/docs/article/guides/recording_video.md +79 -0
  14. data/documentation/docs/article/guides/semi_automation.md +67 -0
  15. data/documentation/docs/include/api_coverage.md +13 -14
  16. data/documentation/package.json +1 -1
  17. data/documentation/yarn.lock +478 -498
  18. data/lib/playwright/channel_owners/browser.rb +19 -10
  19. data/lib/playwright/channel_owners/browser_context.rb +14 -2
  20. data/lib/playwright/channel_owners/browser_type.rb +23 -8
  21. data/lib/playwright/channel_owners/cdp_session.rb +19 -0
  22. data/lib/playwright/channel_owners/page.rb +8 -0
  23. data/lib/playwright/channel_owners/response.rb +1 -1
  24. data/lib/playwright/channel_owners/web_socket.rb +87 -0
  25. data/lib/playwright/tracing_impl.rb +9 -9
  26. data/lib/playwright/version.rb +1 -1
  27. data/lib/playwright_api/android.rb +3 -2
  28. data/lib/playwright_api/browser.rb +4 -3
  29. data/lib/playwright_api/browser_context.rb +3 -3
  30. data/lib/playwright_api/browser_type.rb +6 -5
  31. data/lib/playwright_api/cdp_session.rb +24 -2
  32. data/lib/playwright_api/page.rb +9 -9
  33. data/lib/playwright_api/response.rb +0 -5
  34. data/lib/playwright_api/tracing.rb +6 -12
  35. data/lib/playwright_api/web_socket.rb +28 -6
  36. data/playwright.gemspec +2 -1
  37. metadata +34 -16
@@ -59,11 +59,6 @@ module Playwright
59
59
  wrap_impl(@impl.url)
60
60
  end
61
61
 
62
- # @nodoc
63
- def after_initialize
64
- wrap_impl(@impl.after_initialize)
65
- end
66
-
67
62
  # @nodoc
68
63
  def ok?
69
64
  wrap_impl(@impl.ok?)
@@ -5,35 +5,29 @@ module Playwright
5
5
  # Start with specifying the folder traces will be stored in:
6
6
  #
7
7
  # ```python sync
8
- # browser = chromium.launch(traceDir='traces')
8
+ # browser = chromium.launch()
9
9
  # context = browser.new_context()
10
- # context.tracing.start(name="trace", screenshots=True, snapshots=True)
10
+ # context.tracing.start(screenshots=True, snapshots=True)
11
11
  # page.goto("https://playwright.dev")
12
- # context.tracing.stop()
13
- # context.tracing.export("trace.zip")
12
+ # context.tracing.stop(path = "trace.zip")
14
13
  # ```
15
14
  class Tracing < PlaywrightApi
16
15
 
17
- # Export trace into the file with the given name. Should be called after the tracing has stopped.
18
- def export(path)
19
- wrap_impl(@impl.export(unwrap_impl(path)))
20
- end
21
-
22
16
  # Start tracing.
23
17
  #
24
18
  # ```python sync
25
19
  # context.tracing.start(name="trace", screenshots=True, snapshots=True)
26
20
  # page.goto("https://playwright.dev")
27
21
  # context.tracing.stop()
28
- # context.tracing.export("trace.zip")
22
+ # context.tracing.stop(path = "trace.zip")
29
23
  # ```
30
24
  def start(name: nil, screenshots: nil, snapshots: nil)
31
25
  wrap_impl(@impl.start(name: unwrap_impl(name), screenshots: unwrap_impl(screenshots), snapshots: unwrap_impl(snapshots)))
32
26
  end
33
27
 
34
28
  # Stop tracing.
35
- def stop
36
- wrap_impl(@impl.stop)
29
+ def stop(path: nil)
30
+ wrap_impl(@impl.stop(path: unwrap_impl(path)))
37
31
  end
38
32
  end
39
33
  end
@@ -4,18 +4,18 @@ module Playwright
4
4
 
5
5
  # Indicates that the web socket has been closed.
6
6
  def closed?
7
- raise NotImplementedError.new('closed? is not implemented yet.')
7
+ wrap_impl(@impl.closed?)
8
8
  end
9
9
 
10
10
  # Contains the URL of the WebSocket.
11
11
  def url
12
- raise NotImplementedError.new('url is not implemented yet.')
12
+ wrap_impl(@impl.url)
13
13
  end
14
14
 
15
15
  # Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
16
16
  # value. Will throw an error if the webSocket is closed before the event is fired. Returns the event data value.
17
- def expect_event(event, predicate: nil, timeout: nil)
18
- raise NotImplementedError.new('expect_event is not implemented yet.')
17
+ def expect_event(event, predicate: nil, timeout: nil, &block)
18
+ wrap_impl(@impl.expect_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
19
19
  end
20
20
 
21
21
  # > NOTE: In most cases, you should use [`method: WebSocket.waitForEvent`].
@@ -23,8 +23,30 @@ module Playwright
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.
26
- def wait_for_event(event, predicate: nil, timeout: nil)
27
- raise NotImplementedError.new('wait_for_event is not implemented yet.')
26
+ def wait_for_event(event, predicate: nil, timeout: nil, &block)
27
+ wrap_impl(@impl.wait_for_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
28
+ end
29
+
30
+ # -- inherited from EventEmitter --
31
+ # @nodoc
32
+ def once(event, callback)
33
+ event_emitter_proxy.once(event, callback)
34
+ end
35
+
36
+ # -- inherited from EventEmitter --
37
+ # @nodoc
38
+ def on(event, callback)
39
+ event_emitter_proxy.on(event, callback)
40
+ end
41
+
42
+ # -- inherited from EventEmitter --
43
+ # @nodoc
44
+ def off(event, callback)
45
+ event_emitter_proxy.off(event, callback)
46
+ end
47
+
48
+ private def event_emitter_proxy
49
+ @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
28
50
  end
29
51
  end
30
52
  end
data/playwright.gemspec CHANGED
@@ -30,11 +30,12 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'bundler', '~> 2.2.3'
31
31
  spec.add_development_dependency 'chunky_png'
32
32
  spec.add_development_dependency 'dry-inflector'
33
+ spec.add_development_dependency 'faye-websocket'
33
34
  spec.add_development_dependency 'pry-byebug'
35
+ spec.add_development_dependency 'puma'
34
36
  spec.add_development_dependency 'rake', '~> 13.0.3'
35
37
  spec.add_development_dependency 'rspec', '~> 3.10.0 '
36
38
  spec.add_development_dependency 'rspec_junit_formatter' # for CircleCI.
37
39
  spec.add_development_dependency 'rubocop-rspec'
38
40
  spec.add_development_dependency 'sinatra'
39
- spec.add_development_dependency 'webrick'
40
41
  end
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.6.3
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-07 00:00:00.000000000 Z
11
+ date: 2021-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faye-websocket
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: pry-byebug
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: puma
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: rake
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -164,20 +192,6 @@ dependencies:
164
192
  - - ">="
165
193
  - !ruby/object:Gem::Version
166
194
  version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: webrick
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
195
  description:
182
196
  email:
183
197
  - q7w8e9w8q7w8e9@yahoo.co.jp
@@ -230,6 +244,8 @@ files:
230
244
  - documentation/docs/article/guides/download_playwright_driver.md
231
245
  - documentation/docs/article/guides/launch_browser.md
232
246
  - documentation/docs/article/guides/rails_integration.md
247
+ - documentation/docs/article/guides/recording_video.md
248
+ - documentation/docs/article/guides/semi_automation.md
233
249
  - documentation/docs/include/api_coverage.md
234
250
  - documentation/docusaurus.config.js
235
251
  - documentation/package.json
@@ -258,6 +274,7 @@ files:
258
274
  - lib/playwright/channel_owners/browser.rb
259
275
  - lib/playwright/channel_owners/browser_context.rb
260
276
  - lib/playwright/channel_owners/browser_type.rb
277
+ - lib/playwright/channel_owners/cdp_session.rb
261
278
  - lib/playwright/channel_owners/console_message.rb
262
279
  - lib/playwright/channel_owners/dialog.rb
263
280
  - lib/playwright/channel_owners/electron.rb
@@ -271,6 +288,7 @@ files:
271
288
  - lib/playwright/channel_owners/route.rb
272
289
  - lib/playwright/channel_owners/selectors.rb
273
290
  - lib/playwright/channel_owners/stream.rb
291
+ - lib/playwright/channel_owners/web_socket.rb
274
292
  - lib/playwright/channel_owners/worker.rb
275
293
  - lib/playwright/connection.rb
276
294
  - lib/playwright/download.rb