playwright-ruby-client 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +79 -2
  3. data/docs/api_coverage.md +354 -0
  4. data/lib/playwright.rb +2 -0
  5. data/lib/playwright/channel_owner.rb +3 -2
  6. data/lib/playwright/channel_owners/android.rb +10 -1
  7. data/lib/playwright/channel_owners/android_device.rb +93 -0
  8. data/lib/playwright/channel_owners/browser.rb +13 -13
  9. data/lib/playwright/channel_owners/element_handle.rb +232 -1
  10. data/lib/playwright/channel_owners/frame.rb +41 -3
  11. data/lib/playwright/channel_owners/js_handle.rb +51 -0
  12. data/lib/playwright/channel_owners/page.rb +48 -10
  13. data/lib/playwright/channel_owners/webkit_browser.rb +1 -1
  14. data/lib/playwright/connection.rb +9 -6
  15. data/lib/playwright/errors.rb +1 -1
  16. data/lib/playwright/input_files.rb +42 -0
  17. data/lib/playwright/input_types/keyboard.rb +1 -1
  18. data/lib/playwright/javascript/value_serializer.rb +11 -11
  19. data/lib/playwright/playwright_api.rb +8 -0
  20. data/lib/playwright/select_option_values.rb +32 -0
  21. data/lib/playwright/utils.rb +18 -0
  22. data/lib/playwright/version.rb +1 -1
  23. data/lib/playwright_api/android.rb +33 -0
  24. data/lib/playwright_api/android_device.rb +48 -0
  25. data/lib/playwright_api/binding_call.rb +3 -3
  26. data/lib/playwright_api/browser.rb +7 -6
  27. data/lib/playwright_api/browser_context.rb +6 -6
  28. data/lib/playwright_api/browser_type.rb +4 -4
  29. data/lib/playwright_api/chromium_browser_context.rb +3 -3
  30. data/lib/playwright_api/console_message.rb +3 -8
  31. data/lib/playwright_api/dialog.rb +2 -2
  32. data/lib/playwright_api/element_handle.rb +40 -39
  33. data/lib/playwright_api/frame.rb +23 -27
  34. data/lib/playwright_api/js_handle.rb +15 -9
  35. data/lib/playwright_api/keyboard.rb +6 -6
  36. data/lib/playwright_api/page.rb +35 -54
  37. data/lib/playwright_api/playwright.rb +7 -7
  38. data/lib/playwright_api/request.rb +3 -3
  39. data/lib/playwright_api/response.rb +3 -3
  40. data/lib/playwright_api/selectors.rb +3 -3
  41. data/playwright.gemspec +1 -0
  42. metadata +22 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 243ef6d83fffde209cb8effe291c49b80fb90f7fd1fab7dacd451a524793f78a
4
- data.tar.gz: 877db73a65179e2409423c73aa1fdf72b0da40ebe2d44bf22bce34533c438c98
3
+ metadata.gz: 14f91dd4519f608e30d71da2f014e9640e99fdbf36eb90f07d34e28d526e66a7
4
+ data.tar.gz: 97b9f16880fbd253af2e762e539824e066f43c132e5e6ca609a853bc8a981f33
5
5
  SHA512:
6
- metadata.gz: 01ea7a14404c07a54acd5112ad3704ce0d00ccd562061cbf46b0ec190c26ff0df850c613cddde6ff2d922de390063d6398a02a33f44fad88dd6d5d6ab1918893
7
- data.tar.gz: 5e965b61082503371431d72a8b243c6212d5d2f3b6a232d62faf6fed2c85a920c041e259ea8f2d646722bf9e14eb4fcefebc9f40e86dca3a8ec2aa931c63d95b
6
+ metadata.gz: 737c326cc321c540f970eaa5e165ce02d012a0fae1491c1b7c6214ffb0285ed5382818f01eca5d05b7dd0541929c5478bc2e66ac84c941eeae3f4f7cbd825b20
7
+ data.tar.gz: b4bf7bf326e259ac5f31719076f0541d0a7cffaaf209714c9e344364ebfde9c7493e78a0937955d0af5cbf33b283733bb3ffa713964da677178e764f64662c99
data/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  A Ruby client for Playwright driver.
6
6
 
7
- 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)
7
+ 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
8
 
9
9
  ## Getting Started
10
10
 
11
- At this point, playwright-ruby-client doesn't include the downloader of playwright driver, so **we have to install [playwright CLI](https://github.com/microsoft/playwright-cli) in advance**.
11
+ At this point, playwright-ruby-client doesn't include the downloader of playwright driver, so **we have to install [playwright](https://github.com/microsoft/playwright) in advance**.
12
12
 
13
13
  ```sh
14
14
  npm install playwright
@@ -35,6 +35,83 @@ end
35
35
 
36
36
  ![image](https://user-images.githubusercontent.com/11763113/104339718-412f9180-553b-11eb-9116-908e1e4b5186.gif)
37
37
 
38
+ ### Simple scraping
39
+
40
+ ```ruby
41
+ require 'playwright'
42
+
43
+ Playwright.create(playwright_cli_executable_path: './node_modules/.bin/playwright') do |playwright|
44
+ playwright.chromium.launch(headless: false) do |browser|
45
+ page = browser.new_page
46
+ page.goto('https://github.com/')
47
+
48
+ form = page.query_selector("form.js-site-search-form")
49
+ search_input = form.query_selector("input.header-search-input")
50
+ search_input.click
51
+ page.keyboard.type("playwright")
52
+ page.expect_navigation {
53
+ page.keyboard.press("Enter")
54
+ }
55
+
56
+ list = page.query_selector("ul.repo-list")
57
+ items = list.query_selector_all("div.f4")
58
+ items.each do |item|
59
+ title = item.eval_on_selector("a", "a => a.innerText")
60
+ puts("==> #{title}")
61
+ end
62
+ end
63
+ end
64
+ ```
65
+
66
+ ```sh
67
+ $ bundle exec ruby main.rb
68
+ ==> microsoft/playwright
69
+ ==> microsoft/playwright-python
70
+ ==> microsoft/playwright-cli
71
+ ==> checkly/headless-recorder
72
+ ==> microsoft/playwright-sharp
73
+ ==> playwright-community/jest-playwright
74
+ ==> microsoft/playwright-test
75
+ ==> mxschmitt/playwright-go
76
+ ==> microsoft/playwright-java
77
+ ==> MarketSquare/robotframework-browser
78
+ ```
79
+
80
+ ### Android browser automation
81
+
82
+ ```ruby
83
+ require 'playwright'
84
+
85
+ Playwright.create(playwright_cli_executable_path: './node_modules/.bin/playwright') do |playwright|
86
+ devices = playwright.android.devices
87
+ unless devices.empty?
88
+ device = devices.last
89
+ begin
90
+ puts "Model: #{device.model}"
91
+ puts "Serial: #{device.serial}"
92
+ puts device.shell('ls /system')
93
+
94
+ device.launch_browser do |context|
95
+ page = context.pages.first
96
+ page.goto('https://github.com/YusukeIwaki')
97
+ page.click('header button')
98
+ page.click('input[name="q"]')
99
+ page.keyboard.type('puppeteer')
100
+ page.expect_navigation {
101
+ page.keyboard.press('Enter')
102
+ }
103
+ page.screenshot(path: 'YusukeIwaki.android.png')
104
+ end
105
+ ensure
106
+ device.close
107
+ end
108
+ end
109
+ end
110
+ ```
111
+
112
+ ![android-browser](https://user-images.githubusercontent.com/11763113/106615177-8467a800-65af-11eb-94d9-c56e71487e78.gif)
113
+
114
+
38
115
  ## License
39
116
 
40
117
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,354 @@
1
+ # API coverages
2
+
3
+ ## Request
4
+
5
+ * failure
6
+ * frame
7
+ * headers
8
+ * navigation_request?
9
+ * method
10
+ * post_data
11
+ * post_data_buffer
12
+ * post_data_json
13
+ * redirected_from
14
+ * redirected_to
15
+ * resource_type
16
+ * response
17
+ * timing
18
+ * url
19
+
20
+ ## Response
21
+
22
+ * ~~body~~
23
+ * ~~finished~~
24
+ * ~~frame~~
25
+ * ~~headers~~
26
+ * ~~json~~
27
+ * ~~ok~~
28
+ * ~~request~~
29
+ * ~~status~~
30
+ * ~~status_text~~
31
+ * ~~text~~
32
+ * ~~url~~
33
+
34
+ ## ~~Route~~
35
+
36
+ * ~~abort~~
37
+ * ~~continue_~~
38
+ * ~~fulfill~~
39
+ * ~~request~~
40
+
41
+ ## ~~WebSocket~~
42
+
43
+ * ~~closed?~~
44
+ * ~~url~~
45
+ * ~~expect_event~~
46
+
47
+ ## Keyboard
48
+
49
+ * down
50
+ * insert_text
51
+ * press
52
+ * type
53
+ * up
54
+
55
+ ## Mouse
56
+
57
+ * ~~click~~
58
+ * ~~dblclick~~
59
+ * ~~down~~
60
+ * ~~move~~
61
+ * ~~up~~
62
+
63
+ ## Touchscreen
64
+
65
+ * ~~tap_point~~
66
+
67
+ ## JSHandle
68
+
69
+ * as_element
70
+ * dispose
71
+ * evaluate
72
+ * evaluate_handle
73
+ * get_properties
74
+ * get_property
75
+ * json_value
76
+
77
+ ## ElementHandle
78
+
79
+ * query_selector
80
+ * query_selector_all
81
+ * eval_on_selector
82
+ * eval_on_selector_all
83
+ * bounding_box
84
+ * check
85
+ * click
86
+ * content_frame
87
+ * dblclick
88
+ * dispatch_event
89
+ * fill
90
+ * focus
91
+ * get_attribute
92
+ * hover
93
+ * inner_html
94
+ * inner_text
95
+ * checked?
96
+ * disabled?
97
+ * editable?
98
+ * enabled?
99
+ * hidden?
100
+ * visible?
101
+ * owner_frame
102
+ * press
103
+ * screenshot
104
+ * scroll_into_view_if_needed
105
+ * select_option
106
+ * select_text
107
+ * set_input_files
108
+ * tap_point
109
+ * text_content
110
+ * type
111
+ * uncheck
112
+ * wait_for_element_state
113
+ * wait_for_selector
114
+
115
+ ## ~~Accessibility~~
116
+
117
+ * ~~snapshot~~
118
+
119
+ ## ~~FileChooser~~
120
+
121
+ * ~~element~~
122
+ * ~~multiple?~~
123
+ * ~~page~~
124
+ * ~~set_files~~
125
+
126
+ ## Frame
127
+
128
+ * query_selector
129
+ * query_selector_all
130
+ * eval_on_selector
131
+ * eval_on_selector_all
132
+ * ~~add_script_tag~~
133
+ * ~~add_style_tag~~
134
+ * ~~check~~
135
+ * child_frames
136
+ * click
137
+ * content
138
+ * dblclick
139
+ * ~~dispatch_event~~
140
+ * evaluate
141
+ * evaluate_handle
142
+ * fill
143
+ * focus
144
+ * ~~frame_element~~
145
+ * ~~get_attribute~~
146
+ * goto
147
+ * ~~hover~~
148
+ * ~~inner_html~~
149
+ * ~~inner_text~~
150
+ * ~~checked?~~
151
+ * ~~detached?~~
152
+ * ~~disabled?~~
153
+ * ~~editable?~~
154
+ * ~~enabled?~~
155
+ * ~~hidden?~~
156
+ * ~~visible?~~
157
+ * name
158
+ * page
159
+ * parent_frame
160
+ * press
161
+ * ~~select_option~~
162
+ * set_content
163
+ * ~~set_input_files~~
164
+ * ~~tap_point~~
165
+ * ~~text_content~~
166
+ * title
167
+ * type
168
+ * ~~uncheck~~
169
+ * url
170
+ * ~~wait_for_function~~
171
+ * wait_for_load_state
172
+ * expect_navigation
173
+ * ~~wait_for_selector~~
174
+ * ~~wait_for_timeout~~
175
+
176
+ ## ~~Worker~~
177
+
178
+ * ~~evaluate~~
179
+ * ~~evaluate_handle~~
180
+ * ~~url~~
181
+
182
+ ## Selectors
183
+
184
+ * ~~register~~
185
+
186
+ ## ConsoleMessage
187
+
188
+ * args
189
+ * location
190
+ * text
191
+ * type
192
+
193
+ ## ~~Dialog~~
194
+
195
+ * ~~accept~~
196
+ * ~~default_value~~
197
+ * ~~dismiss~~
198
+ * ~~message~~
199
+ * ~~type~~
200
+
201
+ ## ~~Download~~
202
+
203
+ * ~~create_read_stream~~
204
+ * ~~delete~~
205
+ * ~~failure~~
206
+ * ~~path~~
207
+ * ~~save_as~~
208
+ * ~~suggested_filename~~
209
+ * ~~url~~
210
+
211
+ ## ~~Video~~
212
+
213
+ * ~~path~~
214
+
215
+ ## Page
216
+
217
+ * query_selector
218
+ * query_selector_all
219
+ * eval_on_selector
220
+ * eval_on_selector_all
221
+ * ~~add_init_script~~
222
+ * ~~add_script_tag~~
223
+ * ~~add_style_tag~~
224
+ * ~~bring_to_front~~
225
+ * ~~check~~
226
+ * click
227
+ * close
228
+ * content
229
+ * context
230
+ * dblclick
231
+ * ~~dispatch_event~~
232
+ * ~~emulate_media~~
233
+ * evaluate
234
+ * evaluate_handle
235
+ * ~~expose_binding~~
236
+ * ~~expose_function~~
237
+ * fill
238
+ * focus
239
+ * frame
240
+ * frames
241
+ * ~~get_attribute~~
242
+ * ~~go_back~~
243
+ * ~~go_forward~~
244
+ * goto
245
+ * ~~hover~~
246
+ * ~~inner_html~~
247
+ * ~~inner_text~~
248
+ * ~~checked?~~
249
+ * closed?
250
+ * ~~disabled?~~
251
+ * ~~editable?~~
252
+ * ~~enabled?~~
253
+ * ~~hidden?~~
254
+ * ~~visible?~~
255
+ * main_frame
256
+ * opener
257
+ * ~~pdf~~
258
+ * press
259
+ * reload
260
+ * ~~route~~
261
+ * screenshot
262
+ * ~~select_option~~
263
+ * set_content
264
+ * ~~set_default_navigation_timeout~~
265
+ * ~~set_default_timeout~~
266
+ * ~~set_extra_http_headers~~
267
+ * ~~set_input_files~~
268
+ * set_viewport_size
269
+ * ~~tap_point~~
270
+ * ~~text_content~~
271
+ * title
272
+ * type
273
+ * ~~uncheck~~
274
+ * ~~unroute~~
275
+ * url
276
+ * ~~video~~
277
+ * viewport_size
278
+ * expect_event
279
+ * ~~wait_for_function~~
280
+ * wait_for_load_state
281
+ * expect_navigation
282
+ * expect_request
283
+ * expect_response
284
+ * ~~wait_for_selector~~
285
+ * ~~wait_for_timeout~~
286
+ * ~~workers~~
287
+ * accessibility
288
+ * ~~coverage~~
289
+ * keyboard
290
+ * mouse
291
+ * touchscreen
292
+
293
+ ## BrowserContext
294
+
295
+ * ~~add_cookies~~
296
+ * ~~add_init_script~~
297
+ * ~~browser~~
298
+ * ~~clear_cookies~~
299
+ * ~~clear_permissions~~
300
+ * close
301
+ * ~~cookies~~
302
+ * ~~expose_binding~~
303
+ * ~~expose_function~~
304
+ * ~~grant_permissions~~
305
+ * new_page
306
+ * pages
307
+ * ~~route~~
308
+ * ~~set_default_navigation_timeout~~
309
+ * ~~set_default_timeout~~
310
+ * ~~set_extra_http_headers~~
311
+ * ~~set_geolocation~~
312
+ * ~~set_http_credentials~~
313
+ * ~~set_offline~~
314
+ * ~~storage_state~~
315
+ * ~~unroute~~
316
+ * ~~expect_event~~
317
+
318
+ ## ~~CDPSession~~
319
+
320
+ * ~~detach~~
321
+ * ~~send_message~~
322
+
323
+ ## ChromiumBrowserContext
324
+
325
+ * ~~background_pages~~
326
+ * ~~new_cdp_session~~
327
+ * ~~service_workers~~
328
+
329
+ ## Browser
330
+
331
+ * close
332
+ * contexts
333
+ * connected?
334
+ * new_context
335
+ * new_page
336
+ * version
337
+
338
+ ## BrowserType
339
+
340
+ * ~~connect~~
341
+ * executable_path
342
+ * launch
343
+ * ~~launch_persistent_context~~
344
+ * ~~launch_server~~
345
+ * name
346
+
347
+ ## Playwright
348
+
349
+ * chromium
350
+ * devices
351
+ * ~~errors~~
352
+ * firefox
353
+ * ~~selectors~~
354
+ * webkit