puppeteer-ruby 0.34.3 → 0.35.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/docs/api_coverage.md +17 -2
- data/lib/puppeteer/launcher.rb +0 -1
- data/lib/puppeteer/launcher/chrome.rb +64 -4
- data/lib/puppeteer/launcher/firefox.rb +48 -4
- data/lib/puppeteer/launcher/launch_options.rb +2 -1
- data/lib/puppeteer/puppeteer.rb +5 -2
- data/lib/puppeteer/version.rb +1 -1
- data/puppeteer-ruby.gemspec +1 -1
- metadata +4 -5
- data/lib/puppeteer/launcher/base.rb +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7386b90fffcd353eb933d6dcb35d1e7cab9482fa70eaa536bf7bd19bba594edf
|
4
|
+
data.tar.gz: a4bad8a9ab93025fd2864e2a4cd4ff9c6e972156a19898f6cefab84397a9526e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d884728c758d4109ac19e72845a36677186b02d723f1be5e5dc5f5e7eb688b7e87ec17d134a1c02818a68273eeb5aaa49759f2b8554a2200ab1ea7a149c9df7a
|
7
|
+
data.tar.gz: 2fb46af25d069bd75411abc56a5787b04ba0d2af000c06a046df2f300b096c191978628ed5d68d12653dd8b61bb2131008da90baaf0a190942caa10daf9f6cdc
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.
|
1
|
+
### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.35.0...master)]
|
2
2
|
|
3
3
|
* xxx
|
4
4
|
|
5
|
+
### 0.35.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.3...0.35.0)]
|
6
|
+
|
7
|
+
New features:
|
8
|
+
|
9
|
+
* 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`.
|
10
|
+
|
5
11
|
### 0.34.3 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.2...0.34.3)]
|
6
12
|
|
7
13
|
Bugfix:
|
data/docs/api_coverage.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# API coverages
|
2
|
-
- Puppeteer version: v10.
|
3
|
-
- puppeteer-ruby version: 0.
|
2
|
+
- Puppeteer version: v10.1.0
|
3
|
+
- puppeteer-ruby version: 0.35.0
|
4
4
|
|
5
5
|
## Puppeteer
|
6
6
|
|
@@ -78,8 +78,10 @@
|
|
78
78
|
* content
|
79
79
|
* cookies
|
80
80
|
* coverage
|
81
|
+
* createPDFStream => `#create_pdf_stream`
|
81
82
|
* deleteCookie => `#delete_cookie`
|
82
83
|
* emulate
|
84
|
+
* ~~emulateCPUThrottling~~
|
83
85
|
* emulateIdleState => `#emulate_idle_state`
|
84
86
|
* emulateMediaFeatures => `#emulate_media_features`
|
85
87
|
* emulateMediaType => `#emulate_media_type`
|
@@ -97,6 +99,7 @@
|
|
97
99
|
* goto
|
98
100
|
* hover
|
99
101
|
* isClosed => `#closed?`
|
102
|
+
* ~~isDragInterceptionEnabled~~
|
100
103
|
* isJavaScriptEnabled => `#javascript_enabled?`
|
101
104
|
* keyboard
|
102
105
|
* mainFrame => `#main_frame`
|
@@ -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=`
|
@@ -162,6 +166,11 @@
|
|
162
166
|
|
163
167
|
* click
|
164
168
|
* down
|
169
|
+
* ~~drag~~
|
170
|
+
* ~~dragAndDrop~~
|
171
|
+
* ~~dragEnter~~
|
172
|
+
* ~~dragOver~~
|
173
|
+
* ~~drop~~
|
165
174
|
* move
|
166
175
|
* up
|
167
176
|
* wheel
|
@@ -260,8 +269,14 @@
|
|
260
269
|
* boundingBox => `#bounding_box`
|
261
270
|
* boxModel => `#box_model`
|
262
271
|
* click
|
272
|
+
* clickablePoint => `#clickable_point`
|
263
273
|
* contentFrame => `#content_frame`
|
264
274
|
* dispose
|
275
|
+
* ~~drag~~
|
276
|
+
* ~~dragAndDrop~~
|
277
|
+
* ~~dragEnter~~
|
278
|
+
* ~~dragOver~~
|
279
|
+
* ~~drop~~
|
265
280
|
* evaluate
|
266
281
|
* evaluateHandle => `#evaluate_handle`
|
267
282
|
* executionContext => `#execution_context`
|
data/lib/puppeteer/launcher.rb
CHANGED
@@ -2,7 +2,13 @@ require 'tmpdir'
|
|
2
2
|
|
3
3
|
# https://github.com/puppeteer/puppeteer/blob/main/src/node/Launcher.ts
|
4
4
|
module Puppeteer::Launcher
|
5
|
-
class Chrome
|
5
|
+
class Chrome
|
6
|
+
def initialize(project_root:, preferred_revision:, is_puppeteer_core:)
|
7
|
+
@project_root = project_root
|
8
|
+
@preferred_revision = preferred_revision
|
9
|
+
@is_puppeteer_core = is_puppeteer_core
|
10
|
+
end
|
11
|
+
|
6
12
|
# @param {!(Launcher.LaunchOptions & Launcher.ChromeArgOptions & Launcher.BrowserOptions)=} options
|
7
13
|
# @return {!Promise<!Browser>}
|
8
14
|
def launch(options = {})
|
@@ -38,7 +44,12 @@ module Puppeteer::Launcher
|
|
38
44
|
chrome_arguments << "--user-data-dir=#{temporary_user_data_dir}"
|
39
45
|
end
|
40
46
|
|
41
|
-
chrome_executable =
|
47
|
+
chrome_executable =
|
48
|
+
if @launch_options.channel
|
49
|
+
executable_path_for_channel(@launch_options.channel.to_s)
|
50
|
+
else
|
51
|
+
@launch_options.executable_path || executable_path_for_channel('chrome')
|
52
|
+
end
|
42
53
|
use_pipe = chrome_arguments.include?('--remote-debugging-pipe')
|
43
54
|
runner = Puppeteer::BrowserRunner.new(chrome_executable, chrome_arguments, temporary_user_data_dir)
|
44
55
|
runner.start(
|
@@ -201,8 +212,57 @@ module Puppeteer::Launcher
|
|
201
212
|
end
|
202
213
|
|
203
214
|
# @return {string}
|
204
|
-
def executable_path
|
205
|
-
|
215
|
+
def executable_path(channel: nil)
|
216
|
+
if channel
|
217
|
+
executable_path_for_channel(channel.to_s)
|
218
|
+
else
|
219
|
+
executable_path_for_channel('chrome')
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
CHROMIUM_CHANNELS = {
|
224
|
+
windows: {
|
225
|
+
'chrome' => "#{ENV['PROGRAMFILES']}\\Google\\Chrome\\Application\\chrome.exe",
|
226
|
+
'chrome-beta' => "#{ENV['PROGRAMFILES']}\\Google\\Chrome Beta\\Application\\chrome.exe",
|
227
|
+
'chrome-canary' => "#{ENV['PROGRAMFILES']}\\Google\\Chrome SxS\\Application\\chrome.exe",
|
228
|
+
'chrome-dev' => "#{ENV['PROGRAMFILES']}\\Google\\Chrome Dev\\Application\\chrome.exe",
|
229
|
+
'msedge' => "#{ENV['PROGRAMFILES(X86)']}\\Microsoft\\Edge\\Application\\msedge.exe",
|
230
|
+
},
|
231
|
+
darwin: {
|
232
|
+
'chrome' => '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
233
|
+
'chrome-beta' => '/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta',
|
234
|
+
'chrome-canary' => '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
|
235
|
+
'chrome-dev' => '/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev',
|
236
|
+
'msedge' => '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
|
237
|
+
},
|
238
|
+
linux: {
|
239
|
+
'chrome' => '/opt/google/chrome/chrome',
|
240
|
+
'chrome-beta' => '/opt/google/chrome-beta/chrome',
|
241
|
+
'chrome-dev' => '/opt/google/chrome-unstable/chrome',
|
242
|
+
},
|
243
|
+
}.freeze
|
244
|
+
|
245
|
+
# @param channel [String]
|
246
|
+
private def executable_path_for_channel(channel)
|
247
|
+
chrome_path_map =
|
248
|
+
if Puppeteer.env.windows?
|
249
|
+
CHROMIUM_CHANNELS[:windows]
|
250
|
+
elsif Puppeteer.env.darwin?
|
251
|
+
CHROMIUM_CHANNELS[:darwin]
|
252
|
+
else
|
253
|
+
CHROMIUM_CHANNELS[:linux]
|
254
|
+
end
|
255
|
+
|
256
|
+
chrome_path = chrome_path_map[channel]
|
257
|
+
unless chrome_path
|
258
|
+
raise ArgumentError.new("Invalid channel: '#{channel}'. Allowed channel is #{chrome_path_map.keys}")
|
259
|
+
end
|
260
|
+
|
261
|
+
unless File.exist?(chrome_path)
|
262
|
+
raise "#{channel} is not installed on this system.\nExpected path: #{chrome_path}"
|
263
|
+
end
|
264
|
+
|
265
|
+
chrome_path
|
206
266
|
end
|
207
267
|
|
208
268
|
def product
|
@@ -2,7 +2,13 @@ require 'tmpdir'
|
|
2
2
|
|
3
3
|
# https://github.com/puppeteer/puppeteer/blob/main/src/node/Launcher.ts
|
4
4
|
module Puppeteer::Launcher
|
5
|
-
class Firefox
|
5
|
+
class Firefox
|
6
|
+
def initialize(project_root:, preferred_revision:, is_puppeteer_core:)
|
7
|
+
@project_root = project_root
|
8
|
+
@preferred_revision = preferred_revision
|
9
|
+
@is_puppeteer_core = is_puppeteer_core
|
10
|
+
end
|
11
|
+
|
6
12
|
# @param {!(Launcher.LaunchOptions & Launcher.ChromeArgOptions & Launcher.BrowserOptions)=} options
|
7
13
|
# @return {!Promise<!Browser>}
|
8
14
|
def launch(options = {})
|
@@ -32,7 +38,12 @@ module Puppeteer::Launcher
|
|
32
38
|
firefox_arguments << temporary_user_data_dir
|
33
39
|
end
|
34
40
|
|
35
|
-
firefox_executable =
|
41
|
+
firefox_executable =
|
42
|
+
if @launch_options.channel
|
43
|
+
executable_path_for_channel(@launch_options.channel.to_s)
|
44
|
+
else
|
45
|
+
@launch_options.executable_path || executable_path_for_channel('nightly')
|
46
|
+
end
|
36
47
|
runner = Puppeteer::BrowserRunner.new(firefox_executable, firefox_arguments, temporary_user_data_dir)
|
37
48
|
runner.start(
|
38
49
|
handle_SIGHUP: @launch_options.handle_SIGHUP?,
|
@@ -123,8 +134,41 @@ module Puppeteer::Launcher
|
|
123
134
|
end
|
124
135
|
|
125
136
|
# @return {string}
|
126
|
-
def executable_path
|
127
|
-
|
137
|
+
def executable_path(channel: nil)
|
138
|
+
if channel
|
139
|
+
executable_path_for_channel(channel.to_s)
|
140
|
+
else
|
141
|
+
executable_path_for_channel('firefox')
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
FIREFOX_EXECUTABLE_PATHS = {
|
146
|
+
windows: "#{ENV['PROGRAMFILES']}\\Firefox Nightly\\firefox.exe",
|
147
|
+
darwin: '/Applications/Firefox Nightly.app/Contents/MacOS/firefox',
|
148
|
+
linux: '/usr/bin/firefox',
|
149
|
+
}.freeze
|
150
|
+
|
151
|
+
# @param channel [String]
|
152
|
+
private def executable_path_for_channel(channel)
|
153
|
+
allowed = ['firefox', 'firefox-nightly', 'nightly']
|
154
|
+
unless allowed.include?(channel)
|
155
|
+
raise ArgumentError.new("Invalid channel: '#{channel}'. Allowed channel is #{allowed}")
|
156
|
+
end
|
157
|
+
|
158
|
+
firefox_path =
|
159
|
+
if Puppeteer.env.windows?
|
160
|
+
FIREFOX_EXECUTABLE_PATHS[:windows]
|
161
|
+
elsif Puppeteer.env.darwin?
|
162
|
+
FIREFOX_EXECUTABLE_PATHS[:darwin]
|
163
|
+
else
|
164
|
+
FIREFOX_EXECUTABLE_PATHS[:linux]
|
165
|
+
end
|
166
|
+
|
167
|
+
unless File.exist?(firefox_path)
|
168
|
+
raise "Nightly version of Firefox is not installed on this system.\nExpected path: #{firefox_path}"
|
169
|
+
end
|
170
|
+
|
171
|
+
firefox_path
|
128
172
|
end
|
129
173
|
|
130
174
|
def product
|
@@ -32,6 +32,7 @@ module Puppeteer::Launcher
|
|
32
32
|
# @property {!Object<string, string | undefined>=} env
|
33
33
|
# @property {boolean=} pipe
|
34
34
|
def initialize(options)
|
35
|
+
@channel = options[:channel]
|
35
36
|
@executable_path = options[:executable_path]
|
36
37
|
@ignore_default_args = options[:ignore_default_args] || false
|
37
38
|
@handle_SIGINT = options[:handle_SIGINT] || true
|
@@ -43,7 +44,7 @@ module Puppeteer::Launcher
|
|
43
44
|
@pipe = options[:pipe] || false
|
44
45
|
end
|
45
46
|
|
46
|
-
attr_reader :executable_path, :ignore_default_args, :timeout, :env
|
47
|
+
attr_reader :channel, :executable_path, :ignore_default_args, :timeout, :env
|
47
48
|
|
48
49
|
def handle_SIGINT?
|
49
50
|
@handle_SIGINT
|
data/lib/puppeteer/puppeteer.rb
CHANGED
@@ -11,6 +11,7 @@ class Puppeteer::Puppeteer
|
|
11
11
|
class NoViewport ; end
|
12
12
|
|
13
13
|
# @param product [String]
|
14
|
+
# @param channel [String|Symbol]
|
14
15
|
# @param executable_path [String]
|
15
16
|
# @param ignore_default_args [Array<String>|nil]
|
16
17
|
# @param handle_SIGINT [Boolean]
|
@@ -30,6 +31,7 @@ class Puppeteer::Puppeteer
|
|
30
31
|
# @return [Puppeteer::Browser]
|
31
32
|
def launch(
|
32
33
|
product: nil,
|
34
|
+
channel: nil,
|
33
35
|
executable_path: nil,
|
34
36
|
ignore_default_args: nil,
|
35
37
|
handle_SIGINT: nil,
|
@@ -48,6 +50,7 @@ class Puppeteer::Puppeteer
|
|
48
50
|
slow_mo: nil
|
49
51
|
)
|
50
52
|
options = {
|
53
|
+
channel: channel&.to_s,
|
51
54
|
executable_path: executable_path,
|
52
55
|
ignore_default_args: ignore_default_args,
|
53
56
|
handle_SIGINT: handle_SIGINT,
|
@@ -118,8 +121,8 @@ class Puppeteer::Puppeteer
|
|
118
121
|
end
|
119
122
|
|
120
123
|
# @return [String]
|
121
|
-
def executable_path
|
122
|
-
launcher.executable_path
|
124
|
+
def executable_path(channel: nil)
|
125
|
+
launcher.executable_path(channel: channel)
|
123
126
|
end
|
124
127
|
|
125
128
|
private def launcher
|
data/lib/puppeteer/version.rb
CHANGED
data/puppeteer-ruby.gemspec
CHANGED
@@ -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.18.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.35.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YusukeIwaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.
|
173
|
+
version: 1.18.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.18.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: rubocop-rspec
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -294,7 +294,6 @@ files:
|
|
294
294
|
- lib/puppeteer/keyboard/key_description.rb
|
295
295
|
- lib/puppeteer/keyboard/us_keyboard_layout.rb
|
296
296
|
- lib/puppeteer/launcher.rb
|
297
|
-
- lib/puppeteer/launcher/base.rb
|
298
297
|
- lib/puppeteer/launcher/browser_options.rb
|
299
298
|
- lib/puppeteer/launcher/chrome.rb
|
300
299
|
- lib/puppeteer/launcher/chrome_arg_options.rb
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module Puppeteer::Launcher
|
2
|
-
class Base
|
3
|
-
# @param {string} projectRoot
|
4
|
-
# @param {string} preferredRevision
|
5
|
-
def initialize(project_root:, preferred_revision:, is_puppeteer_core:)
|
6
|
-
@project_root = project_root
|
7
|
-
@preferred_revision = preferred_revision
|
8
|
-
@is_puppeteer_core = is_puppeteer_core
|
9
|
-
end
|
10
|
-
|
11
|
-
class ExecutablePathNotFound < StandardError; end
|
12
|
-
|
13
|
-
# @returns [String] Chrome Executable file path.
|
14
|
-
# @raise [ExecutablePathNotFound]
|
15
|
-
def resolve_executable_path
|
16
|
-
if !@is_puppeteer_core
|
17
|
-
# puppeteer-core doesn't take into account PUPPETEER_* env variables.
|
18
|
-
executable_path = ENV['PUPPETEER_EXECUTABLE_PATH']
|
19
|
-
if FileTest.exist?(executable_path)
|
20
|
-
return executable_path
|
21
|
-
end
|
22
|
-
raise ExecutablePathNotFound.new(
|
23
|
-
"Tried to use PUPPETEER_EXECUTABLE_PATH env variable to launch browser but did not find any executable at: #{executable_path}",
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
# temporal logic.
|
28
|
-
if Puppeteer.env.darwin?
|
29
|
-
case self
|
30
|
-
when Chrome
|
31
|
-
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
32
|
-
when Firefox
|
33
|
-
'/Applications/Firefox Nightly.app/Contents/MacOS/firefox'
|
34
|
-
end
|
35
|
-
elsif Puppeteer.env.windows?
|
36
|
-
case self
|
37
|
-
when Chrome
|
38
|
-
'C:\Program Files\Google\Chrome\Application\chrome.exe'
|
39
|
-
# 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe'
|
40
|
-
when Firefox
|
41
|
-
'C:\Program Files\Firefox Nightly\firefox.exe'
|
42
|
-
end
|
43
|
-
else
|
44
|
-
case self
|
45
|
-
when Chrome
|
46
|
-
'/usr/bin/google-chrome'
|
47
|
-
when Firefox
|
48
|
-
'/usr/bin/firefox'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# const browserFetcher = new BrowserFetcher(launcher._projectRoot);
|
53
|
-
# if (!launcher._isPuppeteerCore) {
|
54
|
-
# const revision = process.env['PUPPETEER_CHROMIUM_REVISION'];
|
55
|
-
# if (revision) {
|
56
|
-
# const revisionInfo = browserFetcher.revisionInfo(revision);
|
57
|
-
# const missingText = !revisionInfo.local ? 'Tried to use PUPPETEER_CHROMIUM_REVISION env variable to launch browser but did not find executable at: ' + revisionInfo.executablePath : null;
|
58
|
-
# return {executablePath: revisionInfo.executablePath, missingText};
|
59
|
-
# }
|
60
|
-
# }
|
61
|
-
# const revisionInfo = browserFetcher.revisionInfo(launcher._preferredRevision);
|
62
|
-
# const missingText = !revisionInfo.local ? `Browser is not downloaded. Run "npm install" or "yarn install"` : null;
|
63
|
-
# return {executablePath: revisionInfo.executablePath, missingText};
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|