puppeteer-ruby 0.37.4 → 0.40.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +35 -1
- data/docs/api_coverage.md +9 -6
- data/lib/puppeteer/aria_query_handler.rb +8 -5
- data/lib/puppeteer/browser_runner.rb +21 -10
- data/lib/puppeteer/cdp_session.rb +5 -0
- data/lib/puppeteer/custom_query_handler.rb +2 -2
- data/lib/puppeteer/dom_world.rb +21 -13
- data/lib/puppeteer/element_handle.rb +54 -0
- data/lib/puppeteer/events.rb +1 -0
- data/lib/puppeteer/frame.rb +30 -8
- data/lib/puppeteer/frame_manager.rb +136 -59
- data/lib/puppeteer/http_request.rb +9 -1
- data/lib/puppeteer/http_response.rb +25 -4
- data/lib/puppeteer/js_handle.rb +8 -0
- data/lib/puppeteer/launcher/chrome.rb +51 -32
- data/lib/puppeteer/launcher/chrome_arg_options.rb +2 -1
- data/lib/puppeteer/launcher/firefox.rb +259 -226
- data/lib/puppeteer/launcher/launch_options.rb +2 -1
- data/lib/puppeteer/network_event_manager.rb +122 -0
- data/lib/puppeteer/network_manager.rb +180 -40
- data/lib/puppeteer/page/screenshot_options.rb +1 -1
- data/lib/puppeteer/page.rb +75 -19
- data/lib/puppeteer/puppeteer.rb +2 -0
- data/lib/puppeteer/query_handler_manager.rb +2 -2
- data/lib/puppeteer/target.rb +5 -0
- data/lib/puppeteer/version.rb +1 -1
- data/lib/puppeteer/wait_task.rb +10 -7
- data/lib/puppeteer.rb +1 -0
- data/puppeteer-ruby.gemspec +2 -2
- metadata +8 -7
data/lib/puppeteer/wait_task.rb
CHANGED
@@ -9,7 +9,7 @@ class Puppeteer::WaitTask
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def initialize(dom_world:, predicate_body:, title:, polling:, timeout:, args: [], binding_function: nil)
|
12
|
+
def initialize(dom_world:, predicate_body:, title:, polling:, timeout:, args: [], binding_function: nil, root: nil)
|
13
13
|
if polling.is_a?(String)
|
14
14
|
if polling != 'raf' && polling != 'mutation'
|
15
15
|
raise ArgumentError.new("Unknown polling option: #{polling}")
|
@@ -25,6 +25,7 @@ class Puppeteer::WaitTask
|
|
25
25
|
@dom_world = dom_world
|
26
26
|
@polling = polling
|
27
27
|
@timeout = timeout
|
28
|
+
@root = root
|
28
29
|
@predicate_body = "return (#{predicate_body})(...args);"
|
29
30
|
@args = args
|
30
31
|
@binding_function = binding_function
|
@@ -68,6 +69,7 @@ class Puppeteer::WaitTask
|
|
68
69
|
begin
|
69
70
|
success = context.evaluate_handle(
|
70
71
|
WAIT_FOR_PREDICATE_PAGE_FUNCTION,
|
72
|
+
@root,
|
71
73
|
@predicate_body,
|
72
74
|
@polling,
|
73
75
|
@timeout,
|
@@ -121,8 +123,9 @@ class Puppeteer::WaitTask
|
|
121
123
|
private define_async_method :async_rerun
|
122
124
|
|
123
125
|
WAIT_FOR_PREDICATE_PAGE_FUNCTION = <<~JAVASCRIPT
|
124
|
-
async function _(predicateBody, polling, timeout, ...args) {
|
126
|
+
async function _(root, predicateBody, polling, timeout, ...args) {
|
125
127
|
const predicate = new Function('...args', predicateBody);
|
128
|
+
root = root || document
|
126
129
|
let timedOut = false;
|
127
130
|
if (timeout)
|
128
131
|
setTimeout(() => (timedOut = true), timeout);
|
@@ -136,7 +139,7 @@ class Puppeteer::WaitTask
|
|
136
139
|
* @return {!Promise<*>}
|
137
140
|
*/
|
138
141
|
async function pollMutation() {
|
139
|
-
const success = await predicate(...args);
|
142
|
+
const success = await predicate(root, ...args);
|
140
143
|
if (success) return Promise.resolve(success);
|
141
144
|
let fulfill;
|
142
145
|
const result = new Promise((x) => (fulfill = x));
|
@@ -145,13 +148,13 @@ class Puppeteer::WaitTask
|
|
145
148
|
observer.disconnect();
|
146
149
|
fulfill();
|
147
150
|
}
|
148
|
-
const success = await predicate(...args);
|
151
|
+
const success = await predicate(root, ...args);
|
149
152
|
if (success) {
|
150
153
|
observer.disconnect();
|
151
154
|
fulfill(success);
|
152
155
|
}
|
153
156
|
});
|
154
|
-
observer.observe(
|
157
|
+
observer.observe(root, {
|
155
158
|
childList: true,
|
156
159
|
subtree: true,
|
157
160
|
attributes: true,
|
@@ -168,7 +171,7 @@ class Puppeteer::WaitTask
|
|
168
171
|
fulfill();
|
169
172
|
return;
|
170
173
|
}
|
171
|
-
const success = await predicate(...args);
|
174
|
+
const success = await predicate(root, ...args);
|
172
175
|
if (success) fulfill(success);
|
173
176
|
else requestAnimationFrame(onRaf);
|
174
177
|
}
|
@@ -183,7 +186,7 @@ class Puppeteer::WaitTask
|
|
183
186
|
fulfill();
|
184
187
|
return;
|
185
188
|
}
|
186
|
-
const success = await predicate(...args);
|
189
|
+
const success = await predicate(root, ...args);
|
187
190
|
if (success) fulfill(success);
|
188
191
|
else setTimeout(onTimeout, pollInterval);
|
189
192
|
}
|
data/lib/puppeteer.rb
CHANGED
@@ -47,6 +47,7 @@ require 'puppeteer/launcher'
|
|
47
47
|
require 'puppeteer/lifecycle_watcher'
|
48
48
|
require 'puppeteer/mouse'
|
49
49
|
require 'puppeteer/network_conditions'
|
50
|
+
require 'puppeteer/network_event_manager'
|
50
51
|
require 'puppeteer/network_manager'
|
51
52
|
require 'puppeteer/page'
|
52
53
|
require 'puppeteer/protocol_stream_reader'
|
data/puppeteer-ruby.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'concurrent-ruby', '~> 1.1.0'
|
25
25
|
spec.add_dependency 'websocket-driver', '>= 0.6.0'
|
26
26
|
spec.add_dependency 'mime-types', '>= 3.0'
|
27
|
-
spec.add_development_dependency 'bundler', '~> 2.
|
27
|
+
spec.add_development_dependency 'bundler', '~> 2.3.4'
|
28
28
|
spec.add_development_dependency 'chunky_png'
|
29
29
|
spec.add_development_dependency 'dry-inflector'
|
30
30
|
spec.add_development_dependency 'pry-byebug'
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency 'rollbar'
|
33
33
|
spec.add_development_dependency 'rspec', '~> 3.10.0 '
|
34
34
|
spec.add_development_dependency 'rspec_junit_formatter' # for CircleCI.
|
35
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
35
|
+
spec.add_development_dependency 'rubocop', '~> 1.24.0'
|
36
36
|
spec.add_development_dependency 'rubocop-rspec'
|
37
37
|
spec.add_development_dependency 'sinatra'
|
38
38
|
spec.add_development_dependency 'webrick'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppeteer-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.40.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YusukeIwaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.3.4
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: 2.3.4
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: chunky_png
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.
|
173
|
+
version: 1.24.0
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.
|
180
|
+
version: 1.24.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: rubocop-rspec
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -306,6 +306,7 @@ files:
|
|
306
306
|
- lib/puppeteer/mouse.rb
|
307
307
|
- lib/puppeteer/network_condition.rb
|
308
308
|
- lib/puppeteer/network_conditions.rb
|
309
|
+
- lib/puppeteer/network_event_manager.rb
|
309
310
|
- lib/puppeteer/network_manager.rb
|
310
311
|
- lib/puppeteer/page.rb
|
311
312
|
- lib/puppeteer/page/metrics.rb
|
@@ -346,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
346
347
|
- !ruby/object:Gem::Version
|
347
348
|
version: '0'
|
348
349
|
requirements: []
|
349
|
-
rubygems_version: 3.
|
350
|
+
rubygems_version: 3.3.3
|
350
351
|
signing_key:
|
351
352
|
specification_version: 4
|
352
353
|
summary: A ruby port of puppeteer
|