playwright-ruby-client 0.6.6 → 0.7.0

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: 9b548b6927a468b4a1209e9002cc7ca6f20bf0ad7ad4091510336ed610d338bb
4
- data.tar.gz: d8f5e411d5ee99460e77d3d922608996cde6de1a2199ee0f6425c7e3a5eb9a7b
3
+ metadata.gz: 9342eb9d31cb69d5eee5734d2143505672336cb630599f5d92a3e07559b76421
4
+ data.tar.gz: 66a5f38c686c7477037740cddf2d6572b63b21dd791f92a0c179fd292ee0b8e6
5
5
  SHA512:
6
- metadata.gz: 645bd780e189153fabc25de3a58b490ae5fb919c8ed9b81f701c8bed0e910483be9cb2c901bda8f4619153bb18924240ae43841b197479665883567980ffd29c
7
- data.tar.gz: 50af6ab226985f5bd7a7631fab3959c4215a6bae7d57d32c5cd9787f7d43a8ed2bbe599443a611a9eafd73e7e8dd74ace7783781a95d04357d5a9ff4c4e69313
6
+ metadata.gz: 9adc1be3cbef06c38bcb1080e26c8b816311dc81573b6d089f55fd286e9e29d9a29831f1655a2d8189d1c20ed6bea0fd108a98ed347d4c1c1281753d64cddd2b
7
+ data.tar.gz: f65e5ff953e8b1f6ef54a031cda1a53819bdb0c62caa44b5dc34a2011bc1d72d867a838de98bc7e2cbc8b0d34899cf19b6b89c4d008aa7a98f60871e91b3021e
@@ -1393,6 +1393,14 @@ page.wait_for_url("**/target.html")
1393
1393
 
1394
1394
  Shortcut for main frame's [Frame#wait_for_url](./frame#wait_for_url).
1395
1395
 
1396
+ ## expect_websocket
1397
+
1398
+ ```
1399
+ def expect_websocket(predicate: nil, timeout: nil, &block)
1400
+ ```
1401
+
1402
+ 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.
1403
+
1396
1404
  ## accessibility
1397
1405
 
1398
1406
  ## keyboard
@@ -5,3 +5,40 @@ sidebar_position: 10
5
5
  # WebSocket
6
6
 
7
7
  The [WebSocket](./web_socket) class represents websocket connections in the page.
8
+
9
+ ## closed?
10
+
11
+ ```
12
+ def closed?
13
+ ```
14
+
15
+ Indicates that the web socket has been closed.
16
+
17
+ ## url
18
+
19
+ ```
20
+ def url
21
+ ```
22
+
23
+ Contains the URL of the WebSocket.
24
+
25
+ ## expect_event
26
+
27
+ ```
28
+ def expect_event(event, predicate: nil, timeout: nil, &block)
29
+ ```
30
+
31
+ Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
32
+ value. Will throw an error if the webSocket is closed before the event is fired. Returns the event data value.
33
+
34
+ ## wait_for_event
35
+
36
+ ```
37
+ def wait_for_event(event, predicate: nil, timeout: nil, &block)
38
+ ```
39
+
40
+ > NOTE: In most cases, you should use [WebSocket#wait_for_event](./web_socket#wait_for_event).
41
+
42
+ Waits for given `event` to fire. If predicate is provided, it passes event's value into the `predicate` function and
43
+ waits for `predicate(event)` to return a truthy value. Will throw an error if the socket is closed before the `event` is
44
+ fired.
@@ -117,3 +117,5 @@ Playwright.create(playwright_cli_executable_path: 'npx playwright') do |playwrig
117
117
  end
118
118
  end
119
119
  ```
120
+
121
+ Note that each browser context is isolated and not persisted by default. When persistent browser context is needed, we can use [BrowserType#launch_persistent_context](/docs/api/browser_type#launch_persistent_context).
@@ -0,0 +1,67 @@
1
+ # Semi-automation
2
+
3
+ Playwright Browser context is isolated and not persisted by default. But we can also use persistent browser context using [BrowserType#launch_persistent_context](/docs/api/browser_type#launch_persistent_context).
4
+ This allow us to intermediate into automation, for example
5
+
6
+ * Authenticate with OAuth2 manually before automation
7
+ * Testing a page after some chrome extensions are installed manually
8
+
9
+ Keep in mind repeatedly that persistent browser context is NOT RECOMMENDED for most cases because it would bring many side effects.
10
+
11
+ ## Pause automation for manual operation
12
+
13
+ `Page#pause` is not implemented yet, however we can use `binding.pry` (with `pry-byebug` installed) instead.
14
+
15
+ ```ruby {4}
16
+ playwright.chromium.launch_persistent_context('./data/', headless: false) do |context|
17
+ page = context.new_page
18
+ page.goto('https://example.com/')
19
+ binding.pry
20
+ end
21
+ ```
22
+
23
+ When script is executed, it is paused as below.
24
+
25
+ ```
26
+ 3:
27
+ 4: playwright.chromium.launch_persistent_context('./data/', headless: false) do |context|
28
+ 5: page = context.new_page
29
+ 6: page.goto('https://example.com/')
30
+ => 7: binding.pry
31
+ 8: end
32
+
33
+ [1] pry(main)>
34
+ ```
35
+
36
+ We can inspect using `page`, `context` and also we can operate something manually during the pause.
37
+
38
+ See https://github.com/deivid-rodriguez/pry-byebug for more detailed debugging options.
39
+
40
+ ## Working with Chrome extensions
41
+
42
+ **Playwright disables the Chrome extension feature by default.**
43
+ We have to enable it for installing Chrome extension, by passing these 3 parameters on launch.
44
+
45
+ * `acceptDownloads: true`
46
+ * `headless: false`
47
+ * `ignoreDefaultArgs: ['--disable-extensions']`
48
+
49
+ ```ruby
50
+ require 'playwright'
51
+ require 'pry'
52
+
53
+ Playwright.create(playwright_cli_executable_path: './node_modules/.bin/playwright') do |playwright|
54
+ launch_params = {
55
+ acceptDownloads: true,
56
+ channel: 'chrome',
57
+ headless: false,
58
+ ignoreDefaultArgs: ['--disable-extensions'],
59
+ }
60
+
61
+ playwright.chromium.launch_persistent_context('./data/', **launch_params) do |context|
62
+ page = context.new_page
63
+ page.goto('https://example.com/')
64
+ binding.pry
65
+ end
66
+ end
67
+ ```
@@ -40,10 +40,10 @@
40
40
 
41
41
  ## WebSocket
42
42
 
43
- * ~~closed?~~
44
- * ~~url~~
45
- * ~~expect_event~~
46
- * ~~wait_for_event~~
43
+ * closed?
44
+ * url
45
+ * expect_event
46
+ * wait_for_event
47
47
 
48
48
  ## Keyboard
49
49
 
@@ -278,7 +278,7 @@
278
278
  * wait_for_selector
279
279
  * ~~wait_for_timeout~~
280
280
  * wait_for_url
281
- * ~~expect_websocket~~
281
+ * expect_websocket
282
282
  * ~~expect_worker~~
283
283
  * ~~workers~~
284
284
  * ~~wait_for_event~~
@@ -774,6 +774,10 @@ module Playwright
774
774
  expect_event(Events::Page::Response, predicate: predicate, timeout: timeout, &block)
775
775
  end
776
776
 
777
+ def expect_websocket(predicate: nil, timeout: nil, &block)
778
+ expect_event(Events::Page::WebSocket, predicate: predicate, timeout: timeout, &block)
779
+ end
780
+
777
781
  # called from Frame with send(:timeout_settings)
778
782
  private def timeout_settings
779
783
  @timeout_settings
@@ -1,4 +1,87 @@
1
+ require 'base64'
2
+
1
3
  module Playwright
2
4
  define_channel_owner :WebSocket do
5
+ private def after_initialize
6
+ @closed = false
7
+
8
+ @channel.on('frameSent', -> (params) {
9
+ on_frame_sent(params['opcode'], params['data'])
10
+ })
11
+ @channel.on('frameReceived', -> (params) {
12
+ on_frame_received(params['opcode'], params['data'])
13
+ })
14
+ @channel.on('socketError', -> (params) {
15
+ emit(Events::WebSocket::Error, params['error'])
16
+ })
17
+ @channel.on('close', -> (_) { on_close })
18
+ end
19
+
20
+ def url
21
+ @initializer['url']
22
+ end
23
+
24
+ class SocketClosedError < StandardError
25
+ def initialize
26
+ super('Socket closed')
27
+ end
28
+ end
29
+
30
+ class SocketError < StandardError
31
+ def initialize
32
+ super('Socket error')
33
+ end
34
+ end
35
+
36
+ class PageClosedError < StandardError
37
+ def initialize
38
+ super('Page closed')
39
+ end
40
+ end
41
+
42
+ def expect_event(event, predicate: nil, timeout: nil, &block)
43
+ wait_helper = WaitHelper.new
44
+ wait_helper.reject_on_timeout(timeout || @parent.send(:timeout_settings).timeout, "Timeout while waiting for event \"#{event}\"")
45
+
46
+ unless event == Events::WebSocket::Close
47
+ wait_helper.reject_on_event(self, Events::WebSocket::Close, SocketClosedError.new)
48
+ end
49
+
50
+ unless event == Events::WebSocket::Error
51
+ wait_helper.reject_on_event(self, Events::WebSocket::Error, SocketError.new)
52
+ end
53
+
54
+ wait_helper.reject_on_event(@parent, 'close', PageClosedError.new)
55
+ wait_helper.wait_for_event(self, event, predicate: predicate)
56
+ block&.call
57
+
58
+ wait_helper.promise.value!
59
+ end
60
+ alias_method :wait_for_event, :expect_event
61
+
62
+ private def on_frame_sent(opcode, data)
63
+ if opcode == 2
64
+ emit(Events::WebSocket::FrameSent, Base64.strict_decode64(data))
65
+ else
66
+ emit(Events::WebSocket::FrameSent, data)
67
+ end
68
+ end
69
+
70
+ private def on_frame_received(opcode, data)
71
+ if opcode == 2
72
+ emit(Events::WebSocket::FrameReceived, Base64.strict_decode64(data))
73
+ else
74
+ emit(Events::WebSocket::FrameReceived, data)
75
+ end
76
+ end
77
+
78
+ def closed?
79
+ @closed
80
+ end
81
+
82
+ private def on_close
83
+ @closed = true
84
+ emit(Events::WebSocket::Close)
85
+ end
3
86
  end
4
87
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playwright
4
- VERSION = '0.6.6'
4
+ VERSION = '0.7.0'
5
5
  COMPATIBLE_PLAYWRIGHT_VERSION = '1.12.0'
6
6
  end
@@ -23,12 +23,6 @@ module Playwright
23
23
  end
24
24
  alias_method :default_timeout=, :set_default_timeout
25
25
 
26
- # -- inherited from EventEmitter --
27
- # @nodoc
28
- def once(event, callback)
29
- event_emitter_proxy.once(event, callback)
30
- end
31
-
32
26
  # -- inherited from EventEmitter --
33
27
  # @nodoc
34
28
  def on(event, callback)
@@ -41,6 +35,12 @@ module Playwright
41
35
  event_emitter_proxy.off(event, callback)
42
36
  end
43
37
 
38
+ # -- inherited from EventEmitter --
39
+ # @nodoc
40
+ def once(event, callback)
41
+ event_emitter_proxy.once(event, callback)
42
+ end
43
+
44
44
  private def event_emitter_proxy
45
45
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
46
46
  end
@@ -171,12 +171,6 @@ module Playwright
171
171
  wrap_impl(@impl.tap_on(unwrap_impl(selector), duration: unwrap_impl(duration), timeout: unwrap_impl(timeout)))
172
172
  end
173
173
 
174
- # -- inherited from EventEmitter --
175
- # @nodoc
176
- def once(event, callback)
177
- event_emitter_proxy.once(event, callback)
178
- end
179
-
180
174
  # -- inherited from EventEmitter --
181
175
  # @nodoc
182
176
  def on(event, callback)
@@ -189,6 +183,12 @@ module Playwright
189
183
  event_emitter_proxy.off(event, callback)
190
184
  end
191
185
 
186
+ # -- inherited from EventEmitter --
187
+ # @nodoc
188
+ def once(event, callback)
189
+ event_emitter_proxy.once(event, callback)
190
+ end
191
+
192
192
  private def event_emitter_proxy
193
193
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
194
194
  end
@@ -156,12 +156,6 @@ module Playwright
156
156
  wrap_impl(@impl.version)
157
157
  end
158
158
 
159
- # -- inherited from EventEmitter --
160
- # @nodoc
161
- def once(event, callback)
162
- event_emitter_proxy.once(event, callback)
163
- end
164
-
165
159
  # -- inherited from EventEmitter --
166
160
  # @nodoc
167
161
  def on(event, callback)
@@ -174,6 +168,12 @@ module Playwright
174
168
  event_emitter_proxy.off(event, callback)
175
169
  end
176
170
 
171
+ # -- inherited from EventEmitter --
172
+ # @nodoc
173
+ def once(event, callback)
174
+ event_emitter_proxy.once(event, callback)
175
+ end
176
+
177
177
  private def event_emitter_proxy
178
178
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
179
179
  end
@@ -382,12 +382,6 @@ module Playwright
382
382
  wrap_impl(@impl.pause)
383
383
  end
384
384
 
385
- # -- inherited from EventEmitter --
386
- # @nodoc
387
- def once(event, callback)
388
- event_emitter_proxy.once(event, callback)
389
- end
390
-
391
385
  # -- inherited from EventEmitter --
392
386
  # @nodoc
393
387
  def on(event, callback)
@@ -400,6 +394,12 @@ module Playwright
400
394
  event_emitter_proxy.off(event, callback)
401
395
  end
402
396
 
397
+ # -- inherited from EventEmitter --
398
+ # @nodoc
399
+ def once(event, callback)
400
+ event_emitter_proxy.once(event, callback)
401
+ end
402
+
403
403
  private def event_emitter_proxy
404
404
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
405
405
  end
@@ -143,12 +143,6 @@ module Playwright
143
143
  wrap_impl(@impl.name)
144
144
  end
145
145
 
146
- # -- inherited from EventEmitter --
147
- # @nodoc
148
- def once(event, callback)
149
- event_emitter_proxy.once(event, callback)
150
- end
151
-
152
146
  # -- inherited from EventEmitter --
153
147
  # @nodoc
154
148
  def on(event, callback)
@@ -161,6 +155,12 @@ module Playwright
161
155
  event_emitter_proxy.off(event, callback)
162
156
  end
163
157
 
158
+ # -- inherited from EventEmitter --
159
+ # @nodoc
160
+ def once(event, callback)
161
+ event_emitter_proxy.once(event, callback)
162
+ end
163
+
164
164
  private def event_emitter_proxy
165
165
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
166
166
  end
@@ -23,12 +23,6 @@ module Playwright
23
23
  wrap_impl(@impl.type)
24
24
  end
25
25
 
26
- # -- inherited from EventEmitter --
27
- # @nodoc
28
- def once(event, callback)
29
- event_emitter_proxy.once(event, callback)
30
- end
31
-
32
26
  # -- inherited from EventEmitter --
33
27
  # @nodoc
34
28
  def on(event, callback)
@@ -41,6 +35,12 @@ module Playwright
41
35
  event_emitter_proxy.off(event, callback)
42
36
  end
43
37
 
38
+ # -- inherited from EventEmitter --
39
+ # @nodoc
40
+ def once(event, callback)
41
+ event_emitter_proxy.once(event, callback)
42
+ end
43
+
44
44
  private def event_emitter_proxy
45
45
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
46
46
  end
@@ -58,12 +58,6 @@ module Playwright
58
58
  wrap_impl(@impl.accept_async(promptText: unwrap_impl(promptText)))
59
59
  end
60
60
 
61
- # -- inherited from EventEmitter --
62
- # @nodoc
63
- def once(event, callback)
64
- event_emitter_proxy.once(event, callback)
65
- end
66
-
67
61
  # -- inherited from EventEmitter --
68
62
  # @nodoc
69
63
  def on(event, callback)
@@ -76,6 +70,12 @@ module Playwright
76
70
  event_emitter_proxy.off(event, callback)
77
71
  end
78
72
 
73
+ # -- inherited from EventEmitter --
74
+ # @nodoc
75
+ def once(event, callback)
76
+ event_emitter_proxy.once(event, callback)
77
+ end
78
+
79
79
  private def event_emitter_proxy
80
80
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
81
81
  end
@@ -509,12 +509,6 @@ module Playwright
509
509
  wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
510
510
  end
511
511
 
512
- # -- inherited from EventEmitter --
513
- # @nodoc
514
- def once(event, callback)
515
- event_emitter_proxy.once(event, callback)
516
- end
517
-
518
512
  # -- inherited from EventEmitter --
519
513
  # @nodoc
520
514
  def on(event, callback)
@@ -527,6 +521,12 @@ module Playwright
527
521
  event_emitter_proxy.off(event, callback)
528
522
  end
529
523
 
524
+ # -- inherited from EventEmitter --
525
+ # @nodoc
526
+ def once(event, callback)
527
+ event_emitter_proxy.once(event, callback)
528
+ end
529
+
530
530
  private def event_emitter_proxy
531
531
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
532
532
  end
@@ -687,12 +687,6 @@ module Playwright
687
687
  wrap_impl(@impl.detached=(unwrap_impl(req)))
688
688
  end
689
689
 
690
- # -- inherited from EventEmitter --
691
- # @nodoc
692
- def once(event, callback)
693
- event_emitter_proxy.once(event, callback)
694
- end
695
-
696
690
  # -- inherited from EventEmitter --
697
691
  # @nodoc
698
692
  def on(event, callback)
@@ -705,6 +699,12 @@ module Playwright
705
699
  event_emitter_proxy.off(event, callback)
706
700
  end
707
701
 
702
+ # -- inherited from EventEmitter --
703
+ # @nodoc
704
+ def once(event, callback)
705
+ event_emitter_proxy.once(event, callback)
706
+ end
707
+
708
708
  private def event_emitter_proxy
709
709
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
710
710
  end
@@ -88,12 +88,6 @@ module Playwright
88
88
  wrap_impl(@impl.to_s)
89
89
  end
90
90
 
91
- # -- inherited from EventEmitter --
92
- # @nodoc
93
- def once(event, callback)
94
- event_emitter_proxy.once(event, callback)
95
- end
96
-
97
91
  # -- inherited from EventEmitter --
98
92
  # @nodoc
99
93
  def on(event, callback)
@@ -106,6 +100,12 @@ module Playwright
106
100
  event_emitter_proxy.off(event, callback)
107
101
  end
108
102
 
103
+ # -- inherited from EventEmitter --
104
+ # @nodoc
105
+ def once(event, callback)
106
+ event_emitter_proxy.once(event, callback)
107
+ end
108
+
109
109
  private def event_emitter_proxy
110
110
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
111
111
  end
@@ -1239,8 +1239,8 @@ module Playwright
1239
1239
  # Performs action and waits for a new `WebSocket`. If predicate is provided, it passes `WebSocket` value into the
1240
1240
  # `predicate` function and waits for `predicate(webSocket)` to return a truthy value. Will throw an error if the page is
1241
1241
  # closed before the WebSocket event is fired.
1242
- def expect_websocket(predicate: nil, timeout: nil)
1243
- raise NotImplementedError.new('expect_websocket is not implemented yet.')
1242
+ def expect_websocket(predicate: nil, timeout: nil, &block)
1243
+ wrap_impl(@impl.expect_websocket(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
1244
1244
  end
1245
1245
 
1246
1246
  # Performs action and waits for a new `Worker`. If predicate is provided, it passes `Worker` value into the `predicate`
@@ -1297,12 +1297,6 @@ module Playwright
1297
1297
  wrap_impl(@impl.guid)
1298
1298
  end
1299
1299
 
1300
- # -- inherited from EventEmitter --
1301
- # @nodoc
1302
- def once(event, callback)
1303
- event_emitter_proxy.once(event, callback)
1304
- end
1305
-
1306
1300
  # -- inherited from EventEmitter --
1307
1301
  # @nodoc
1308
1302
  def on(event, callback)
@@ -1315,6 +1309,12 @@ module Playwright
1315
1309
  event_emitter_proxy.off(event, callback)
1316
1310
  end
1317
1311
 
1312
+ # -- inherited from EventEmitter --
1313
+ # @nodoc
1314
+ def once(event, callback)
1315
+ event_emitter_proxy.once(event, callback)
1316
+ end
1317
+
1318
1318
  private def event_emitter_proxy
1319
1319
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
1320
1320
  end
@@ -91,12 +91,6 @@ module Playwright
91
91
  wrap_impl(@impl.electron)
92
92
  end
93
93
 
94
- # -- inherited from EventEmitter --
95
- # @nodoc
96
- def once(event, callback)
97
- event_emitter_proxy.once(event, callback)
98
- end
99
-
100
94
  # -- inherited from EventEmitter --
101
95
  # @nodoc
102
96
  def on(event, callback)
@@ -109,6 +103,12 @@ module Playwright
109
103
  event_emitter_proxy.off(event, callback)
110
104
  end
111
105
 
106
+ # -- inherited from EventEmitter --
107
+ # @nodoc
108
+ def once(event, callback)
109
+ event_emitter_proxy.once(event, callback)
110
+ end
111
+
112
112
  private def event_emitter_proxy
113
113
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
114
114
  end
@@ -128,12 +128,6 @@ module Playwright
128
128
  wrap_impl(@impl.url)
129
129
  end
130
130
 
131
- # -- inherited from EventEmitter --
132
- # @nodoc
133
- def once(event, callback)
134
- event_emitter_proxy.once(event, callback)
135
- end
136
-
137
131
  # -- inherited from EventEmitter --
138
132
  # @nodoc
139
133
  def on(event, callback)
@@ -146,6 +140,12 @@ module Playwright
146
140
  event_emitter_proxy.off(event, callback)
147
141
  end
148
142
 
143
+ # -- inherited from EventEmitter --
144
+ # @nodoc
145
+ def once(event, callback)
146
+ event_emitter_proxy.once(event, callback)
147
+ end
148
+
149
149
  private def event_emitter_proxy
150
150
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
151
151
  end
@@ -69,12 +69,6 @@ module Playwright
69
69
  wrap_impl(@impl.ok?)
70
70
  end
71
71
 
72
- # -- inherited from EventEmitter --
73
- # @nodoc
74
- def once(event, callback)
75
- event_emitter_proxy.once(event, callback)
76
- end
77
-
78
72
  # -- inherited from EventEmitter --
79
73
  # @nodoc
80
74
  def on(event, callback)
@@ -87,6 +81,12 @@ module Playwright
87
81
  event_emitter_proxy.off(event, callback)
88
82
  end
89
83
 
84
+ # -- inherited from EventEmitter --
85
+ # @nodoc
86
+ def once(event, callback)
87
+ event_emitter_proxy.once(event, callback)
88
+ end
89
+
90
90
  private def event_emitter_proxy
91
91
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
92
92
  end
@@ -56,12 +56,6 @@ module Playwright
56
56
  wrap_impl(@impl.request)
57
57
  end
58
58
 
59
- # -- inherited from EventEmitter --
60
- # @nodoc
61
- def once(event, callback)
62
- event_emitter_proxy.once(event, callback)
63
- end
64
-
65
59
  # -- inherited from EventEmitter --
66
60
  # @nodoc
67
61
  def on(event, callback)
@@ -74,6 +68,12 @@ module Playwright
74
68
  event_emitter_proxy.off(event, callback)
75
69
  end
76
70
 
71
+ # -- inherited from EventEmitter --
72
+ # @nodoc
73
+ def once(event, callback)
74
+ event_emitter_proxy.once(event, callback)
75
+ end
76
+
77
77
  private def event_emitter_proxy
78
78
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
79
79
  end
@@ -12,12 +12,6 @@ module Playwright
12
12
  wrap_impl(@impl.register(unwrap_impl(name), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path), script: unwrap_impl(script)))
13
13
  end
14
14
 
15
- # -- inherited from EventEmitter --
16
- # @nodoc
17
- def once(event, callback)
18
- event_emitter_proxy.once(event, callback)
19
- end
20
-
21
15
  # -- inherited from EventEmitter --
22
16
  # @nodoc
23
17
  def on(event, callback)
@@ -30,6 +24,12 @@ module Playwright
30
24
  event_emitter_proxy.off(event, callback)
31
25
  end
32
26
 
27
+ # -- inherited from EventEmitter --
28
+ # @nodoc
29
+ def once(event, callback)
30
+ event_emitter_proxy.once(event, callback)
31
+ end
32
+
33
33
  private def event_emitter_proxy
34
34
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
35
35
  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,14 +23,8 @@ 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.')
28
- end
29
-
30
- # -- inherited from EventEmitter --
31
- # @nodoc
32
- def once(event, callback)
33
- event_emitter_proxy.once(event, callback)
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)))
34
28
  end
35
29
 
36
30
  # -- inherited from EventEmitter --
@@ -45,6 +39,12 @@ module Playwright
45
39
  event_emitter_proxy.off(event, callback)
46
40
  end
47
41
 
42
+ # -- inherited from EventEmitter --
43
+ # @nodoc
44
+ def once(event, callback)
45
+ event_emitter_proxy.once(event, callback)
46
+ end
47
+
48
48
  private def event_emitter_proxy
49
49
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
50
50
  end
@@ -43,12 +43,6 @@ module Playwright
43
43
  raise NotImplementedError.new('url is not implemented yet.')
44
44
  end
45
45
 
46
- # -- inherited from EventEmitter --
47
- # @nodoc
48
- def once(event, callback)
49
- event_emitter_proxy.once(event, callback)
50
- end
51
-
52
46
  # -- inherited from EventEmitter --
53
47
  # @nodoc
54
48
  def on(event, callback)
@@ -61,6 +55,12 @@ module Playwright
61
55
  event_emitter_proxy.off(event, callback)
62
56
  end
63
57
 
58
+ # -- inherited from EventEmitter --
59
+ # @nodoc
60
+ def once(event, callback)
61
+ event_emitter_proxy.once(event, callback)
62
+ end
63
+
64
64
  private def event_emitter_proxy
65
65
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
66
66
  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.6
4
+ version: 0.7.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-06-11 00:00:00.000000000 Z
11
+ date: 2021-06-15 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
@@ -231,6 +245,7 @@ files:
231
245
  - documentation/docs/article/guides/launch_browser.md
232
246
  - documentation/docs/article/guides/rails_integration.md
233
247
  - documentation/docs/article/guides/recording_video.md
248
+ - documentation/docs/article/guides/semi_automation.md
234
249
  - documentation/docs/include/api_coverage.md
235
250
  - documentation/docusaurus.config.js
236
251
  - documentation/package.json