puppeteer-ruby 0.34.1 → 0.35.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 759579a77012a03fa74915957ff0c3ed656ea4cdcc280b2f24fede885d01f361
4
- data.tar.gz: 390f5ef626fb791dc9744cfe59a977fcd3a9d45c16d32aec60247a652ef73712
3
+ metadata.gz: b6261fae36fcaf6fad5ebcc8a6721496ea1ba7e76cdc770885f1b9cb6c49582b
4
+ data.tar.gz: cd7c4dbc2370568973c4319158e8c0d2f79248f83a7d7fd0a1f00d8c9f38ffa8
5
5
  SHA512:
6
- metadata.gz: aa0d6262ed3953a9b15efc2fdad2be48cd6b22cba0f1b89d7c93b0b9cbd52413705f60fe334cbb57b5f6eabffbb599b98db520859bd1239406def453ca314228
7
- data.tar.gz: 84632098cf49cf5201528e2ac620321b83210bfb4f0a5bd6fae48a86fb5009a8c4e791b666eaf82b110eb4fc55a569723266e850381fe1b7dda49bd9830422d2
6
+ metadata.gz: 0cb8cb7bebc28260088f3f558225c83f8e15bfbe539c0eabbca2fdcf324e941d3c4f61ebd08b57600bf3a366219bcb2f9c0930e250f796caca367601baab9daf
7
+ data.tar.gz: e3532e2a9b2da82d819b6946a7c4b2b870312dfb359739b997a7f2c72bc13772998a89453a3e244e64d0db0a6c9f6f70b95d86ba2d02c1b7d8cd5411a67c482f
data/CHANGELOG.md CHANGED
@@ -1,7 +1,31 @@
1
- ### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.1...master)]
1
+ ### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.35.1...master)]
2
2
 
3
3
  * xxx
4
4
 
5
+ ### 0.35.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.35.0...0.35.1)]
6
+
7
+ New features:
8
+
9
+ * Allow Rails users to use this library without `require 'puppeteer'`.
10
+
11
+ ### 0.35.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.3...0.35.0)]
12
+
13
+ New features:
14
+
15
+ * 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`.
16
+
17
+ ### 0.34.3 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.2...0.34.3)]
18
+
19
+ Bugfix:
20
+
21
+ * Fix wait_for_xxx's timeout error type.
22
+
23
+ ### 0.34.2 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.1...0.34.2)]
24
+
25
+ New features:
26
+
27
+ * Add `Page#bring_to_front`.
28
+
5
29
  ### 0.34.1 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.34.0...0.34.1)]
6
30
 
7
31
  Bugfix:
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.
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.1
2
+ - Puppeteer version: v10.1.0
3
+ - puppeteer-ruby version: 0.35.1
4
4
 
5
5
  ## Puppeteer
6
6
 
@@ -70,7 +70,7 @@
70
70
  * addScriptTag => `#add_script_tag`
71
71
  * addStyleTag => `#add_style_tag`
72
72
  * authenticate
73
- * ~~bringToFront~~
73
+ * bringToFront => `#bring_to_front`
74
74
  * browser
75
75
  * browserContext => `#browser_context`
76
76
  * click
@@ -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`
@@ -0,0 +1,2 @@
1
+ # just an alias.
2
+ require 'puppeteer'
@@ -1,4 +1,3 @@
1
- require_relative './launcher/base'
2
1
  require_relative './launcher/browser_options'
3
2
  require_relative './launcher/chrome'
4
3
  require_relative './launcher/chrome_arg_options'
@@ -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 < Base
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 = @launch_options.executable_path || resolve_executable_path
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
- resolve_executable_path
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 < Base
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 = @launch_options.executable_path || resolve_executable_path
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
- resolve_executable_path
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
@@ -767,6 +767,11 @@ class Puppeteer::Page
767
767
  end
768
768
  end
769
769
 
770
+ # Brings page to front (activates tab).
771
+ def bring_to_front
772
+ @client.send_message('Page.bringToFront')
773
+ end
774
+
770
775
  # @param device [Device]
771
776
  def emulate(device)
772
777
  self.viewport = device.viewport
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Puppeteer
2
- VERSION = '0.34.1'
2
+ VERSION = '0.35.1'
3
3
  end
@@ -3,7 +3,7 @@ class Puppeteer::WaitTask
3
3
 
4
4
  class TerminatedError < StandardError; end
5
5
 
6
- class TimeoutError < StandardError
6
+ class TimeoutError < ::Puppeteer::TimeoutError
7
7
  def initialize(title:, timeout:)
8
8
  super("waiting for #{title} failed: timeout #{timeout}ms exceeded")
9
9
  end
@@ -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.17.0'
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.34.1
4
+ version: 0.35.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2021-07-23 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.17.0
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.17.0
180
+ version: 1.18.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rubocop-rspec
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -244,15 +244,14 @@ files:
244
244
  - ".rspec"
245
245
  - ".rubocop.yml"
246
246
  - CHANGELOG.md
247
- - Dockerfile
248
247
  - Gemfile
249
248
  - LICENSE
250
249
  - README.md
251
250
  - Rakefile
252
251
  - bin/console
253
252
  - bin/setup
254
- - docker-compose.yml
255
253
  - docs/api_coverage.md
254
+ - lib/puppeteer-ruby.rb
256
255
  - lib/puppeteer.rb
257
256
  - lib/puppeteer/aria_query_handler.rb
258
257
  - lib/puppeteer/browser.rb
@@ -294,7 +293,6 @@ files:
294
293
  - lib/puppeteer/keyboard/key_description.rb
295
294
  - lib/puppeteer/keyboard/us_keyboard_layout.rb
296
295
  - lib/puppeteer/launcher.rb
297
- - lib/puppeteer/launcher/base.rb
298
296
  - lib/puppeteer/launcher/browser_options.rb
299
297
  - lib/puppeteer/launcher/chrome.rb
300
298
  - lib/puppeteer/launcher/chrome_arg_options.rb
data/Dockerfile DELETED
@@ -1,9 +0,0 @@
1
- FROM circleci/ruby:3.0.0-rc1-buster-node-browsers
2
-
3
- USER root
4
-
5
- RUN wget -O nightly.tar.bz2 "https://download.mozilla.org/?product=firefox-nightly-latest-ssl&os=linux64&lang=en-US" \
6
- && tar xf nightly.tar.bz2 \
7
- && ln -s $(pwd)/firefox/firefox /usr/bin/firefox
8
-
9
- USER circleci
data/docker-compose.yml DELETED
@@ -1,34 +0,0 @@
1
- version: "3"
2
- services:
3
- chrome:
4
- tty: true
5
- stdin_open: true
6
- build: .
7
- environment:
8
- BUNDLE_PATH: /usr/local/bundle
9
- DEBUG: 1
10
- CI: 1
11
- volumes:
12
- - .:/puppeteer-ruby
13
- - bundle-data:/usr/local/bundle
14
- working_dir: /puppeteer-ruby
15
- command: bundle exec rspec
16
-
17
- firefox:
18
- tty: true
19
- stdin_open: true
20
- build: .
21
- environment:
22
- BUNDLE_PATH: /usr/local/bundle
23
- PUPPETEER_PRODUCT_RSPEC: firefox
24
- DEBUG: 1
25
- CI: 1
26
- volumes:
27
- - .:/puppeteer-ruby
28
- - bundle-data:/usr/local/bundle
29
- working_dir: /puppeteer-ruby
30
- command: bundle exec rspec spec/integration/
31
-
32
- volumes:
33
- bundle-data:
34
- driver: local
@@ -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