puppeteer-ruby 0.37.2 → 0.39.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +31 -1
- data/README.md +1 -1
- data/docs/api_coverage.md +6 -6
- data/lib/puppeteer/aria_query_handler.rb +3 -3
- data/lib/puppeteer/browser_runner.rb +21 -10
- data/lib/puppeteer/cdp_session.rb +5 -0
- data/lib/puppeteer/dom_world.rb +9 -5
- data/lib/puppeteer/element_handle.rb +10 -8
- data/lib/puppeteer/executable_path_finder.rb +28 -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/launcher/chrome.rb +66 -30
- data/lib/puppeteer/launcher/chrome_arg_options.rb +2 -1
- data/lib/puppeteer/launcher/firefox.rb +268 -228
- data/lib/puppeteer/launcher/launch_options.rb +2 -1
- 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/target.rb +5 -0
- data/lib/puppeteer/version.rb +1 -1
- data/lib/puppeteer.rb +1 -0
- metadata +3 -2
@@ -72,7 +72,15 @@ class Puppeteer::HTTPRequest
|
|
72
72
|
end
|
73
73
|
|
74
74
|
attr_reader :internal
|
75
|
-
attr_reader :url, :resource_type, :method, :post_data, :headers, :response, :frame
|
75
|
+
attr_reader :url, :resource_type, :method, :post_data, :headers, :response, :frame, :initiator
|
76
|
+
|
77
|
+
def inspect
|
78
|
+
values = %i[request_id method url].map do |sym|
|
79
|
+
value = instance_variable_get(:"@#{sym}")
|
80
|
+
"@#{sym}=#{value}"
|
81
|
+
end
|
82
|
+
"#<Puppeteer::HTTPRequest #{values.join(' ')}>"
|
83
|
+
end
|
76
84
|
|
77
85
|
private def assert_interception_allowed
|
78
86
|
unless @allow_interception
|
@@ -27,31 +27,41 @@ module Puppeteer::Launcher
|
|
27
27
|
@chrome_arg_options.args.dup
|
28
28
|
end
|
29
29
|
|
30
|
-
#
|
31
|
-
# let temporaryUserDataDir = null;
|
32
|
-
|
33
30
|
if chrome_arguments.none? { |arg| arg.start_with?('--remote-debugging-') }
|
34
31
|
if @launch_options.pipe?
|
35
32
|
chrome_arguments << '--remote-debugging-pipe'
|
36
33
|
else
|
37
|
-
chrome_arguments <<
|
34
|
+
chrome_arguments << "--remote-debugging-port=#{@chrome_arg_options.debugging_port}"
|
38
35
|
end
|
39
36
|
end
|
40
37
|
|
41
|
-
|
42
|
-
if
|
43
|
-
|
44
|
-
|
38
|
+
user_data_dir = chrome_arguments.find { |arg| arg.start_with?('--user-data-dir') }
|
39
|
+
if user_data_dir
|
40
|
+
user_data_dir = user_data_dir.split('=').last
|
41
|
+
unless File.exist?(user_data_dir)
|
42
|
+
raise ArgumentError.new("Chrome user data dir not found at '#{user_data_dir}'")
|
43
|
+
end
|
44
|
+
using_temp_user_data_dir = false
|
45
|
+
else
|
46
|
+
user_data_dir = Dir.mktmpdir('puppeteer_dev_chrome_profile-', ENV['PUPPETEER_TMP_DIR'])
|
47
|
+
chrome_arguments << "--user-data-dir=#{user_data_dir}"
|
48
|
+
using_temp_user_data_dir = true
|
45
49
|
end
|
46
50
|
|
47
51
|
chrome_executable =
|
48
52
|
if @launch_options.channel
|
49
53
|
executable_path_for_channel(@launch_options.channel.to_s)
|
50
54
|
else
|
51
|
-
@launch_options.executable_path ||
|
55
|
+
@launch_options.executable_path || fallback_executable_path
|
52
56
|
end
|
53
57
|
use_pipe = chrome_arguments.include?('--remote-debugging-pipe')
|
54
|
-
runner = Puppeteer::BrowserRunner.new(
|
58
|
+
runner = Puppeteer::BrowserRunner.new(
|
59
|
+
false,
|
60
|
+
chrome_executable,
|
61
|
+
chrome_arguments,
|
62
|
+
user_data_dir,
|
63
|
+
using_temp_user_data_dir,
|
64
|
+
)
|
55
65
|
runner.start(
|
56
66
|
handle_SIGHUP: @launch_options.handle_SIGHUP?,
|
57
67
|
handle_SIGTERM: @launch_options.handle_SIGTERM?,
|
@@ -61,30 +71,39 @@ module Puppeteer::Launcher
|
|
61
71
|
pipe: use_pipe,
|
62
72
|
)
|
63
73
|
|
74
|
+
browser =
|
75
|
+
begin
|
76
|
+
connection = runner.setup_connection(
|
77
|
+
use_pipe: use_pipe,
|
78
|
+
timeout: @launch_options.timeout,
|
79
|
+
slow_mo: @browser_options.slow_mo,
|
80
|
+
preferred_revision: @preferred_revision,
|
81
|
+
)
|
82
|
+
|
83
|
+
Puppeteer::Browser.create(
|
84
|
+
connection: connection,
|
85
|
+
context_ids: [],
|
86
|
+
ignore_https_errors: @browser_options.ignore_https_errors?,
|
87
|
+
default_viewport: @browser_options.default_viewport,
|
88
|
+
process: runner.proc,
|
89
|
+
close_callback: -> { runner.close },
|
90
|
+
)
|
91
|
+
rescue
|
92
|
+
runner.kill
|
93
|
+
raise
|
94
|
+
end
|
95
|
+
|
64
96
|
begin
|
65
|
-
|
66
|
-
|
97
|
+
browser.wait_for_target(
|
98
|
+
predicate: ->(target) { target.type == 'page' },
|
67
99
|
timeout: @launch_options.timeout,
|
68
|
-
slow_mo: @browser_options.slow_mo,
|
69
|
-
preferred_revision: @preferred_revision,
|
70
|
-
)
|
71
|
-
|
72
|
-
browser = Puppeteer::Browser.create(
|
73
|
-
connection: connection,
|
74
|
-
context_ids: [],
|
75
|
-
ignore_https_errors: @browser_options.ignore_https_errors?,
|
76
|
-
default_viewport: @browser_options.default_viewport,
|
77
|
-
process: runner.proc,
|
78
|
-
close_callback: -> { runner.close },
|
79
100
|
)
|
80
|
-
|
81
|
-
browser.wait_for_target(predicate: ->(target) { target.type == 'page' })
|
82
|
-
|
83
|
-
browser
|
84
101
|
rescue
|
85
|
-
|
102
|
+
browser.close
|
86
103
|
raise
|
87
104
|
end
|
105
|
+
|
106
|
+
browser
|
88
107
|
end
|
89
108
|
|
90
109
|
class DefaultArgs
|
@@ -216,10 +235,14 @@ module Puppeteer::Launcher
|
|
216
235
|
if channel
|
217
236
|
executable_path_for_channel(channel.to_s)
|
218
237
|
else
|
219
|
-
|
238
|
+
fallback_executable_path
|
220
239
|
end
|
221
240
|
end
|
222
241
|
|
242
|
+
private def fallback_executable_path
|
243
|
+
executable_path_for_channel('chrome')
|
244
|
+
end
|
245
|
+
|
223
246
|
CHROMIUM_CHANNELS = {
|
224
247
|
windows: {
|
225
248
|
'chrome' => "#{ENV['PROGRAMFILES']}\\Google\\Chrome\\Application\\chrome.exe",
|
@@ -236,7 +259,16 @@ module Puppeteer::Launcher
|
|
236
259
|
'msedge' => '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
|
237
260
|
},
|
238
261
|
linux: {
|
239
|
-
'chrome' =>
|
262
|
+
'chrome' => -> {
|
263
|
+
Puppeteer::ExecutablePathFinder.new(
|
264
|
+
'google-chrome-stable',
|
265
|
+
'google-chrome',
|
266
|
+
'chrome',
|
267
|
+
'chromium-freeworld',
|
268
|
+
'chromium-browser',
|
269
|
+
'chromium',
|
270
|
+
).find_first
|
271
|
+
},
|
240
272
|
'chrome-beta' => '/opt/google/chrome-beta/chrome',
|
241
273
|
'chrome-dev' => '/opt/google/chrome-unstable/chrome',
|
242
274
|
},
|
@@ -254,6 +286,10 @@ module Puppeteer::Launcher
|
|
254
286
|
end
|
255
287
|
|
256
288
|
chrome_path = chrome_path_map[channel]
|
289
|
+
if chrome_path.is_a?(Proc)
|
290
|
+
chrome_path = chrome_path.call
|
291
|
+
end
|
292
|
+
|
257
293
|
unless chrome_path
|
258
294
|
raise ArgumentError.new("Invalid channel: '#{channel}'. Allowed channel is #{chrome_path_map.keys}")
|
259
295
|
end
|
@@ -34,9 +34,10 @@ module Puppeteer::Launcher
|
|
34
34
|
if @headless.nil?
|
35
35
|
@headless = !@devtools
|
36
36
|
end
|
37
|
+
@debugging_port = options[:debugging_port] || 0
|
37
38
|
end
|
38
39
|
|
39
|
-
attr_reader :args, :user_data_dir
|
40
|
+
attr_reader :args, :user_data_dir, :debugging_port
|
40
41
|
|
41
42
|
def headless?
|
42
43
|
@headless
|