playwright-ruby-client 0.0.7 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +38 -3
- data/docs/api_coverage.md +89 -84
- data/lib/playwright.rb +4 -2
- data/lib/playwright/android_input_impl.rb +23 -0
- data/lib/playwright/api_implementation.rb +18 -0
- data/lib/playwright/channel.rb +7 -0
- data/lib/playwright/channel_owner.rb +3 -5
- data/lib/playwright/channel_owners/android.rb +1 -1
- data/lib/playwright/channel_owners/android_device.rb +83 -13
- data/lib/playwright/channel_owners/browser.rb +1 -1
- data/lib/playwright/channel_owners/browser_context.rb +10 -2
- data/lib/playwright/channel_owners/download.rb +27 -0
- data/lib/playwright/channel_owners/element_handle.rb +15 -4
- data/lib/playwright/channel_owners/frame.rb +228 -19
- data/lib/playwright/channel_owners/js_handle.rb +1 -1
- data/lib/playwright/channel_owners/page.rb +350 -27
- data/lib/playwright/channel_owners/request.rb +9 -1
- data/lib/playwright/errors.rb +1 -1
- data/lib/playwright/event_emitter.rb +8 -1
- data/lib/playwright/event_emitter_proxy.rb +49 -0
- data/lib/playwright/file_chooser_impl.rb +23 -0
- data/lib/playwright/http_headers.rb +20 -0
- data/lib/playwright/input_files.rb +1 -1
- data/lib/playwright/javascript/expression.rb +15 -0
- data/lib/playwright/javascript/function.rb +15 -0
- data/lib/playwright/javascript/value_parser.rb +1 -1
- data/lib/playwright/javascript/value_serializer.rb +1 -1
- data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +5 -1
- data/lib/playwright/mouse_impl.rb +7 -0
- data/lib/playwright/playwright_api.rb +59 -20
- data/lib/playwright/select_option_values.rb +14 -4
- data/lib/playwright/timeout_settings.rb +1 -1
- data/lib/playwright/touchscreen_impl.rb +7 -0
- data/lib/playwright/utils.rb +3 -3
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright/wait_helper.rb +1 -1
- data/lib/playwright_api/android.rb +9 -10
- data/lib/playwright_api/android_device.rb +43 -14
- data/lib/playwright_api/android_input.rb +25 -0
- data/lib/playwright_api/binding_call.rb +10 -6
- data/lib/playwright_api/browser.rb +20 -21
- data/lib/playwright_api/browser_context.rb +29 -20
- data/lib/playwright_api/browser_type.rb +16 -56
- data/lib/playwright_api/chromium_browser_context.rb +10 -8
- data/lib/playwright_api/console_message.rb +10 -6
- data/lib/playwright_api/dialog.rb +5 -1
- data/lib/playwright_api/download.rb +28 -11
- data/lib/playwright_api/element_handle.rb +107 -96
- data/lib/playwright_api/file_chooser.rb +17 -9
- data/lib/playwright_api/frame.rb +136 -132
- data/lib/playwright_api/js_handle.rb +18 -20
- data/lib/playwright_api/keyboard.rb +5 -5
- data/lib/playwright_api/page.rb +204 -149
- data/lib/playwright_api/playwright.rb +32 -44
- data/lib/playwright_api/request.rb +7 -8
- data/lib/playwright_api/response.rb +10 -6
- data/lib/playwright_api/selectors.rb +13 -9
- data/lib/playwright_api/web_socket.rb +10 -1
- data/lib/playwright_api/worker.rb +13 -13
- metadata +12 -6
- data/lib/playwright/input_type.rb +0 -19
- data/lib/playwright/input_types/mouse.rb +0 -4
- data/lib/playwright/input_types/touchscreen.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 140f77362280a6874d89ed73fde1e80fa47e2b83f075b6207835f02ab62cb97f
|
4
|
+
data.tar.gz: e715b39c620668eeea1a0dbb022865f759d02f59d2f3d23948c7c20536ca0136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0315d44031788794eca7f506ba9a20a81dbb6bf77c15efda873a1efc3e25074d46e1629ae07551f2dd8368f8a7609568cd719fd1470fdd3bf2717373168655a2
|
7
|
+
data.tar.gz: a3b6a02b60059ac3ef14c0ca1222e3b88a3aaee588b8510c49ef748fab5f27c354417b1e38cc6adfe98e6b1f38805ed1c0cead8cfb465f4968e449c98dd5a9a5
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
[](https://badge.fury.io/rb/playwright-ruby-client)
|
2
2
|
|
3
|
-
#
|
4
|
-
|
5
|
-
A Ruby client for Playwright driver.
|
3
|
+
# 🎭 Playwright client for Ruby
|
6
4
|
|
7
5
|
Note: Currently, this Gem is just a PoC (Proof of Concept). If you want to develop browser-automation for Chrome with Ruby, consider using [puppeteer-ruby](https://github.com/YusukeIwaki/puppeteer-ruby). The list of the available APIs of playwright-ruby-client is [here](./docs/api_coverage.md)
|
8
6
|
|
@@ -17,6 +15,8 @@ npm install playwright
|
|
17
15
|
|
18
16
|
and then, set `playwright_cli_executable_path: ./node_modules/.bin/playwright` at `Playwright.create`.
|
19
17
|
|
18
|
+
**Prefer playwrighting without Node.js?**
|
19
|
+
|
20
20
|
Instead of npm install, you can also directly download playwright driver from playwright.azureedge.net/builds/. The URL can be easily detected from [here](https://github.com/microsoft/playwright-python/blob/79f6ce0a6a69c480573372706df84af5ef99c4a4/setup.py#L56-L61)
|
21
21
|
|
22
22
|
### Capture a site
|
@@ -111,6 +111,41 @@ end
|
|
111
111
|
|
112
112
|

|
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
@@ -43,6 +43,7 @@
|
|
43
43
|
* ~~closed?~~
|
44
44
|
* ~~url~~
|
45
45
|
* ~~expect_event~~
|
46
|
+
* ~~wait_for_event~~
|
46
47
|
|
47
48
|
## Keyboard
|
48
49
|
|
@@ -76,16 +77,14 @@
|
|
76
77
|
|
77
78
|
## ElementHandle
|
78
79
|
|
79
|
-
* query_selector
|
80
|
-
* query_selector_all
|
81
|
-
* eval_on_selector
|
82
|
-
* eval_on_selector_all
|
83
80
|
* bounding_box
|
84
81
|
* check
|
85
82
|
* click
|
86
83
|
* content_frame
|
87
84
|
* dblclick
|
88
85
|
* dispatch_event
|
86
|
+
* eval_on_selector
|
87
|
+
* eval_on_selector_all
|
89
88
|
* fill
|
90
89
|
* focus
|
91
90
|
* get_attribute
|
@@ -100,6 +99,8 @@
|
|
100
99
|
* visible?
|
101
100
|
* owner_frame
|
102
101
|
* press
|
102
|
+
* query_selector
|
103
|
+
* query_selector_all
|
103
104
|
* screenshot
|
104
105
|
* scroll_into_view_if_needed
|
105
106
|
* select_option
|
@@ -116,61 +117,61 @@
|
|
116
117
|
|
117
118
|
* ~~snapshot~~
|
118
119
|
|
119
|
-
##
|
120
|
+
## FileChooser
|
120
121
|
|
121
|
-
*
|
122
|
-
*
|
123
|
-
*
|
124
|
-
*
|
122
|
+
* element
|
123
|
+
* multiple?
|
124
|
+
* page
|
125
|
+
* set_files
|
125
126
|
|
126
127
|
## Frame
|
127
128
|
|
128
|
-
*
|
129
|
-
*
|
130
|
-
*
|
131
|
-
* eval_on_selector_all
|
132
|
-
* ~~add_script_tag~~
|
133
|
-
* ~~add_style_tag~~
|
134
|
-
* ~~check~~
|
129
|
+
* add_script_tag
|
130
|
+
* add_style_tag
|
131
|
+
* check
|
135
132
|
* child_frames
|
136
133
|
* click
|
137
134
|
* content
|
138
135
|
* dblclick
|
139
|
-
*
|
136
|
+
* dispatch_event
|
137
|
+
* eval_on_selector
|
138
|
+
* eval_on_selector_all
|
140
139
|
* evaluate
|
141
140
|
* evaluate_handle
|
142
141
|
* fill
|
143
142
|
* focus
|
144
143
|
* ~~frame_element~~
|
145
|
-
*
|
144
|
+
* get_attribute
|
146
145
|
* goto
|
147
|
-
*
|
148
|
-
*
|
149
|
-
*
|
150
|
-
*
|
151
|
-
*
|
152
|
-
*
|
153
|
-
*
|
154
|
-
*
|
155
|
-
*
|
156
|
-
*
|
146
|
+
* hover
|
147
|
+
* inner_html
|
148
|
+
* inner_text
|
149
|
+
* checked?
|
150
|
+
* detached?
|
151
|
+
* disabled?
|
152
|
+
* editable?
|
153
|
+
* enabled?
|
154
|
+
* hidden?
|
155
|
+
* visible?
|
157
156
|
* name
|
158
157
|
* page
|
159
158
|
* parent_frame
|
160
159
|
* press
|
161
|
-
*
|
160
|
+
* query_selector
|
161
|
+
* query_selector_all
|
162
|
+
* select_option
|
162
163
|
* set_content
|
163
|
-
*
|
164
|
-
*
|
165
|
-
*
|
164
|
+
* set_input_files
|
165
|
+
* tap_point
|
166
|
+
* text_content
|
166
167
|
* title
|
167
168
|
* type
|
168
|
-
*
|
169
|
+
* uncheck
|
169
170
|
* url
|
170
|
-
*
|
171
|
+
* wait_for_function
|
171
172
|
* wait_for_load_state
|
172
173
|
* expect_navigation
|
173
|
-
*
|
174
|
+
* wait_for_selector
|
174
175
|
* ~~wait_for_timeout~~
|
175
176
|
|
176
177
|
## ~~Worker~~
|
@@ -198,15 +199,14 @@
|
|
198
199
|
* ~~message~~
|
199
200
|
* ~~type~~
|
200
201
|
|
201
|
-
##
|
202
|
+
## Download
|
202
203
|
|
203
|
-
*
|
204
|
-
*
|
205
|
-
*
|
206
|
-
*
|
207
|
-
*
|
208
|
-
*
|
209
|
-
* ~~url~~
|
204
|
+
* delete
|
205
|
+
* failure
|
206
|
+
* path
|
207
|
+
* save_as
|
208
|
+
* suggested_filename
|
209
|
+
* url
|
210
210
|
|
211
211
|
## ~~Video~~
|
212
212
|
|
@@ -214,78 +214,84 @@
|
|
214
214
|
|
215
215
|
## Page
|
216
216
|
|
217
|
-
*
|
218
|
-
*
|
219
|
-
*
|
220
|
-
*
|
221
|
-
*
|
222
|
-
* ~~add_script_tag~~
|
223
|
-
* ~~add_style_tag~~
|
224
|
-
* ~~bring_to_front~~
|
225
|
-
* ~~check~~
|
217
|
+
* add_init_script
|
218
|
+
* add_script_tag
|
219
|
+
* add_style_tag
|
220
|
+
* bring_to_front
|
221
|
+
* check
|
226
222
|
* click
|
227
223
|
* close
|
228
224
|
* content
|
229
225
|
* context
|
230
226
|
* dblclick
|
231
|
-
*
|
232
|
-
*
|
227
|
+
* dispatch_event
|
228
|
+
* emulate_media
|
229
|
+
* eval_on_selector
|
230
|
+
* eval_on_selector_all
|
233
231
|
* evaluate
|
234
232
|
* evaluate_handle
|
235
|
-
*
|
236
|
-
*
|
233
|
+
* expose_binding
|
234
|
+
* expose_function
|
237
235
|
* fill
|
238
236
|
* focus
|
239
237
|
* frame
|
240
238
|
* frames
|
241
|
-
*
|
242
|
-
*
|
243
|
-
*
|
239
|
+
* get_attribute
|
240
|
+
* go_back
|
241
|
+
* go_forward
|
244
242
|
* goto
|
245
|
-
*
|
246
|
-
*
|
247
|
-
*
|
248
|
-
*
|
243
|
+
* hover
|
244
|
+
* inner_html
|
245
|
+
* inner_text
|
246
|
+
* checked?
|
249
247
|
* closed?
|
250
|
-
*
|
251
|
-
*
|
252
|
-
*
|
253
|
-
*
|
254
|
-
*
|
248
|
+
* disabled?
|
249
|
+
* editable?
|
250
|
+
* enabled?
|
251
|
+
* hidden?
|
252
|
+
* visible?
|
255
253
|
* main_frame
|
256
254
|
* opener
|
257
|
-
* ~~
|
255
|
+
* ~~pause~~
|
256
|
+
* pdf
|
258
257
|
* press
|
258
|
+
* query_selector
|
259
|
+
* query_selector_all
|
259
260
|
* reload
|
260
261
|
* ~~route~~
|
261
262
|
* screenshot
|
262
|
-
*
|
263
|
+
* select_option
|
263
264
|
* set_content
|
264
|
-
*
|
265
|
-
*
|
266
|
-
*
|
267
|
-
*
|
265
|
+
* set_default_navigation_timeout
|
266
|
+
* set_default_timeout
|
267
|
+
* set_extra_http_headers
|
268
|
+
* set_input_files
|
268
269
|
* set_viewport_size
|
269
|
-
*
|
270
|
-
*
|
270
|
+
* tap_point
|
271
|
+
* text_content
|
271
272
|
* title
|
272
273
|
* type
|
273
|
-
*
|
274
|
+
* uncheck
|
274
275
|
* ~~unroute~~
|
275
276
|
* url
|
276
277
|
* ~~video~~
|
277
278
|
* viewport_size
|
278
279
|
* expect_event
|
279
|
-
*
|
280
|
+
* wait_for_function
|
280
281
|
* wait_for_load_state
|
281
282
|
* expect_navigation
|
282
283
|
* expect_request
|
283
284
|
* expect_response
|
284
|
-
*
|
285
|
+
* wait_for_selector
|
285
286
|
* ~~wait_for_timeout~~
|
286
287
|
* ~~workers~~
|
288
|
+
* expect_download
|
289
|
+
* expect_popup
|
290
|
+
* ~~expect_worker~~
|
291
|
+
* expect_console_message
|
292
|
+
* expect_file_chooser
|
293
|
+
* ~~wait_for_event~~
|
287
294
|
* accessibility
|
288
|
-
* ~~coverage~~
|
289
295
|
* keyboard
|
290
296
|
* mouse
|
291
297
|
* touchscreen
|
@@ -309,11 +315,12 @@
|
|
309
315
|
* ~~set_default_timeout~~
|
310
316
|
* ~~set_extra_http_headers~~
|
311
317
|
* ~~set_geolocation~~
|
312
|
-
* ~~set_http_credentials~~
|
313
318
|
* ~~set_offline~~
|
314
319
|
* ~~storage_state~~
|
315
320
|
* ~~unroute~~
|
316
321
|
* ~~expect_event~~
|
322
|
+
* ~~expect_page~~
|
323
|
+
* ~~wait_for_event~~
|
317
324
|
|
318
325
|
## ~~CDPSession~~
|
319
326
|
|
@@ -337,18 +344,16 @@
|
|
337
344
|
|
338
345
|
## BrowserType
|
339
346
|
|
340
|
-
* ~~connect~~
|
341
347
|
* executable_path
|
342
348
|
* launch
|
343
349
|
* ~~launch_persistent_context~~
|
344
|
-
* ~~launch_server~~
|
345
350
|
* name
|
346
351
|
|
347
352
|
## Playwright
|
348
353
|
|
354
|
+
* ~~stop~~
|
349
355
|
* chromium
|
350
356
|
* devices
|
351
|
-
* ~~errors~~
|
352
357
|
* firefox
|
353
358
|
* ~~selectors~~
|
354
359
|
* webkit
|
data/lib/playwright.rb
CHANGED
@@ -10,13 +10,15 @@ require 'concurrent'
|
|
10
10
|
require 'playwright/errors'
|
11
11
|
require 'playwright/events'
|
12
12
|
require 'playwright/event_emitter'
|
13
|
+
require 'playwright/event_emitter_proxy'
|
13
14
|
require 'playwright/javascript'
|
14
15
|
require 'playwright/utils'
|
15
16
|
|
17
|
+
require 'playwright/api_implementation'
|
16
18
|
require 'playwright/channel'
|
17
19
|
require 'playwright/channel_owner'
|
20
|
+
require 'playwright/http_headers'
|
18
21
|
require 'playwright/input_files'
|
19
|
-
require 'playwright/input_type'
|
20
22
|
require 'playwright/connection'
|
21
23
|
require 'playwright/select_option_values'
|
22
24
|
require 'playwright/timeout_settings'
|
@@ -37,7 +39,7 @@ module Playwright
|
|
37
39
|
|
38
40
|
playwright_promise = connection.async_wait_for_object_with_known_name('Playwright')
|
39
41
|
Thread.new { connection.run }
|
40
|
-
playwright = PlaywrightApi.
|
42
|
+
playwright = PlaywrightApi.wrap(playwright_promise.value!)
|
41
43
|
begin
|
42
44
|
block.call(playwright)
|
43
45
|
ensure
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Playwright
|
2
|
+
define_api_implementation :AndroidInputImpl do
|
3
|
+
def initialize(channel)
|
4
|
+
@channel = channel
|
5
|
+
end
|
6
|
+
|
7
|
+
def type(text)
|
8
|
+
@channel.send_message_to_server('inputType', text: text)
|
9
|
+
end
|
10
|
+
|
11
|
+
def press(key)
|
12
|
+
@channel.send_message_to_server('inputPress', key: key)
|
13
|
+
end
|
14
|
+
|
15
|
+
def tap_point(point)
|
16
|
+
@channel.send_message_to_server('inputTap', point: point)
|
17
|
+
end
|
18
|
+
|
19
|
+
def drag(from, to, steps)
|
20
|
+
@channel.send_message_to_server('inputDrag', from: from, to: to, steps: steps)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Playwright
|
2
|
+
# Each Impl class include this module.
|
3
|
+
# Used for detecting whether the object is a XXXXImpl or not.
|
4
|
+
module ApiImplementation ; end
|
5
|
+
|
6
|
+
def self.define_api_implementation(class_name, &block)
|
7
|
+
klass = Class.new
|
8
|
+
klass.include(ApiImplementation)
|
9
|
+
klass.class_eval(&block) if block
|
10
|
+
if ::Playwright.const_defined?(class_name)
|
11
|
+
raise ArgumentError.new("Playwright::#{class_name} already exist. Choose another class name.")
|
12
|
+
end
|
13
|
+
::Playwright.const_set(class_name, klass)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# load subclasses
|
18
|
+
Dir[File.join(__dir__, '*_impl.rb')].each { |f| require f }
|
data/lib/playwright/channel.rb
CHANGED