playwright-ruby-client 0.0.7 → 0.0.8

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: 14f91dd4519f608e30d71da2f014e9640e99fdbf36eb90f07d34e28d526e66a7
4
- data.tar.gz: 97b9f16880fbd253af2e762e539824e066f43c132e5e6ca609a853bc8a981f33
3
+ metadata.gz: 04f50e523a846e243058cbb53a44e0f4a6ecce32aa843a02ace9b855b2264862
4
+ data.tar.gz: a8c99b7550206d0ff90ad033e0391a9224f780ae1e009a8cab48441070adabaa
5
5
  SHA512:
6
- metadata.gz: 737c326cc321c540f970eaa5e165ce02d012a0fae1491c1b7c6214ffb0285ed5382818f01eca5d05b7dd0541929c5478bc2e66ac84c941eeae3f4f7cbd825b20
7
- data.tar.gz: b4bf7bf326e259ac5f31719076f0541d0a7cffaaf209714c9e344364ebfde9c7493e78a0937955d0af5cbf33b283733bb3ffa713964da677178e764f64662c99
6
+ metadata.gz: d5e089555dc0d1ee2a86980d14d8310e338fa1d23b529a3d711895532dba64101300a198ed55b80f90342116b86baae8937c7526f992bc7ea9816297e385c436
7
+ data.tar.gz: d1da5e4e141043a37f3eccdd300865437264c795e343fa5652534d2fa04168d6f1326f7311c1f8c0212c98fd0d365b5b8f684b18b4b615b8825d5d65fa185562
data/README.md CHANGED
@@ -111,6 +111,41 @@ end
111
111
 
112
112
  ![android-browser](https://user-images.githubusercontent.com/11763113/106615177-8467a800-65af-11eb-94d9-c56e71487e78.gif)
113
113
 
114
+ ### Android native automation
115
+
116
+ We have to download android-driver for Playwright in advance.
117
+
118
+ ```
119
+ wget https://github.com/microsoft/playwright/raw/master/bin/android-driver-target.apk -O /path/to/playwright-driver/package/bin/android-driver-target.apk
120
+ wget https://github.com/microsoft/playwright/raw/master/bin/android-driver.apk -O /path/to/playwright-driver/package/bin/android-driver.apk
121
+ ```
122
+
123
+ (If you downloaded Playwright via npm, replace `/path/to/playwright-driver/package/` with `./node_modules/playwright/` above.)
124
+
125
+ ```ruby
126
+ require 'playwright'
127
+
128
+ Playwright.create(playwright_cli_executable_path: ENV['PLAYWRIGHT_CLI_EXECUTABLE_PATH']) do |playwright|
129
+ devices = playwright.android.devices
130
+ unless devices.empty?
131
+ device = devices.last
132
+ begin
133
+ device.shell('input keyevent POWER')
134
+ device.shell('input keyevent POWER')
135
+ device.shell('input keyevent 82')
136
+ sleep 1
137
+ device.shell('cmd statusbar expand-notifications')
138
+
139
+ # pp device.tree
140
+ # pp device.info(res: 'com.android.systemui:id/clock')
141
+ device.tap_on(res: 'com.android.systemui:id/clock')
142
+ ensure
143
+ device.close
144
+ end
145
+ end
146
+ end
147
+
148
+ ```
114
149
 
115
150
  ## License
116
151
 
data/docs/api_coverage.md CHANGED
@@ -129,45 +129,45 @@
129
129
  * query_selector_all
130
130
  * eval_on_selector
131
131
  * eval_on_selector_all
132
- * ~~add_script_tag~~
133
- * ~~add_style_tag~~
134
- * ~~check~~
132
+ * add_script_tag
133
+ * add_style_tag
134
+ * check
135
135
  * child_frames
136
136
  * click
137
137
  * content
138
138
  * dblclick
139
- * ~~dispatch_event~~
139
+ * dispatch_event
140
140
  * evaluate
141
141
  * evaluate_handle
142
142
  * fill
143
143
  * focus
144
144
  * ~~frame_element~~
145
- * ~~get_attribute~~
145
+ * get_attribute
146
146
  * goto
147
- * ~~hover~~
148
- * ~~inner_html~~
149
- * ~~inner_text~~
150
- * ~~checked?~~
151
- * ~~detached?~~
152
- * ~~disabled?~~
153
- * ~~editable?~~
154
- * ~~enabled?~~
155
- * ~~hidden?~~
156
- * ~~visible?~~
147
+ * hover
148
+ * inner_html
149
+ * inner_text
150
+ * checked?
151
+ * detached?
152
+ * disabled?
153
+ * editable?
154
+ * enabled?
155
+ * hidden?
156
+ * visible?
157
157
  * name
158
158
  * page
159
159
  * parent_frame
160
160
  * press
161
- * ~~select_option~~
161
+ * select_option
162
162
  * set_content
163
- * ~~set_input_files~~
164
- * ~~tap_point~~
165
- * ~~text_content~~
163
+ * set_input_files
164
+ * tap_point
165
+ * text_content
166
166
  * title
167
167
  * type
168
- * ~~uncheck~~
168
+ * uncheck
169
169
  * url
170
- * ~~wait_for_function~~
170
+ * wait_for_function
171
171
  * wait_for_load_state
172
172
  * expect_navigation
173
173
  * ~~wait_for_selector~~
@@ -219,8 +219,8 @@
219
219
  * eval_on_selector
220
220
  * eval_on_selector_all
221
221
  * ~~add_init_script~~
222
- * ~~add_script_tag~~
223
- * ~~add_style_tag~~
222
+ * add_script_tag
223
+ * add_style_tag
224
224
  * ~~bring_to_front~~
225
225
  * ~~check~~
226
226
  * click
@@ -261,8 +261,8 @@
261
261
  * screenshot
262
262
  * ~~select_option~~
263
263
  * set_content
264
- * ~~set_default_navigation_timeout~~
265
- * ~~set_default_timeout~~
264
+ * set_default_navigation_timeout
265
+ * set_default_timeout
266
266
  * ~~set_extra_http_headers~~
267
267
  * ~~set_input_files~~
268
268
  * set_viewport_size
@@ -276,7 +276,7 @@
276
276
  * ~~video~~
277
277
  * viewport_size
278
278
  * expect_event
279
- * ~~wait_for_function~~
279
+ * wait_for_function
280
280
  * wait_for_load_state
281
281
  * expect_navigation
282
282
  * expect_request
@@ -2,6 +2,12 @@ module Playwright
2
2
  define_channel_owner :AndroidDevice do
3
3
  include Utils::PrepareBrowserContextOptions
4
4
 
5
+ def after_initialize
6
+ @input = InputTypes::AndroidInput.new(@channel)
7
+ end
8
+
9
+ attr_reader :input
10
+
5
11
  def serial
6
12
  @initializer['serial']
7
13
  end
@@ -10,9 +16,68 @@ module Playwright
10
16
  @initializer['model']
11
17
  end
12
18
 
13
- def shell(command)
14
- resp = @channel.send_message_to_server('shell', command: command)
15
- Base64.strict_decode64(resp)
19
+ private def to_regex(value)
20
+ case value
21
+ when nil
22
+ nil
23
+ when Regexp
24
+ value
25
+ else
26
+ Regexp.new("^#{value}$")
27
+ end
28
+ end
29
+
30
+ private def to_selector_channel(selector)
31
+ {
32
+ checkable: selector[:checkable],
33
+ checked: selector[:checked],
34
+ clazz: to_regex(selector[:clazz]),
35
+ pkg: to_regex(selector[:pkg]),
36
+ desc: to_regex(selector[:desc]),
37
+ res: to_regex(selector[:res]),
38
+ text: to_regex(selector[:text]),
39
+ clickable: selector[:clickable],
40
+ depth: selector[:depth],
41
+ enabled: selector[:enabled],
42
+ focusable: selector[:focusable],
43
+ focused: selector[:focused],
44
+ hasChild: selector[:hasChild] ? { selector: to_selector_channel(selector[:hasChild][:selector]) } : nil,
45
+ hasDescendant: selector[:hasDescendant] ? {
46
+ selector: to_selector_channel(selector[:hasDescendant][:selector]),
47
+ maxDepth: selector[:hasDescendant][:maxDepth],
48
+ } : nil,
49
+ longClickable: selector[:longClickable],
50
+ scrollable: selector[:scrollable],
51
+ selected: selector[:selected],
52
+ }.compact
53
+ end
54
+
55
+ def tap_on(selector, duration: nil, timeout: nil)
56
+ params = {
57
+ selector: to_selector_channel(selector),
58
+ duration: duration,
59
+ timeout: timeout,
60
+ }.compact
61
+ @channel.send_message_to_server('tap', params)
62
+ end
63
+
64
+ def info(selector)
65
+ @channel.send_message_to_server('info', selector: to_selector_channel(selector))
66
+ end
67
+
68
+ def tree
69
+ @channel.send_message_to_server('tree')
70
+ end
71
+
72
+ def screenshot(path: nil)
73
+ encoded_binary = @channel.send_message_to_server('screenshot')
74
+ decoded_binary = Base64.strict_decode64(encoded_binary)
75
+ if path
76
+ File.open(path, 'wb') do |f|
77
+ f.write(decoded_binary)
78
+ end
79
+ end
80
+ decoded_binary
16
81
  end
17
82
 
18
83
  def close
@@ -20,6 +85,11 @@ module Playwright
20
85
  emit(Events::AndroidDevice::Close)
21
86
  end
22
87
 
88
+ def shell(command)
89
+ resp = @channel.send_message_to_server('shell', command: command)
90
+ Base64.strict_decode64(resp)
91
+ end
92
+
23
93
  def launch_browser(
24
94
  pkg: nil,
25
95
  acceptDownloads: nil,
@@ -144,6 +144,48 @@ module Playwright
144
144
  end
145
145
  end
146
146
 
147
+ def checked?(selector, timeout: nil)
148
+ params = { selector: selector, timeout: timeout }.compact
149
+ @channel.send_message_to_server('isChecked', params)
150
+ end
151
+
152
+ def disabled?(selector, timeout: nil)
153
+ params = { selector: selector, timeout: timeout }.compact
154
+ @channel.send_message_to_server('isDisabled', params)
155
+ end
156
+
157
+ def editable?(selector, timeout: nil)
158
+ params = { selector: selector, timeout: timeout }.compact
159
+ @channel.send_message_to_server('isEditable', params)
160
+ end
161
+
162
+ def enabled?(selector, timeout: nil)
163
+ params = { selector: selector, timeout: timeout }.compact
164
+ @channel.send_message_to_server('isEnabled', params)
165
+ end
166
+
167
+ def hidden?(selector, timeout: nil)
168
+ params = { selector: selector, timeout: timeout }.compact
169
+ @channel.send_message_to_server('isHidden', params)
170
+ end
171
+
172
+ def visible?(selector, timeout: nil)
173
+ params = { selector: selector, timeout: timeout }.compact
174
+ @channel.send_message_to_server('isVisible', params)
175
+ end
176
+
177
+ def dispatch_event(selector, type, eventInit: nil, timeout: nil)
178
+ params = {
179
+ selector: selector,
180
+ type: type,
181
+ eventInit: JavaScript::ValueSerializer.new(eventInit).serialize,
182
+ timeout: timeout,
183
+ }.compact
184
+ @channel.send_message_to_server('dispatchEvent', params)
185
+
186
+ nil
187
+ end
188
+
147
189
  def eval_on_selector(selector, pageFunction, arg: nil)
148
190
  if JavaScript.function?(pageFunction)
149
191
  JavaScript::Function.new(pageFunction, arg).eval_on_selector(@channel, selector)
@@ -176,6 +218,47 @@ module Playwright
176
218
  nil
177
219
  end
178
220
 
221
+ def name
222
+ @name || ''
223
+ end
224
+
225
+ def url
226
+ @url || ''
227
+ end
228
+
229
+ def child_frames
230
+ @child_frames.to_a
231
+ end
232
+
233
+ def detached?
234
+ @detached
235
+ end
236
+
237
+ def add_script_tag(content: nil, path: nil, type: nil, url: nil)
238
+ params = {
239
+ content: content,
240
+ type: type,
241
+ url: url,
242
+ }.compact
243
+ if path
244
+ params[:content] = "#{File.read(path)}\n//# sourceURL=#{path}"
245
+ end
246
+ resp = @channel.send_message_to_server('addScriptTag', params)
247
+ ChannelOwners::ElementHandle.from(resp)
248
+ end
249
+
250
+ def add_style_tag(content: nil, path: nil, url: nil)
251
+ params = {
252
+ content: content,
253
+ url: url,
254
+ }.compact
255
+ if path
256
+ params[:content] = "#{File.read(path)}\n/*# sourceURL=#{path}*/"
257
+ end
258
+ resp = @channel.send_message_to_server('addStyleTag', params)
259
+ ChannelOwners::ElementHandle.from(resp)
260
+ end
261
+
179
262
  def click(
180
263
  selector,
181
264
  button: nil,
@@ -228,6 +311,26 @@ module Playwright
228
311
  nil
229
312
  end
230
313
 
314
+ def tap_point(
315
+ selector,
316
+ force: nil,
317
+ modifiers: nil,
318
+ noWaitAfter: nil,
319
+ position: nil,
320
+ timeout: nil)
321
+ params = {
322
+ selector: selector,
323
+ force: force,
324
+ modifiers: modifiers,
325
+ noWaitAfter: noWaitAfter,
326
+ position: position,
327
+ timeout: timeout,
328
+ }.compact
329
+ @channel.send_message_to_server('tap', params)
330
+
331
+ nil
332
+ end
333
+
231
334
  def fill(selector, value, noWaitAfter: nil, timeout: nil)
232
335
  params = {
233
336
  selector: selector,
@@ -246,12 +349,70 @@ module Playwright
246
349
  nil
247
350
  end
248
351
 
352
+ def text_content(selector, timeout: nil)
353
+ params = { selector: selector, timeout: timeout }.compact
354
+ @channel.send_message_to_server('textContent', params)
355
+ end
356
+
357
+ def inner_text(selector, timeout: nil)
358
+ params = { selector: selector, timeout: timeout }.compact
359
+ @channel.send_message_to_server('innerText', params)
360
+ end
361
+
362
+ def inner_html(selector, timeout: nil)
363
+ params = { selector: selector, timeout: timeout }.compact
364
+ @channel.send_message_to_server('innerHTML', params)
365
+ end
366
+
367
+ def get_attribute(selector, name, timeout: nil)
368
+ params = {
369
+ selector: selector,
370
+ name: name,
371
+ timeout: timeout,
372
+ }.compact
373
+ @channel.send_message_to_server('getAttribute', params)
374
+ end
375
+
376
+ def hover(
377
+ selector,
378
+ force: nil,
379
+ modifiers: nil,
380
+ position: nil,
381
+ timeout: nil)
382
+ params = {
383
+ selector: selector,
384
+ force: force,
385
+ modifiers: modifiers,
386
+ position: position,
387
+ timeout: timeout,
388
+ }.compact
389
+ @channel.send_message_to_server('hover', params)
390
+
391
+ nil
392
+ end
393
+
394
+ def select_option(selector, values, noWaitAfter: nil, timeout: nil)
395
+ base_params = SelectOptionValues.new(values).as_params
396
+ params = base_params + { selector: selector, noWaitAfter: noWaitAfter, timeout: timeout }.compact
397
+ @channel.send_message_to_server('selectOption', params)
398
+
399
+ nil
400
+ end
401
+
402
+ def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
403
+ base_params = InputFiles.new(values).as_params
404
+ params = base_params + { selector: selector, noWaitAfter: noWaitAfter, timeout: timeout }.compact
405
+ @channel.send_message_to_server('setInputFiles', params)
406
+
407
+ nil
408
+ end
409
+
249
410
  def type(
250
- selector,
251
- text,
252
- delay: nil,
253
- noWaitAfter: nil,
254
- timeout: nil)
411
+ selector,
412
+ text,
413
+ delay: nil,
414
+ noWaitAfter: nil,
415
+ timeout: nil)
255
416
 
256
417
  params = {
257
418
  selector: selector,
@@ -260,16 +421,17 @@ module Playwright
260
421
  noWaitAfter: noWaitAfter,
261
422
  timeout: timeout,
262
423
  }.compact
263
-
264
424
  @channel.send_message_to_server('type', params)
425
+
426
+ nil
265
427
  end
266
428
 
267
429
  def press(
268
- selector,
269
- key,
270
- delay: nil,
271
- noWaitAfter: nil,
272
- timeout: nil)
430
+ selector,
431
+ key,
432
+ delay: nil,
433
+ noWaitAfter: nil,
434
+ timeout: nil)
273
435
 
274
436
  params = {
275
437
  selector: selector,
@@ -278,20 +440,48 @@ module Playwright
278
440
  noWaitAfter: noWaitAfter,
279
441
  timeout: timeout,
280
442
  }.compact
281
-
282
443
  @channel.send_message_to_server('press', params)
444
+
445
+ nil
283
446
  end
284
447
 
285
- def name
286
- @name || ''
448
+ def check(selector, force: nil, noWaitAfter: nil, timeout: nil)
449
+ params = {
450
+ selector: selector,
451
+ force: force,
452
+ noWaitAfter: noWaitAfter,
453
+ timeout: timeout,
454
+ }.compact
455
+ @channel.send_message_to_server('check', params)
456
+
457
+ nil
287
458
  end
288
459
 
289
- def url
290
- @url || ''
460
+ def uncheck(selector, force: nil, noWaitAfter: nil, timeout: nil)
461
+ params = {
462
+ selector: selector,
463
+ force: force,
464
+ noWaitAfter: noWaitAfter,
465
+ timeout: timeout,
466
+ }.compact
467
+ @channel.send_message_to_server('uncheck', params)
468
+
469
+ nil
291
470
  end
292
471
 
293
- def child_frames
294
- @child_frames.to_a
472
+ def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
473
+ if polling.is_a?(String) && polling != 'raf'
474
+ raise ArgumentError.new("Unknown polling option: #{polling}")
475
+ end
476
+
477
+ function_or_expression =
478
+ if JavaScript.function?(pageFunction)
479
+ JavaScript::Function.new(pageFunction, arg)
480
+ else
481
+ JavaScript::Expression.new(pageFunction)
482
+ end
483
+
484
+ function_or_expression.wait_for_function(@channel, polling: polling, timeout: timeout)
295
485
  end
296
486
 
297
487
  def title
@@ -103,6 +103,16 @@ module Playwright
103
103
  @frames.to_a
104
104
  end
105
105
 
106
+ def set_default_navigation_timeout(timeout)
107
+ @timeout_settings.default_navigation_timeout = timeout
108
+ @channel.send_message_to_server('setDefaultNavigationTimeoutNoReply', timeout: timeout)
109
+ end
110
+
111
+ def set_default_timeout(timeout)
112
+ @timeout_settings.default_timeout = timeout
113
+ @channel.send_message_to_server('setDefaultTimeoutNoReply', timeout: timeout)
114
+ end
115
+
106
116
  def query_selector(selector)
107
117
  @main_frame.query_selector(selector)
108
118
  end
@@ -127,6 +137,14 @@ module Playwright
127
137
  @main_frame.eval_on_selector_all(selector, pageFunction, arg: arg)
128
138
  end
129
139
 
140
+ def add_script_tag(content: nil, path: nil, type: nil, url: nil)
141
+ @main_frame.add_script_tag(content: content, path: path, type: type, url: url)
142
+ end
143
+
144
+ def add_style_tag(content: nil, path: nil, url: nil)
145
+ @main_frame.add_style_tag(content: content, path: path, url: url)
146
+ end
147
+
130
148
  def url
131
149
  @main_frame.url
132
150
  end
@@ -279,6 +297,10 @@ module Playwright
279
297
  @main_frame.press(selector, key, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout)
280
298
  end
281
299
 
300
+ def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
301
+ @main_frame.wait_for_function(pageFunction, arg: arg, polling: polling, timeout: timeout)
302
+ end
303
+
282
304
  class CrashedError < StandardError
283
305
  def initialize
284
306
  super('Page crashed')
@@ -0,0 +1,19 @@
1
+ module Playwright
2
+ define_input_type :AndroidInput do
3
+ def type(text)
4
+ @channel.send_message_to_server('inputType', text: text)
5
+ end
6
+
7
+ def press(key)
8
+ @channel.send_message_to_server('inputPress', key: key)
9
+ end
10
+
11
+ def tap_point(point)
12
+ @channel.send_message_to_server('inputTap', point: point)
13
+ end
14
+
15
+ def drag(from, to, steps)
16
+ @channel.send_message_to_server('inputDrag', from: from, to: to, steps: steps)
17
+ end
18
+ end
19
+ end
@@ -47,6 +47,21 @@ module Playwright
47
47
  )
48
48
  ValueParser.new(value).parse
49
49
  end
50
+
51
+ def wait_for_function(channel, polling:, timeout:)
52
+ params = {
53
+ expression: @expression,
54
+ isFunction: false,
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
50
65
  end
51
66
  end
52
67
  end
@@ -47,6 +47,21 @@ module Playwright
47
47
  )
48
48
  ValueParser.new(value).parse
49
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
50
65
  end
51
66
  end
52
67
  end
@@ -61,7 +61,7 @@ module Playwright
61
61
  end
62
62
 
63
63
  if hash.key?('o')
64
- return hash['o'].map { |key, value| [key, parse_hash(value)].to_h }
64
+ return hash['o'].map { |obj| [obj['k'], parse_hash(obj['v'])] }.to_h
65
65
  end
66
66
 
67
67
  if hash.key?('h')
@@ -44,7 +44,7 @@ module Playwright
44
44
  when Array
45
45
  { a: value.map { |v| serialize_value(v) } }
46
46
  when Hash
47
- { o: value.map { |key, v| [key, serialize_value(v)] }.to_h }
47
+ { o: value.map { |key, v| { k: key, v: serialize_value(v) } } }
48
48
  else
49
49
  raise ArgumentError.new("Unexpected value: #{value}")
50
50
  end
@@ -13,7 +13,7 @@ module Playwright
13
13
  end
14
14
 
15
15
  def timeout
16
- @default_timeout || @parent&.navigation_timeout || DEFAULT_TIMEOUT
16
+ @default_timeout || @parent&.timeout || DEFAULT_TIMEOUT
17
17
  end
18
18
  end
19
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playwright
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.8'
5
5
  end
@@ -3,13 +3,13 @@ module Playwright
3
3
  class Android < PlaywrightApi
4
4
 
5
5
  # @nodoc
6
- def after_initialize
7
- wrap_impl(@impl.after_initialize)
6
+ def devices
7
+ wrap_impl(@impl.devices)
8
8
  end
9
9
 
10
10
  # @nodoc
11
- def devices
12
- wrap_impl(@impl.devices)
11
+ def after_initialize
12
+ wrap_impl(@impl.after_initialize)
13
13
  end
14
14
 
15
15
  # -- inherited from EventEmitter --
@@ -3,13 +3,28 @@ module Playwright
3
3
  class AndroidDevice < PlaywrightApi
4
4
 
5
5
  # @nodoc
6
- def serial
7
- wrap_impl(@impl.serial)
6
+ def tree
7
+ wrap_impl(@impl.tree)
8
8
  end
9
9
 
10
10
  # @nodoc
11
- def model
12
- wrap_impl(@impl.model)
11
+ def close
12
+ wrap_impl(@impl.close)
13
+ end
14
+
15
+ # @nodoc
16
+ def after_initialize
17
+ wrap_impl(@impl.after_initialize)
18
+ end
19
+
20
+ # @nodoc
21
+ def tap_on(selector, duration: nil, timeout: nil)
22
+ wrap_impl(@impl.tap_on(unwrap_impl(selector), duration: unwrap_impl(duration), timeout: unwrap_impl(timeout)))
23
+ end
24
+
25
+ # @nodoc
26
+ def screenshot(path: nil)
27
+ wrap_impl(@impl.screenshot(path: unwrap_impl(path)))
13
28
  end
14
29
 
15
30
  # @nodoc
@@ -18,8 +33,8 @@ module Playwright
18
33
  end
19
34
 
20
35
  # @nodoc
21
- def close
22
- wrap_impl(@impl.close)
36
+ def input
37
+ wrap_impl(@impl.input)
23
38
  end
24
39
 
25
40
  # @nodoc
@@ -27,6 +42,21 @@ module Playwright
27
42
  wrap_impl(@impl.launch_browser(pkg: unwrap_impl(pkg), acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), logger: unwrap_impl(logger), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), recordHar: unwrap_impl(recordHar), recordVideo: unwrap_impl(recordVideo), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), videoSize: unwrap_impl(videoSize), videosPath: unwrap_impl(videosPath), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
28
43
  end
29
44
 
45
+ # @nodoc
46
+ def info(selector)
47
+ wrap_impl(@impl.info(unwrap_impl(selector)))
48
+ end
49
+
50
+ # @nodoc
51
+ def serial
52
+ wrap_impl(@impl.serial)
53
+ end
54
+
55
+ # @nodoc
56
+ def model
57
+ wrap_impl(@impl.model)
58
+ end
59
+
30
60
  # -- inherited from EventEmitter --
31
61
  # @nodoc
32
62
  def on(event, callback)
@@ -0,0 +1,25 @@
1
+ module Playwright
2
+ # @nodoc
3
+ class AndroidInput < PlaywrightApi
4
+
5
+ # @nodoc
6
+ def type(text)
7
+ wrap_impl(@impl.type(unwrap_impl(text)))
8
+ end
9
+
10
+ # @nodoc
11
+ def tap_point(point)
12
+ wrap_impl(@impl.tap_point(unwrap_impl(point)))
13
+ end
14
+
15
+ # @nodoc
16
+ def press(key)
17
+ wrap_impl(@impl.press(unwrap_impl(key)))
18
+ end
19
+
20
+ # @nodoc
21
+ def drag(from, to, steps)
22
+ wrap_impl(@impl.drag(unwrap_impl(from), unwrap_impl(to), unwrap_impl(steps)))
23
+ end
24
+ end
25
+ end
@@ -572,8 +572,8 @@ module Playwright
572
572
  end
573
573
 
574
574
  # @nodoc
575
- def owner_page=(req)
576
- wrap_impl(@impl.owner_page=(unwrap_impl(req)))
575
+ def browser=(req)
576
+ wrap_impl(@impl.browser=(unwrap_impl(req)))
577
577
  end
578
578
 
579
579
  # @nodoc
@@ -582,8 +582,8 @@ module Playwright
582
582
  end
583
583
 
584
584
  # @nodoc
585
- def browser=(req)
586
- wrap_impl(@impl.browser=(unwrap_impl(req)))
585
+ def owner_page=(req)
586
+ wrap_impl(@impl.owner_page=(unwrap_impl(req)))
587
587
  end
588
588
 
589
589
  # @nodoc
@@ -155,7 +155,7 @@ module Playwright
155
155
  #
156
156
  # Adds a `<script>` tag into the page with the desired url or content.
157
157
  def add_script_tag(content: nil, path: nil, type: nil, url: nil)
158
- raise NotImplementedError.new('add_script_tag is not implemented yet.')
158
+ wrap_impl(@impl.add_script_tag(content: unwrap_impl(content), path: unwrap_impl(path), type: unwrap_impl(type), url: unwrap_impl(url)))
159
159
  end
160
160
 
161
161
  # Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
@@ -163,7 +163,7 @@ module Playwright
163
163
  # Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
164
164
  # content.
165
165
  def add_style_tag(content: nil, path: nil, url: nil)
166
- raise NotImplementedError.new('add_style_tag is not implemented yet.')
166
+ wrap_impl(@impl.add_style_tag(content: unwrap_impl(content), path: unwrap_impl(path), url: unwrap_impl(url)))
167
167
  end
168
168
 
169
169
  # This method checks an element matching `selector` by performing the following steps:
@@ -180,7 +180,7 @@ module Playwright
180
180
  # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
181
181
  # Passing zero timeout disables this.
182
182
  def check(selector, force: nil, noWaitAfter: nil, timeout: nil)
183
- raise NotImplementedError.new('check is not implemented yet.')
183
+ wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
184
184
  end
185
185
 
186
186
  def child_frames
@@ -290,7 +290,7 @@ module Playwright
290
290
  # frame.dispatch_event("#source", "dragstart", { "dataTransfer": data_transfer })
291
291
  # ```
292
292
  def dispatch_event(selector, type, eventInit: nil, timeout: nil)
293
- raise NotImplementedError.new('dispatch_event is not implemented yet.')
293
+ wrap_impl(@impl.dispatch_event(unwrap_impl(selector), unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
294
294
  end
295
295
 
296
296
  # Returns the return value of `pageFunction`
@@ -477,9 +477,8 @@ module Playwright
477
477
 
478
478
  # Returns element attribute value.
479
479
  def get_attribute(selector, name, timeout: nil)
480
- raise NotImplementedError.new('get_attribute is not implemented yet.')
480
+ wrap_impl(@impl.get_attribute(unwrap_impl(selector), unwrap_impl(name), timeout: unwrap_impl(timeout)))
481
481
  end
482
- alias_method :[], :get_attribute
483
482
 
484
483
  # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
485
484
  # last redirect.
@@ -519,52 +518,52 @@ module Playwright
519
518
  modifiers: nil,
520
519
  position: nil,
521
520
  timeout: nil)
522
- raise NotImplementedError.new('hover is not implemented yet.')
521
+ wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
523
522
  end
524
523
 
525
524
  # Returns `element.innerHTML`.
526
525
  def inner_html(selector, timeout: nil)
527
- raise NotImplementedError.new('inner_html is not implemented yet.')
526
+ wrap_impl(@impl.inner_html(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
528
527
  end
529
528
 
530
529
  # Returns `element.innerText`.
531
530
  def inner_text(selector, timeout: nil)
532
- raise NotImplementedError.new('inner_text is not implemented yet.')
531
+ wrap_impl(@impl.inner_text(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
533
532
  end
534
533
 
535
534
  # Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
536
535
  def checked?(selector, timeout: nil)
537
- raise NotImplementedError.new('checked? is not implemented yet.')
536
+ wrap_impl(@impl.checked?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
538
537
  end
539
538
 
540
539
  # Returns `true` if the frame has been detached, or `false` otherwise.
541
540
  def detached?
542
- raise NotImplementedError.new('detached? is not implemented yet.')
541
+ wrap_impl(@impl.detached?)
543
542
  end
544
543
 
545
544
  # Returns whether the element is disabled, the opposite of [enabled](./actionability.md#enabled).
546
545
  def disabled?(selector, timeout: nil)
547
- raise NotImplementedError.new('disabled? is not implemented yet.')
546
+ wrap_impl(@impl.disabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
548
547
  end
549
548
 
550
549
  # Returns whether the element is [editable](./actionability.md#editable).
551
550
  def editable?(selector, timeout: nil)
552
- raise NotImplementedError.new('editable? is not implemented yet.')
551
+ wrap_impl(@impl.editable?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
553
552
  end
554
553
 
555
554
  # Returns whether the element is [enabled](./actionability.md#enabled).
556
555
  def enabled?(selector, timeout: nil)
557
- raise NotImplementedError.new('enabled? is not implemented yet.')
556
+ wrap_impl(@impl.enabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
558
557
  end
559
558
 
560
559
  # Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible).
561
560
  def hidden?(selector, timeout: nil)
562
- raise NotImplementedError.new('hidden? is not implemented yet.')
561
+ wrap_impl(@impl.hidden?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
563
562
  end
564
563
 
565
564
  # Returns whether the element is [visible](./actionability.md#visible).
566
565
  def visible?(selector, timeout: nil)
567
- raise NotImplementedError.new('visible? is not implemented yet.')
566
+ wrap_impl(@impl.visible?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
568
567
  end
569
568
 
570
569
  # Returns frame's name attribute as specified in the tag.
@@ -648,7 +647,7 @@ module Playwright
648
647
  # frame.select_option("select#colors", value=["red", "green", "blue"])
649
648
  # ```
650
649
  def select_option(selector, values, noWaitAfter: nil, timeout: nil)
651
- raise NotImplementedError.new('select_option is not implemented yet.')
650
+ wrap_impl(@impl.select_option(unwrap_impl(selector), unwrap_impl(values), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
652
651
  end
653
652
 
654
653
  def set_content(html, timeout: nil, waitUntil: nil)
@@ -662,7 +661,7 @@ module Playwright
662
661
  # Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
663
662
  # are resolved relative to the the current working directory. For empty array, clears the selected files.
664
663
  def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
665
- raise NotImplementedError.new('set_input_files is not implemented yet.')
664
+ wrap_impl(@impl.set_input_files(unwrap_impl(selector), unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
666
665
  end
667
666
 
668
667
  # This method taps an element matching `selector` by performing the following steps:
@@ -684,12 +683,12 @@ module Playwright
684
683
  noWaitAfter: nil,
685
684
  position: nil,
686
685
  timeout: nil)
687
- raise NotImplementedError.new('tap_point is not implemented yet.')
686
+ wrap_impl(@impl.tap_point(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
688
687
  end
689
688
 
690
689
  # Returns `element.textContent`.
691
690
  def text_content(selector, timeout: nil)
692
- raise NotImplementedError.new('text_content is not implemented yet.')
691
+ wrap_impl(@impl.text_content(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
693
692
  end
694
693
 
695
694
  # Returns the page title.
@@ -740,7 +739,7 @@ module Playwright
740
739
  # When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`.
741
740
  # Passing zero timeout disables this.
742
741
  def uncheck(selector, force: nil, noWaitAfter: nil, timeout: nil)
743
- raise NotImplementedError.new('uncheck is not implemented yet.')
742
+ wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
744
743
  end
745
744
 
746
745
  # Returns frame's url.
@@ -817,7 +816,7 @@ module Playwright
817
816
  # frame.wait_for_function("selector => !!document.querySelector(selector)", selector)
818
817
  # ```
819
818
  def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
820
- raise NotImplementedError.new('wait_for_function is not implemented yet.')
819
+ wrap_impl(@impl.wait_for_function(unwrap_impl(pageFunction), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
821
820
  end
822
821
 
823
822
  # Waits for the required load state to be reached.
@@ -951,13 +950,13 @@ module Playwright
951
950
  end
952
951
 
953
952
  # @nodoc
954
- def after_initialize
955
- wrap_impl(@impl.after_initialize)
953
+ def detached=(req)
954
+ wrap_impl(@impl.detached=(unwrap_impl(req)))
956
955
  end
957
956
 
958
957
  # @nodoc
959
- def detached=(req)
960
- wrap_impl(@impl.detached=(unwrap_impl(req)))
958
+ def after_initialize
959
+ wrap_impl(@impl.after_initialize)
961
960
  end
962
961
 
963
962
  # -- inherited from EventEmitter --
@@ -229,7 +229,7 @@ module Playwright
229
229
  #
230
230
  # Shortcut for main frame's [`method: Frame.addScriptTag`].
231
231
  def add_script_tag(content: nil, path: nil, type: nil, url: nil)
232
- raise NotImplementedError.new('add_script_tag is not implemented yet.')
232
+ wrap_impl(@impl.add_script_tag(content: unwrap_impl(content), path: unwrap_impl(path), type: unwrap_impl(type), url: unwrap_impl(url)))
233
233
  end
234
234
 
235
235
  # Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
@@ -237,7 +237,7 @@ module Playwright
237
237
  #
238
238
  # Shortcut for main frame's [`method: Frame.addStyleTag`].
239
239
  def add_style_tag(content: nil, path: nil, url: nil)
240
- raise NotImplementedError.new('add_style_tag is not implemented yet.')
240
+ wrap_impl(@impl.add_style_tag(content: unwrap_impl(content), path: unwrap_impl(path), url: unwrap_impl(url)))
241
241
  end
242
242
 
243
243
  # Brings page to front (activates tab).
@@ -909,7 +909,6 @@ module Playwright
909
909
  def get_attribute(selector, name, timeout: nil)
910
910
  raise NotImplementedError.new('get_attribute is not implemented yet.')
911
911
  end
912
- alias_method :[], :get_attribute
913
912
 
914
913
  # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
915
914
  # last redirect. If can not go back, returns `null`.
@@ -1308,7 +1307,7 @@ module Playwright
1308
1307
  # > NOTE: [`method: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout`],
1309
1308
  # [`method: BrowserContext.setDefaultTimeout`] and [`method: BrowserContext.setDefaultNavigationTimeout`].
1310
1309
  def set_default_navigation_timeout(timeout)
1311
- raise NotImplementedError.new('set_default_navigation_timeout is not implemented yet.')
1310
+ wrap_impl(@impl.set_default_navigation_timeout(unwrap_impl(timeout)))
1312
1311
  end
1313
1312
  alias_method :default_navigation_timeout=, :set_default_navigation_timeout
1314
1313
 
@@ -1316,7 +1315,7 @@ module Playwright
1316
1315
  #
1317
1316
  # > NOTE: [`method: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout`].
1318
1317
  def set_default_timeout(timeout)
1319
- raise NotImplementedError.new('set_default_timeout is not implemented yet.')
1318
+ wrap_impl(@impl.set_default_timeout(unwrap_impl(timeout)))
1320
1319
  end
1321
1320
  alias_method :default_timeout=, :set_default_timeout
1322
1321
 
@@ -1569,7 +1568,7 @@ module Playwright
1569
1568
  #
1570
1569
  # Shortcut for main frame's [`method: Frame.waitForFunction`].
1571
1570
  def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
1572
- raise NotImplementedError.new('wait_for_function is not implemented yet.')
1571
+ wrap_impl(@impl.wait_for_function(unwrap_impl(pageFunction), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
1573
1572
  end
1574
1573
 
1575
1574
  # Returns when the required load state has been reached.
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-07 00:00:00.000000000 Z
11
+ date: 2021-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -209,6 +209,7 @@ files:
209
209
  - lib/playwright/events.rb
210
210
  - lib/playwright/input_files.rb
211
211
  - lib/playwright/input_type.rb
212
+ - lib/playwright/input_types/android_input.rb
212
213
  - lib/playwright/input_types/keyboard.rb
213
214
  - lib/playwright/input_types/mouse.rb
214
215
  - lib/playwright/input_types/touchscreen.rb
@@ -228,6 +229,7 @@ files:
228
229
  - lib/playwright_api/accessibility.rb
229
230
  - lib/playwright_api/android.rb
230
231
  - lib/playwright_api/android_device.rb
232
+ - lib/playwright_api/android_input.rb
231
233
  - lib/playwright_api/binding_call.rb
232
234
  - lib/playwright_api/browser.rb
233
235
  - lib/playwright_api/browser_context.rb