playwright-ruby-client 0.5.2 → 0.5.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8979977d78ed7f62007ac6049ccf50a4c865093ac0d4c8828a8f8b8fdd69beef
4
- data.tar.gz: 20346e5f5a373b49441c81a1fc77cc15ed0afb3bd47479e7cb6e545935fb7dfa
3
+ metadata.gz: 66cf08a96bb2b41f99fdfcaa8880785ba08afb7287c9d98199d9312812d93362
4
+ data.tar.gz: b7ee7d9db9f28a6752f20e935825412a7bf088e2c138f3ea5b985f114bf6e66d
5
5
  SHA512:
6
- metadata.gz: f74fc9b91dccf461603ef6be94c7dbb6aae4899f7246fb4db1456018cc16c9e4fc63d6bf8c9912623b69d20d2901fcd5aab6e128638afc799fa20caac989ddaf
7
- data.tar.gz: f25f60d3d258fc5fa3592201a45e46e6b111a8508b4493c4308a206d4b33f7909925a1b8760e433a2b7139223e7670b4c9fa0474eccfc3ec2bf2c46061af04b4
6
+ metadata.gz: c50508317e8468f6cea658190b6b199f889777b8fcf6e0e7c208fb4e6574e122c0337562c4a8fec03a779750569ba54fa502ca85b71e8491a335cd7ae21e37b7
7
+ data.tar.gz: 035fff2a09a49a95b28ebfed67b13842c4baf54021613af9a3efc5b0da99198c28bed559d8e6724dd15ede4dd99dd19509ef44f05640e8c090acba9539b5be31
@@ -82,7 +82,7 @@ module Playwright
82
82
  modifiers: modifiers,
83
83
  position: position,
84
84
  timeout: timeout,
85
- }
85
+ }.compact
86
86
  @channel.send_message_to_server('hover', params)
87
87
 
88
88
  nil
@@ -149,10 +149,8 @@ module Playwright
149
149
  value: value,
150
150
  label: label,
151
151
  ).as_params
152
- params = base_params + { noWaitAfter: noWaitAfter, timeout: timeout }.compact
152
+ params = base_params.merge({ noWaitAfter: noWaitAfter, timeout: timeout }.compact)
153
153
  @channel.send_message_to_server('selectOption', params)
154
-
155
- nil
156
154
  end
157
155
 
158
156
  def tap_point(
@@ -230,10 +228,11 @@ module Playwright
230
228
  nil
231
229
  end
232
230
 
233
- def check(force: nil, noWaitAfter: nil, timeout: nil)
231
+ def check(force: nil, noWaitAfter: nil, position: nil, timeout: nil)
234
232
  params = {
235
233
  force: force,
236
234
  noWaitAfter: noWaitAfter,
235
+ position: position,
237
236
  timeout: timeout,
238
237
  }.compact
239
238
  @channel.send_message_to_server('check', params)
@@ -241,10 +240,11 @@ module Playwright
241
240
  nil
242
241
  end
243
242
 
244
- def uncheck(force: nil, noWaitAfter: nil, timeout: nil)
243
+ def uncheck(force: nil, noWaitAfter: nil, position: nil, timeout: nil)
245
244
  params = {
246
245
  force: force,
247
246
  noWaitAfter: noWaitAfter,
247
+ position: position,
248
248
  timeout: timeout,
249
249
  }.compact
250
250
  @channel.send_message_to_server('uncheck', params)
@@ -421,10 +421,8 @@ module Playwright
421
421
  value: value,
422
422
  label: label,
423
423
  ).as_params
424
- params = base_params + { selector: selector, noWaitAfter: noWaitAfter, timeout: timeout }.compact
424
+ params = base_params.merge({ selector: selector, noWaitAfter: noWaitAfter, timeout: timeout }.compact)
425
425
  @channel.send_message_to_server('selectOption', params)
426
-
427
- nil
428
426
  end
429
427
 
430
428
  def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
@@ -798,5 +798,11 @@ module Playwright
798
798
  private def has_bindings?(name)
799
799
  @bindings.key?(name)
800
800
  end
801
+
802
+ # Expose guid for library developers.
803
+ # Not intended to be used by users.
804
+ def guid
805
+ @guid
806
+ end
801
807
  end
802
808
  end
@@ -14,7 +14,7 @@ module Playwright
14
14
  when ApiImplementation
15
15
  ApiImplementationWrapper.new(channel_owner_or_api_implementation).wrap
16
16
  else
17
- nil
17
+ channel_owner_or_api_implementation
18
18
  end
19
19
  end
20
20
 
@@ -119,12 +119,14 @@ module Playwright
119
119
  if object.is_a?(Array)
120
120
  object.map { |obj| wrap_impl(obj) }
121
121
  else
122
- ::Playwright::PlaywrightApi.wrap(object) || object
122
+ ::Playwright::PlaywrightApi.wrap(object)
123
123
  end
124
124
  end
125
125
 
126
126
  private def unwrap_impl(object)
127
- if object.is_a?(PlaywrightApi)
127
+ if object.is_a?(Array)
128
+ object.map { |obj| unwrap_impl(obj) }
129
+ elsif object.is_a?(PlaywrightApi)
128
130
  object.instance_variable_get(:@impl)
129
131
  else
130
132
  object
@@ -1,18 +1,30 @@
1
1
  module Playwright
2
2
  class SelectOptionValues
3
3
  def initialize(element: nil, index: nil, value: nil, label: nil)
4
- @params =
5
- if element
6
- convert(elmeent)
7
- elsif index
8
- convert(index)
9
- elsif value
10
- convert(value)
11
- elsif label
12
- convert(label)
13
- else
14
- {}
15
- end
4
+ params = {}
5
+
6
+ options = []
7
+ if value
8
+ options.concat(convert(:value, value))
9
+ end
10
+
11
+ if index
12
+ options.concat(convert(:index, index))
13
+ end
14
+
15
+ if label
16
+ options.concat(convert(:label, label))
17
+ end
18
+
19
+ unless options.empty?
20
+ params[:options] = options
21
+ end
22
+
23
+ if element
24
+ params[:elements] = convert(:element, element)
25
+ end
26
+
27
+ @params = params
16
28
  end
17
29
 
18
30
  # @return [Hash]
@@ -20,22 +32,19 @@ module Playwright
20
32
  @params
21
33
  end
22
34
 
23
- private def convert(values)
24
- return convert([values]) unless values.is_a?(Enumerable)
25
- return {} if values.empty?
35
+ private def convert(key, values)
36
+ return convert(key, [values]) unless values.is_a?(Enumerable)
37
+ return [] if values.empty?
26
38
  values.each_with_index do |value, index|
27
- unless values
39
+ unless value
28
40
  raise ArgumentError.new("options[#{index}]: expected object, got null")
29
41
  end
30
42
  end
31
43
 
32
- case values.first
33
- when ElementHandle
34
- { elements: values.map(&:channel) }
35
- when String
36
- { options: values.map { |value| { value: value } } }
44
+ if key == :element
45
+ values.map(&:channel)
37
46
  else
38
- { options: values }
47
+ values.map { |value| { key => value } }
39
48
  end
40
49
  end
41
50
  end
@@ -30,10 +30,10 @@ module Playwright
30
30
  debug_send_message(message) if @debug
31
31
  msg = JSON.dump(message)
32
32
  @mutex.synchronize {
33
- @stdin.write([msg.size].pack('V')) # unsigned 32bit, little endian
34
- @stdin.write(msg)
33
+ @stdin.write([msg.bytes.length].pack('V')) # unsigned 32bit, little endian, real byte size instead of chars
34
+ @stdin.write(msg) # write UTF-8 in binary mode as byte stream
35
35
  }
36
- rescue Errno::EPIPE
36
+ rescue Errno::EPIPE, IOError
37
37
  raise AlreadyDisconnectedError.new('send_message failed')
38
38
  end
39
39
 
@@ -48,6 +48,7 @@ module Playwright
48
48
  # @note This method blocks until playwright-cli exited. Consider using Thread or Future.
49
49
  def async_run
50
50
  @stdin, @stdout, @stderr, @thread = Open3.popen3("#{@driver_executable_path} run-driver")
51
+ @stdin.binmode # Ensure Strings are written 1:1 without encoding conversion, necessary for integer values
51
52
 
52
53
  Thread.new { handle_stdout }
53
54
  Thread.new { handle_stderr }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playwright
4
- VERSION = '0.5.2'
4
+ VERSION = '0.5.7'
5
5
  end
@@ -730,23 +730,23 @@ module Playwright
730
730
  end
731
731
 
732
732
  # @nodoc
733
- def options=(req)
734
- wrap_impl(@impl.options=(unwrap_impl(req)))
733
+ def browser=(req)
734
+ wrap_impl(@impl.browser=(unwrap_impl(req)))
735
735
  end
736
736
 
737
737
  # @nodoc
738
- def browser=(req)
739
- wrap_impl(@impl.browser=(unwrap_impl(req)))
738
+ def owner_page=(req)
739
+ wrap_impl(@impl.owner_page=(unwrap_impl(req)))
740
740
  end
741
741
 
742
742
  # @nodoc
743
- def pause
744
- wrap_impl(@impl.pause)
743
+ def options=(req)
744
+ wrap_impl(@impl.options=(unwrap_impl(req)))
745
745
  end
746
746
 
747
747
  # @nodoc
748
- def owner_page=(req)
749
- wrap_impl(@impl.owner_page=(unwrap_impl(req)))
748
+ def pause
749
+ wrap_impl(@impl.pause)
750
750
  end
751
751
 
752
752
  # -- inherited from EventEmitter --
@@ -2268,6 +2268,11 @@ module Playwright
2268
2268
  raise NotImplementedError.new('wait_for_event is not implemented yet.')
2269
2269
  end
2270
2270
 
2271
+ # @nodoc
2272
+ def owned_context=(req)
2273
+ wrap_impl(@impl.owned_context=(unwrap_impl(req)))
2274
+ end
2275
+
2271
2276
  # @nodoc
2272
2277
  def start_js_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
2273
2278
  wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
@@ -2289,8 +2294,8 @@ module Playwright
2289
2294
  end
2290
2295
 
2291
2296
  # @nodoc
2292
- def owned_context=(req)
2293
- wrap_impl(@impl.owned_context=(unwrap_impl(req)))
2297
+ def guid
2298
+ wrap_impl(@impl.guid)
2294
2299
  end
2295
2300
 
2296
2301
  # -- inherited from EventEmitter --
@@ -60,13 +60,13 @@ module Playwright
60
60
  end
61
61
 
62
62
  # @nodoc
63
- def after_initialize
64
- wrap_impl(@impl.after_initialize)
63
+ def ok?
64
+ wrap_impl(@impl.ok?)
65
65
  end
66
66
 
67
67
  # @nodoc
68
- def ok?
69
- wrap_impl(@impl.ok?)
68
+ def after_initialize
69
+ wrap_impl(@impl.after_initialize)
70
70
  end
71
71
 
72
72
  # -- 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.5.2
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-28 00:00:00.000000000 Z
11
+ date: 2021-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby