puppeteer-ruby 0.34.3 → 0.37.0

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +69 -43
  3. data/README.md +78 -11
  4. data/docs/api_coverage.md +27 -6
  5. data/lib/puppeteer/browser.rb +2 -8
  6. data/lib/puppeteer/browser_context.rb +1 -0
  7. data/lib/puppeteer/concurrent_ruby_utils.rb +2 -2
  8. data/lib/puppeteer/coverage.rb +11 -2
  9. data/lib/puppeteer/define_async_method.rb +1 -1
  10. data/lib/puppeteer/devices.rb +132 -0
  11. data/lib/puppeteer/dom_world.rb +10 -9
  12. data/lib/puppeteer/element_handle/offset.rb +28 -0
  13. data/lib/puppeteer/element_handle/point.rb +11 -0
  14. data/lib/puppeteer/element_handle.rb +68 -7
  15. data/lib/puppeteer/frame.rb +3 -2
  16. data/lib/puppeteer/js_coverage.rb +28 -7
  17. data/lib/puppeteer/launcher/chrome.rb +64 -4
  18. data/lib/puppeteer/launcher/firefox.rb +48 -4
  19. data/lib/puppeteer/launcher/launch_options.rb +2 -1
  20. data/lib/puppeteer/launcher.rb +0 -1
  21. data/lib/puppeteer/mouse.rb +54 -1
  22. data/lib/puppeteer/network_condition.rb +12 -0
  23. data/lib/puppeteer/network_conditions.rb +24 -0
  24. data/lib/puppeteer/network_manager.rb +47 -11
  25. data/lib/puppeteer/page/metrics.rb +49 -0
  26. data/lib/puppeteer/page/screenshot_options.rb +3 -1
  27. data/lib/puppeteer/page.rb +147 -93
  28. data/lib/puppeteer/puppeteer.rb +10 -2
  29. data/lib/puppeteer/timeout_helper.rb +22 -0
  30. data/lib/puppeteer/tracing.rb +6 -1
  31. data/lib/puppeteer/version.rb +1 -1
  32. data/lib/puppeteer/web_socket.rb +1 -0
  33. data/lib/puppeteer-ruby.rb +2 -0
  34. data/lib/puppeteer.rb +15 -12
  35. data/puppeteer-ruby.gemspec +1 -1
  36. metadata +10 -7
  37. data/Dockerfile +0 -9
  38. data/docker-compose.yml +0 -34
  39. data/lib/puppeteer/launcher/base.rb +0 -66
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40020c8b6fa98e08295fe19758d81b6bb88c5d828d19b25a567d8f699db90267
4
- data.tar.gz: 309d5de2c5a715a531b2909d0ac8408205f95a78204fbdf8f6a619d8630719eb
3
+ metadata.gz: 9e46056e6227e597554a407d47c132610af952d42b1cd7c2149e2046e0d8f1bb
4
+ data.tar.gz: 99a5c6fd6885181e32c72086a768c60583738974a3c86a05a693af2b97b51bc3
5
5
  SHA512:
6
- metadata.gz: ed631a2b52c199404eed1559ac2f1d450af94d8139d70b466f2be72f801799f3548bed0ce344e114295f9374edff4323e8970e6b98cba3b7bc3ee384c517cba7
7
- data.tar.gz: a8fab38d9172110fe68d3d93034b5d67dec74ea821eee809fd35347ffdbe5d9bb0acb3c197f727feb273ae838c672f2a6d497f8ca580c5afbad10424df72c3ab
6
+ metadata.gz: d4b1032b52bb5a0ad92e57f0bac5fe5208b785679f1d7efff0ab335cb28478f6110979102d0ec4759ef2f86654b4d231e018aa9cdb3982dc1ffa2e985fa4c55f
7
+ data.tar.gz: 42f81fe580fcb85b5c57397962362c3c6b0ba7462fe210c65ee017b9e73c0a3d9d091c03a7b18f6e6d78f3a3c52572a5d0bb8284f1087412344a184e8624170d
data/CHANGELOG.md CHANGED
@@ -1,30 +1,57 @@
1
- ### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.3...master)]
1
+ ### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.37.0...master)]
2
2
 
3
- * xxx
3
+ - xxx
4
+
5
+ ### 0.37.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.36.0...0.37.0)]
6
+
7
+ New features:
8
+
9
+ - Some features introduced in Puppeteer 10.4
10
+
11
+ ### 0.36.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.35.1...0.36.0)]
12
+
13
+ New features:
14
+
15
+ - Drag and Drop feature introduced in Puppeteer 10.1
16
+ - `Page#emulateNetworkConditions`, `Page#emulateCPUThrottling`
17
+ - `Page#exposeFunction`
18
+ - Metrics
19
+
20
+ ### 0.35.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.35.0...0.35.1)]
21
+
22
+ New features:
23
+
24
+ - Allow Rails users to use this library without `require 'puppeteer'`.
25
+
26
+ ### 0.35.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.3...0.35.0)]
27
+
28
+ New features:
29
+
30
+ - Add `channel` parameter for Puppeteer.launch. Now `channel: chrome` or `channel: chrome-canary` (chrome-beta, chrome-dev is also available) automatically detects the executablePath of Google Chrome. Windows/macOS users can also use `channel: msedge`.
4
31
 
5
32
  ### 0.34.3 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.2...0.34.3)]
6
33
 
7
34
  Bugfix:
8
35
 
9
- * Fix wait_for_xxx's timeout error type.
36
+ - Fix wait_for_xxx's timeout error type.
10
37
 
11
38
  ### 0.34.2 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.1...0.34.2)]
12
39
 
13
40
  New features:
14
41
 
15
- * Add `Page#bring_to_front`.
42
+ - Add `Page#bring_to_front`.
16
43
 
17
44
  ### 0.34.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.0...0.34.1)]
18
45
 
19
46
  Bugfix:
20
47
 
21
- * Fix `Page#pdf` to work without `path` parameter.
48
+ - Fix `Page#pdf` to work without `path` parameter.
22
49
 
23
50
  ### 0.34.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.33.0...0.34.0)]
24
51
 
25
52
  New features:
26
53
 
27
- * Sync API with block
54
+ - Sync API with block
28
55
 
29
56
  ### 0.33.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.32.4...0.33.0)]
30
57
 
@@ -32,170 +59,169 @@ NOTE: Requires Ruby version >= 2.6 explicitly since this version.
32
59
 
33
60
  Bugfix:
34
61
 
35
- * Fix PDF options to work correctly on decimal numbers specified.
62
+ - Fix PDF options to work correctly on decimal numbers specified.
36
63
 
37
64
  ### 0.32.4 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.32.3...0.32.4)]
38
65
 
39
66
  Bugfix:
40
67
 
41
- * Fix `#type_text` to input '<' correctly.
68
+ - Fix `#type_text` to input '<' correctly.
42
69
 
43
70
  ### 0.32.3 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.32.2...0.32.3)]
44
71
 
45
72
  Bugfix:
46
73
 
47
- * Fix puppeteer-ruby to work on Rails in development mode.
48
-
74
+ - Fix puppeteer-ruby to work on Rails in development mode.
49
75
 
50
76
  ### 0.32.2 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.32.1...0.32.2)]
51
77
 
52
78
  Bugfix:
53
79
 
54
- * Fix full_page option in screenshot.
80
+ - Fix full_page option in screenshot.
55
81
 
56
82
  ### 0.32.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.32.0...0.32.1)]
57
83
 
58
84
  Bugfix:
59
85
 
60
- * Fix WebSocket to work with `wss://...` endpoint (ex. browserless.io)
86
+ - Fix WebSocket to work with `wss://...` endpoint (ex. browserless.io)
61
87
 
62
88
  ### 0.32.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.6...0.32.0)]
63
89
 
64
90
  New features:
65
91
 
66
- * Tracing
67
- * JS/CSS coverages
92
+ - Tracing
93
+ - JS/CSS coverages
68
94
 
69
95
  Improvement:
70
96
 
71
- * Increase stability [#92](https://github.com/YusukeIwaki/puppeteer-ruby/pull/92)
97
+ - Increase stability [#92](https://github.com/YusukeIwaki/puppeteer-ruby/pull/92)
72
98
 
73
99
  ### 0.31.6 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.5...0.31.6)]
74
100
 
75
101
  Improvement:
76
102
 
77
- * Increase stability [#87](https://github.com/YusukeIwaki/puppeteer-ruby/pull/87)
103
+ - Increase stability [#87](https://github.com/YusukeIwaki/puppeteer-ruby/pull/87)
78
104
 
79
105
  ### 0.31.5 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.4...0.31.5)]
80
106
 
81
107
  Bugfix:
82
108
 
83
- * Fix file uploading to work without crash.
109
+ - Fix file uploading to work without crash.
84
110
 
85
111
  ### 0.31.4 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.3...0.31.4)]
86
112
 
87
113
  Bugfix:
88
114
 
89
- * Fix PDF options (format, margin, omit_background) to work.
115
+ - Fix PDF options (format, margin, omit_background) to work.
90
116
 
91
117
  ### 0.31.3 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.1...0.31.3)]
92
118
 
93
119
  Bugfix:
94
120
 
95
- * Fix `wait_for_selector` to work. *It is strongly recommended to update for 0.29.0-0.31.x users.*
121
+ - Fix `wait_for_selector` to work. _It is strongly recommended to update for 0.29.0-0.31.x users._
96
122
 
97
123
  ### 0.31.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.31.0...0.31.1)]
98
124
 
99
125
  Bugfix:
100
126
 
101
- * Fix `Page#pdf` to work on Windows.
127
+ - Fix `Page#pdf` to work on Windows.
102
128
 
103
129
  ### 0.31.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.30.0...0.31.0)]
104
130
 
105
131
  New features:
106
132
 
107
- * Now puppeteer-ruby is compatible with Windows
133
+ - Now puppeteer-ruby is compatible with Windows
108
134
 
109
135
  Bugfix:
110
136
 
111
- * Fix `Page#add_script_tag` and `Page#add_style_tag` to work
137
+ - Fix `Page#add_script_tag` and `Page#add_style_tag` to work
112
138
 
113
139
  ### 0.30.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.29.0...0.30.0)]
114
140
 
115
141
  New features:
116
142
 
117
- * S, SS, Seval, SSeval is renamed to query_selector, query_selector_all, eval_on_selector, eval_on_selector_all
143
+ - S, SS, Seval, SSeval is renamed to query_selector, query_selector_all, eval_on_selector, eval_on_selector_all
118
144
 
119
145
  ### 0.29.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.28.1...0.29.0)]
120
146
 
121
147
  New features:
122
148
 
123
- * Add `AriaQueryHandler`. Now we can use "aria/...." for selectors.
149
+ - Add `AriaQueryHandler`. Now we can use "aria/...." for selectors.
124
150
 
125
151
  ### 0.28.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.27...0.28.1)]
126
152
 
127
153
  New features:
128
154
 
129
- * Add `Page#emulate_idle_state`
130
- * Change versioning rule.
155
+ - Add `Page#emulate_idle_state`
156
+ - Change versioning rule.
131
157
 
132
158
  ### 0.0.27 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.26...0.0.27)]
133
159
 
134
160
  New features:
135
161
 
136
- * Now puppeteer-ruby is Ruby 3.0 compatible!
162
+ - Now puppeteer-ruby is Ruby 3.0 compatible!
137
163
 
138
164
  ### 0.0.26 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.25...0.0.26)]
139
165
 
140
166
  Bugfix:
141
167
 
142
- * Fix `Page#screenshot` working correctly with `quality` parameter.
168
+ - Fix `Page#screenshot` working correctly with `quality` parameter.
143
169
 
144
170
  ### 0.0.25 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.23...0.0.25)]
145
171
 
146
172
  New feature:
147
173
 
148
- * **Cookie** feature: `Page#set_cookie`, `Page#cookies`
174
+ - **Cookie** feature: `Page#set_cookie`, `Page#cookies`
149
175
 
150
176
  ### 0.0.23 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.22...0.0.23)]
151
177
 
152
178
  New feature:
153
179
 
154
- * **GeoLocation** feature
155
- * grant/clear permission
180
+ - **GeoLocation** feature
181
+ - grant/clear permission
156
182
 
157
183
  Bugfix/Improvement:
158
184
 
159
- * Refactoring for events ([#31](https://github.com/YusukeIwaki/puppeteer-ruby/pull/31))
160
- * Improve SEND/RECV handling in CDPSession ([#34](https://github.com/YusukeIwaki/puppeteer-ruby/pull/34))
185
+ - Refactoring for events ([#31](https://github.com/YusukeIwaki/puppeteer-ruby/pull/31))
186
+ - Improve SEND/RECV handling in CDPSession ([#34](https://github.com/YusukeIwaki/puppeteer-ruby/pull/34))
161
187
 
162
188
  ### 0.0.22 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.21...0.0.22)]
163
189
 
164
190
  Bugfix
165
191
 
166
- * Make `Puppeteer#default_args` to work
167
- * Respect Firefox launch options
168
- * Respect `default_viewport: nil`
192
+ - Make `Puppeteer#default_args` to work
193
+ - Respect Firefox launch options
194
+ - Respect `default_viewport: nil`
169
195
 
170
196
  ### 0.0.21 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.20...0.0.21)]
171
197
 
172
198
  Bugfix/Improvement:
173
199
 
174
- * Update DeviceDescriptors (list of emulatable devices)
175
- * Fix bug on inputing "(" ([#25](https://github.com/YusukeIwaki/puppeteer-ruby/pull/25))
200
+ - Update DeviceDescriptors (list of emulatable devices)
201
+ - Fix bug on inputing "(" ([#25](https://github.com/YusukeIwaki/puppeteer-ruby/pull/25))
176
202
 
177
203
  ### 0.0.20 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.19...0.0.20)]
178
204
 
179
205
  New feature
180
206
 
181
- * Dialog-handling feature
207
+ - Dialog-handling feature
182
208
 
183
209
  ### 0.0.19 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.18...0.0.19)]
184
210
 
185
211
  New feature
186
212
 
187
- * **Firefox support**
213
+ - **Firefox support**
188
214
 
189
215
  Bugfix/Improvement
190
216
 
191
- * Allow `Page#keyboard` with block ([#18](https://github.com/YusukeIwaki/puppeteer-ruby/pull/18))
217
+ - Allow `Page#keyboard` with block ([#18](https://github.com/YusukeIwaki/puppeteer-ruby/pull/18))
192
218
 
193
219
  ### 0.0.18 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.0.17...0.0.18)]
194
220
 
195
221
  New feature
196
222
 
197
- * **Firefox support**
223
+ - **Firefox support**
198
224
 
199
225
  Bugfix/Improvement
200
226
 
201
- * Allow `Page#keyboard` with block ([#18](https://github.com/YusukeIwaki/puppeteer-ruby/pull/18))
227
+ - Allow `Page#keyboard` with block ([#18](https://github.com/YusukeIwaki/puppeteer-ruby/pull/18))
data/README.md CHANGED
@@ -20,31 +20,29 @@ gem 'puppeteer-ruby'
20
20
 
21
21
  And then execute:
22
22
 
23
- $ bundle
24
-
25
- Or install it yourself as:
26
-
27
- $ gem install puppeteer-ruby
23
+ $ bundle install
28
24
 
29
25
  ### Capture a site
30
26
 
31
27
  ```ruby
32
- require 'puppeteer'
28
+ require 'puppeteer-ruby'
33
29
 
34
30
  Puppeteer.launch(headless: false) do |browser|
35
- page = browser.pages.first || browser.new_page
31
+ page = browser.new_page
36
32
  page.goto("https://github.com/YusukeIwaki")
37
33
  page.screenshot(path: "YusukeIwaki.png")
38
34
  end
39
35
  ```
40
36
 
37
+ NOTE: `require 'puppeteer-ruby'` is not necessary in Rails.
38
+
41
39
  ### Simple scraping
42
40
 
43
41
  ```ruby
44
- require 'puppeteer'
42
+ require 'puppeteer-ruby'
45
43
 
46
44
  Puppeteer.launch(headless: false, slow_mo: 50, args: ['--guest', '--window-size=1280,800']) do |browser|
47
- page = browser.pages.first || browser.new_page
45
+ page = browser.new_page
48
46
  page.viewport = Puppeteer::Viewport.new(width: 1280, height: 800)
49
47
  page.goto("https://github.com/", wait_until: 'domcontentloaded')
50
48
 
@@ -69,10 +67,10 @@ end
69
67
  ### Evaluate JavaScript
70
68
 
71
69
  ```ruby
72
- require 'puppeteer'
70
+ require 'puppeteer-ruby'
73
71
 
74
72
  Puppeteer.launch do |browser|
75
- page = browser.pages.last || browser.new_page
73
+ page = browser.new_page
76
74
  page.goto 'https://github.com/YusukeIwaki'
77
75
 
78
76
  # Get the "viewport" of the page, as reported by the page.
@@ -158,6 +156,75 @@ RSpec.describe 'hotel.testplanisphere.dev', type: :feature do
158
156
 
159
157
  The detailed step of configuration can be found [here](https://github.com/YusukeIwaki/puppeteer-ruby-example/tree/master/_with_capybara-rspec).
160
158
 
159
+ ## :bulb: Use Puppeteer methods simply without Capybara::DSL
160
+
161
+ We can also use puppeteer-ruby as it is without Capybara DSL. When you want to just test a Rails application simply with Puppeteer, refer this section.
162
+
163
+ Also, if you have trouble with handling flaky/unstable testcases in existing feature/system specs, consider replacing Capybara::DSL with raw puppeteer-ruby codes like `page.wait_for_selector(...)` or `page.wait_for_navigation { ... }`.
164
+
165
+ Capybara prepares test server even when Capybara DSL is not used.
166
+
167
+ Sample configuration is shown below. You can use it by putting the file at `spec/support/puppeteer_ruby.rb` or another location where RSpec loads on initialization.
168
+
169
+ ```ruby
170
+ RSpec.configure do |config|
171
+ require 'capybara'
172
+
173
+ # This driver only requests Capybara to launch test server.
174
+ # Remark that no Capybara::DSL is available with this driver.
175
+ class CapybaraNullDriver < Capybara::Driver::Base
176
+ def needs_server?
177
+ true
178
+ end
179
+ end
180
+
181
+ Capybara.register_driver(:null) { CapybaraNullDriver.new }
182
+
183
+ config.around(driver: :null) do |example|
184
+ Capybara.current_driver = :null
185
+
186
+ # Rails server is launched here,
187
+ # (at the first time of accessing Capybara.current_session.server)
188
+ @base_url = Capybara.current_session.server.base_url
189
+
190
+ require 'puppeteer'
191
+ launch_options = {
192
+ # Use launch options as you like.
193
+ channel: :chrome,
194
+ headless: false,
195
+ }
196
+ Puppeteer.launch(**launch_options) do |browser|
197
+ @puppeteer_page = browser.new_page
198
+ example.run
199
+ end
200
+
201
+ Capybara.reset_sessions!
202
+ Capybara.use_default_driver
203
+ end
204
+ end
205
+ ```
206
+
207
+ Now, we can work with integration test using `Puppeteer::Page` in puppeteer-ruby.
208
+
209
+ ```ruby
210
+ RSpec.describe 'Sample integration tests', driver: :null do
211
+ let(:page) { @puppeteer_page }
212
+ let(:base_url) { @base_url }
213
+
214
+ it 'should work with Puppeteer' do
215
+ # null driver only launches server, and Capybara::DSL is unavailable.
216
+ expect { visit '/' }.to raise_error(/NotImplementedError/)
217
+
218
+ page.goto("#{base_url}/")
219
+
220
+ # Automation with Puppeteer
221
+ h1_text = page.eval_on_selector('h1', '(el) => el.textContent')
222
+ expect(h1_text).to eq('It works!')
223
+ end
224
+ end
225
+ ```
226
+
227
+
161
228
  ## API
162
229
 
163
230
  https://yusukeiwaki.github.io/puppeteer-ruby-docs/
data/docs/api_coverage.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # API coverages
2
- - Puppeteer version: v10.0.0
3
- - puppeteer-ruby version: 0.34.3
2
+ - Puppeteer version: v10.4.0
3
+ - puppeteer-ruby version: 0.37.0
4
4
 
5
5
  ## Puppeteer
6
6
 
@@ -13,7 +13,7 @@
13
13
  * ~~errors~~
14
14
  * executablePath => `#executable_path`
15
15
  * launch
16
- * ~~networkConditions~~
16
+ * networkConditions => `#network_conditions`
17
17
  * product
18
18
  * ~~registerCustomQueryHandler~~
19
19
  * ~~unregisterCustomQueryHandler~~
@@ -78,18 +78,20 @@
78
78
  * content
79
79
  * cookies
80
80
  * coverage
81
+ * createPDFStream => `#create_pdf_stream`
81
82
  * deleteCookie => `#delete_cookie`
82
83
  * emulate
84
+ * emulateCPUThrottling => `#emulate_cpu_throttling`
83
85
  * emulateIdleState => `#emulate_idle_state`
84
86
  * emulateMediaFeatures => `#emulate_media_features`
85
87
  * emulateMediaType => `#emulate_media_type`
86
- * ~~emulateNetworkConditions~~
88
+ * emulateNetworkConditions => `#emulate_network_conditions`
87
89
  * emulateTimezone => `#emulate_timezone`
88
90
  * emulateVisionDeficiency => `#emulate_vision_deficiency`
89
91
  * evaluate
90
92
  * evaluateHandle => `#evaluate_handle`
91
93
  * evaluateOnNewDocument => `#evaluate_on_new_document`
92
- * ~~exposeFunction~~
94
+ * exposeFunction => `#expose_function`
93
95
  * focus
94
96
  * frames
95
97
  * goBack => `#go_back`
@@ -97,10 +99,11 @@
97
99
  * goto
98
100
  * hover
99
101
  * isClosed => `#closed?`
102
+ * isDragInterceptionEnabled => `#drag_interception_enabled?`
100
103
  * isJavaScriptEnabled => `#javascript_enabled?`
101
104
  * keyboard
102
105
  * mainFrame => `#main_frame`
103
- * ~~metrics~~
106
+ * metrics
104
107
  * mouse
105
108
  * pdf
106
109
  * queryObjects => `#query_objects`
@@ -113,6 +116,7 @@
113
116
  * setCookie => `#set_cookie`
114
117
  * setDefaultNavigationTimeout => `#default_navigation_timeout=`
115
118
  * setDefaultTimeout => `#default_timeout=`
119
+ * ~~setDragInterception~~
116
120
  * setExtraHTTPHeaders => `#extra_http_headers=`
117
121
  * setGeolocation => `#geolocation=`
118
122
  * setJavaScriptEnabled => `#javascript_enabled=`
@@ -132,6 +136,7 @@
132
136
  * waitForFileChooser => `#wait_for_file_chooser`
133
137
  * waitForFunction => `#wait_for_function`
134
138
  * waitForNavigation => `#wait_for_navigation`
139
+ * ~~waitForNetworkIdle~~
135
140
  * waitForRequest => `#wait_for_request`
136
141
  * waitForResponse => `#wait_for_response`
137
142
  * waitForSelector => `#wait_for_selector`
@@ -162,6 +167,11 @@
162
167
 
163
168
  * click
164
169
  * down
170
+ * drag
171
+ * dragAndDrop => `#drag_and_drop`
172
+ * dragEnter => `#drag_enter`
173
+ * dragOver => `#drag_over`
174
+ * drop
165
175
  * move
166
176
  * up
167
177
  * wheel
@@ -260,8 +270,14 @@
260
270
  * boundingBox => `#bounding_box`
261
271
  * boxModel => `#box_model`
262
272
  * click
273
+ * clickablePoint => `#clickable_point`
263
274
  * contentFrame => `#content_frame`
264
275
  * dispose
276
+ * drag
277
+ * dragAndDrop => `#drag_and_drop`
278
+ * dragEnter => `#drag_enter`
279
+ * dragOver => `#drag_over`
280
+ * drop
265
281
  * evaluate
266
282
  * evaluateHandle => `#evaluate_handle`
267
283
  * executionContext => `#execution_context`
@@ -282,8 +298,12 @@
282
298
  ## ~~HTTPRequest~~
283
299
 
284
300
  * ~~abort~~
301
+ * ~~abortErrorReason~~
285
302
  * ~~continue~~
303
+ * ~~continueRequestOverrides~~
304
+ * ~~enqueueInterceptAction~~
286
305
  * ~~failure~~
306
+ * ~~finalizeInterceptions~~
287
307
  * ~~frame~~
288
308
  * ~~headers~~
289
309
  * ~~isNavigationRequest~~
@@ -293,6 +313,7 @@
293
313
  * ~~resourceType~~
294
314
  * ~~respond~~
295
315
  * ~~response~~
316
+ * ~~responseForRequest~~
296
317
  * ~~url~~
297
318
 
298
319
  ## ~~HTTPResponse~~
@@ -223,7 +223,7 @@ class Puppeteer::Browser
223
223
  # @param predicate [Proc(Puppeteer::Target -> Boolean)]
224
224
  # @return [Puppeteer::Target]
225
225
  def wait_for_target(predicate:, timeout: nil)
226
- timeout_in_sec = (timeout || 30000).to_i / 1000.0
226
+ timeout_helper = Puppeteer::TimeoutHelper.new('target', timeout_ms: timeout, default_timeout_ms: 30000)
227
227
  existing_target = targets.find { |target| predicate.call(target) }
228
228
  return existing_target if existing_target
229
229
 
@@ -241,15 +241,9 @@ class Puppeteer::Browser
241
241
  end
242
242
 
243
243
  begin
244
- if timeout_in_sec > 0
245
- Timeout.timeout(timeout_in_sec) do
246
- target_promise.value!
247
- end
248
- else
244
+ timeout_helper.with_timeout do
249
245
  target_promise.value!
250
246
  end
251
- rescue Timeout::Error
252
- raise Puppeteer::TimeoutError.new("waiting for target failed: timeout #{timeout}ms exceeded")
253
247
  ensure
254
248
  remove_event_listener(*event_listening_ids)
255
249
  end
@@ -74,6 +74,7 @@ class Puppeteer::BrowserContext
74
74
  'clipboard-read' => 'clipboardReadWrite',
75
75
  'clipboard-write' => 'clipboardReadWrite',
76
76
  'payment-handler' => 'paymentHandler',
77
+ 'persistent-storage' => 'durableStorage',
77
78
  'idle-detection' => 'idleDetection',
78
79
  # chrome-specific permissions we have.
79
80
  'midi-sysex' => 'midiSysex',
@@ -3,11 +3,11 @@ module Puppeteer::ConcurrentRubyUtils
3
3
  module ConcurrentPromisesFutureExtension
4
4
  # Extension for describing 2 concurrent tasks smartly.
5
5
  #
6
- # page.async_for_navigation.with_waiting_for_complete do
6
+ # page.async_wait_for_navigation.with_waiting_for_complete do
7
7
  # page.click('#submit')
8
8
  # end
9
9
  def with_waiting_for_complete(&block)
10
- async_block_call = Concurrent::Promises.future do
10
+ async_block_call = Concurrent::Promises.delay do
11
11
  block.call
12
12
  rescue => err
13
13
  Logger.new($stderr).warn(err)
@@ -5,10 +5,14 @@ class Puppeteer::Coverage
5
5
  @css = Puppeteer::CSSCoverage.new(client)
6
6
  end
7
7
 
8
- def start_js_coverage(reset_on_navigation: nil, report_anonymous_scripts: nil)
8
+ def start_js_coverage(
9
+ reset_on_navigation: nil,
10
+ report_anonymous_scripts: nil,
11
+ include_raw_script_coverage: nil)
9
12
  @js.start(
10
13
  reset_on_navigation: reset_on_navigation,
11
14
  report_anonymous_scripts: report_anonymous_scripts,
15
+ include_raw_script_coverage: include_raw_script_coverage,
12
16
  )
13
17
  end
14
18
 
@@ -16,7 +20,11 @@ class Puppeteer::Coverage
16
20
  @js.stop
17
21
  end
18
22
 
19
- def js_coverage(reset_on_navigation: nil, report_anonymous_scripts: nil, &block)
23
+ def js_coverage(
24
+ reset_on_navigation: nil,
25
+ report_anonymous_scripts: nil,
26
+ include_raw_script_coverage: nil,
27
+ &block)
20
28
  unless block
21
29
  raise ArgumentError.new('Block must be given')
22
30
  end
@@ -24,6 +32,7 @@ class Puppeteer::Coverage
24
32
  start_js_coverage(
25
33
  reset_on_navigation: reset_on_navigation,
26
34
  report_anonymous_scripts: report_anonymous_scripts,
35
+ include_raw_script_coverage: include_raw_script_coverage,
27
36
  )
28
37
  block.call
29
38
  stop_js_coverage
@@ -40,7 +40,7 @@ module Puppeteer::DefineAsyncMethod
40
40
  end
41
41
  end
42
42
 
43
- async_block_call = Concurrent::Promises.future do
43
+ async_block_call = Concurrent::Promises.delay do
44
44
  block.call
45
45
  rescue => err
46
46
  Logger.new($stderr).warn(err)