webdrivers 4.0.1 → 5.2.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.
@@ -29,9 +29,14 @@ module Webdrivers
29
29
  def latest_version
30
30
  @latest_version ||= begin
31
31
  # Versions before 70 do not have a LATEST_RELEASE file
32
- return normalize_version('2.41') if release_version < normalize_version('70')
32
+ return normalize_version('2.41') if browser_build_version < normalize_version('70')
33
33
 
34
- latest_applicable = with_cache(file_name) { latest_point_release(release_version) }
34
+ # Cache check
35
+ # Cached version should exist and be compatible with the current browser version.
36
+ # Otherwise, fetch the latest compatible driver.
37
+ latest_applicable = with_cache(file_name,
38
+ current_build_version,
39
+ browser_build_version) { latest_point_release(browser_build_version) }
35
40
 
36
41
  Webdrivers.logger.debug "Latest version available: #{latest_applicable}"
37
42
  normalize_version(latest_applicable)
@@ -42,9 +47,10 @@ module Webdrivers
42
47
  # Returns currently installed Chrome/Chromium version.
43
48
  #
44
49
  # @return [Gem::Version]
45
- def chrome_version
50
+ def browser_version
46
51
  normalize_version ChromeFinder.version
47
52
  end
53
+ alias chrome_version browser_version
48
54
 
49
55
  #
50
56
  # Returns url with domain for calls to get this driver.
@@ -67,64 +73,84 @@ module Webdrivers
67
73
  else
68
74
  msg
69
75
  end
70
- rescue NetworkError
71
- "#{msg} A network issue is preventing determination of latest chromedriver release."
76
+ rescue NetworkError
77
+ "#{msg} A network issue is preventing determination of latest chromedriver release."
72
78
  end
73
79
 
74
80
  msg = "#{msg} Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` "\
75
- 'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
76
-
81
+ 'to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html'
77
82
  Webdrivers.logger.debug msg
78
83
  raise VersionError, msg
79
84
  end
80
85
 
81
86
  def file_name
82
- System.platform == 'win' ? 'chromedriver.exe' : 'chromedriver'
87
+ System.platform == 'win' || System.wsl_v1? ? 'chromedriver.exe' : 'chromedriver'
88
+ end
89
+
90
+ def apple_m1_compatible?(driver_version)
91
+ if System.apple_m1_architecture? && driver_version >= normalize_version('87.0.4280.88')
92
+ Webdrivers.logger.debug 'chromedriver version is Apple M1 compatible.'
93
+ return true
94
+ end
95
+
96
+ Webdrivers.logger.debug 'chromedriver version is NOT Apple M1 compatible. Required >= 87.0.4280.88'
97
+ false
83
98
  end
84
99
 
85
- def download_url
86
- return @download_url if @download_url
100
+ def apple_filename(driver_version)
101
+ if apple_m1_compatible?(driver_version)
102
+ driver_version >= normalize_version('106.0.5249.61') ? 'mac_arm64' : 'mac64_m1'
103
+ else
104
+ 'mac64'
105
+ end
106
+ end
107
+
108
+ def direct_url(driver_version)
109
+ "#{base_url}/#{driver_version}/chromedriver_#{driver_filename(driver_version)}.zip"
110
+ end
87
111
 
88
- version = if required_version == EMPTY_VERSION
89
- latest_version
90
- else
91
- normalize_version(required_version)
92
- end
112
+ def driver_filename(driver_version)
113
+ if System.platform == 'win' || System.wsl_v1?
114
+ 'win32'
115
+ elsif System.platform == 'linux'
116
+ 'linux64'
117
+ elsif System.platform == 'mac'
118
+ apple_filename(driver_version)
119
+ else
120
+ raise 'Failed to determine driver filename to download for your OS.'
121
+ end
122
+ end
93
123
 
94
- file_name = System.platform == 'win' ? 'win32' : "#{System.platform}64"
95
- url = "#{base_url}/#{version}/chromedriver_#{file_name}.zip"
96
- Webdrivers.logger.debug "chromedriver URL: #{url}"
97
- @download_url = url
124
+ # Returns major.minor.build version from the currently installed chromedriver version
125
+ #
126
+ # @example
127
+ # 73.0.3683.68 (major.minor.build.patch) -> 73.0.3683 (major.minor.build)
128
+ def current_build_version
129
+ build_ver = if current_version.nil? # Driver not found
130
+ nil
131
+ else
132
+ current_version.segments[0..2].join('.')
133
+ end
134
+ normalize_version(build_ver)
98
135
  end
99
136
 
100
- # Returns release version from the currently installed Chrome version
137
+ # Returns major.minor.build version from the currently installed Chrome version
101
138
  #
102
139
  # @example
103
- # 73.0.3683.75 -> 73.0.3683
104
- def release_version
105
- chrome = normalize_version(chrome_version)
106
- normalize_version(chrome.segments[0..2].join('.'))
140
+ # 73.0.3683.75 (major.minor.build.patch) -> 73.0.3683 (major.minor.build)
141
+ def browser_build_version
142
+ normalize_version(browser_version.segments[0..2].join('.'))
107
143
  end
144
+ alias chrome_build_version browser_build_version
108
145
 
146
+ # Returns true if an executable driver binary exists
147
+ # and its build version matches the browser build version
109
148
  def sufficient_binary?
110
149
  super && current_version && (current_version < normalize_version('70.0.3538') ||
111
- current_version.segments.first == release_version.segments.first)
150
+ current_build_version == browser_build_version)
112
151
  end
113
152
  end
114
153
  end
115
154
  end
116
155
 
117
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
118
- ::Selenium::WebDriver::Chrome::Service.driver_path = proc { ::Webdrivers::Chromedriver.update }
119
- else
120
- # v3.141.0 and lower
121
- module Selenium
122
- module WebDriver
123
- module Chrome
124
- def self.driver_path
125
- @driver_path ||= Webdrivers::Chromedriver.update
126
- end
127
- end
128
- end
129
- end
130
- end
156
+ ::Selenium::WebDriver::Chrome::Service.driver_path = proc { ::Webdrivers::Chromedriver.update }
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rubygems/package'
4
- require 'zip'
5
- require 'webdrivers/logger'
6
4
  require 'webdrivers/network'
7
5
  require 'webdrivers/system'
8
6
  require 'selenium-webdriver'
7
+ require 'webdrivers/logger'
9
8
  require 'webdrivers/version'
10
9
 
11
10
  module Webdrivers
@@ -18,7 +17,11 @@ module Webdrivers
18
17
  class NetworkError < StandardError
19
18
  end
20
19
 
20
+ class BrowserNotFound < StandardError
21
+ end
22
+
21
23
  DEFAULT_CACHE_TIME = 86_400 # 24 hours
24
+ DEFAULT_INSTALL_DIR = File.expand_path('~/.webdrivers')
22
25
 
23
26
  class << self
24
27
  attr_accessor :proxy_addr, :proxy_port, :proxy_user, :proxy_pass
@@ -30,7 +33,8 @@ module Webdrivers
30
33
  # are set, it defaults to 86,400 Seconds (24 hours).
31
34
  #
32
35
  def cache_time
33
- (ENV['WD_CACHE_TIME'] || @cache_time || DEFAULT_CACHE_TIME).to_i
36
+ @cache_time ||= (ENV['WD_CACHE_TIME'] || DEFAULT_CACHE_TIME)
37
+ @cache_time.to_i
34
38
  end
35
39
 
36
40
  #
@@ -38,7 +42,7 @@ module Webdrivers
38
42
  #
39
43
  # @return [String]
40
44
  def install_dir
41
- @install_dir || ENV['WD_INSTALL_DIR'] || File.expand_path(File.join(ENV['HOME'], '.webdrivers'))
45
+ @install_dir ||= ENV['WD_INSTALL_DIR'] || DEFAULT_INSTALL_DIR
42
46
  end
43
47
 
44
48
  def logger
@@ -65,7 +69,7 @@ module Webdrivers
65
69
  raise 'Webdrivers.net_http_ssl_fix is no longer available.' \
66
70
  ' Please see https://github.com/titusfortner/webdrivers#ssl_connect-errors.'
67
71
  end
68
- end
72
+ end
69
73
 
70
74
  class Common
71
75
  class << self
@@ -76,7 +80,7 @@ end
76
80
  #
77
81
  # @return [Gem::Version]
78
82
  def required_version
79
- normalize_version @required_version
83
+ normalize_version(@required_version ||= nil)
80
84
  end
81
85
 
82
86
  #
@@ -109,17 +113,17 @@ end
109
113
  #
110
114
  # @return [String]
111
115
  def driver_path
112
- System.escape_path File.join(System.install_dir, file_name)
116
+ File.absolute_path File.join(System.install_dir, file_name)
113
117
  end
114
118
 
115
119
  private
116
120
 
121
+ def download_version
122
+ required_version == EMPTY_VERSION ? latest_version : required_version
123
+ end
124
+
117
125
  def download_url
118
- @download_url ||= if required_version == EMPTY_VERSION
119
- downloads[downloads.keys.max]
120
- else
121
- downloads[normalize_version(required_version)]
122
- end
126
+ @download_url ||= direct_url(download_version).tap { |url| Webdrivers.logger.debug "#{file_name} URL: #{url}" }
123
127
  end
124
128
 
125
129
  def exists?
@@ -127,11 +131,7 @@ end
127
131
  end
128
132
 
129
133
  def correct_binary?
130
- current_version == if required_version == EMPTY_VERSION
131
- latest_version
132
- else
133
- normalize_version(required_version)
134
- end
134
+ current_version == download_version
135
135
  rescue ConnectionError, VersionError
136
136
  driver_path if sufficient_binary?
137
137
  end
@@ -145,7 +145,7 @@ end
145
145
  end
146
146
 
147
147
  def binary_version
148
- version = System.call("#{driver_path} --version")
148
+ version = System.call(driver_path, '--version')
149
149
  Webdrivers.logger.debug "Current version of #{driver_path} is #{version}"
150
150
  version
151
151
  rescue Errno::ENOENT
@@ -153,9 +153,15 @@ end
153
153
  nil
154
154
  end
155
155
 
156
- def with_cache(file_name)
157
- if System.valid_cache?(file_name)
158
- normalize_version System.cached_version(file_name)
156
+ # Returns cached driver version if cache is still valid and the driver binary exists.
157
+ # Otherwise caches the given version (typically the latest available)
158
+ # In case of Chrome, it also verifies that the driver build and browser build versions are compatible.
159
+ # Example usage: lib/webdrivers/chromedriver.rb:34
160
+ def with_cache(file_name, driver_build = nil, browser_build = nil)
161
+ if System.valid_cache?(file_name) && exists? && (driver_build == browser_build)
162
+ cached_version = System.cached_version(file_name)
163
+ Webdrivers.logger.debug "using cached version as latest: #{cached_version}"
164
+ normalize_version cached_version
159
165
  else
160
166
  version = yield
161
167
  System.cache_version(file_name, version)
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Webdrivers
4
+ #
5
+ # @api private
6
+ #
7
+ class EdgeFinder
8
+ class << self
9
+ def version
10
+ version = send("#{System.platform}_version", location)
11
+ raise VersionError, 'Failed to find Edge version.' if version.nil? || version.empty?
12
+
13
+ Webdrivers.logger.debug "Browser version: #{version}"
14
+ version[/\d+\.\d+\.\d+\.\d+/] # Microsoft Edge 73.0.3683.75 -> 73.0.3683.75
15
+ end
16
+
17
+ def location
18
+ edge_bin = user_defined_location || send("#{System.platform}_location")
19
+ return edge_bin unless edge_bin.nil?
20
+
21
+ raise BrowserNotFound, 'Failed to find Edge binary.'
22
+ end
23
+
24
+ private
25
+
26
+ def user_defined_location
27
+ if Selenium::WebDriver::Edge.path
28
+ Webdrivers.logger.debug "Selenium::WebDriver::Edge.path: #{Selenium::WebDriver::Edge.path}"
29
+ return Selenium::WebDriver::Edge.path
30
+ end
31
+
32
+ return if ENV['WD_EDGE_PATH'].nil?
33
+
34
+ Webdrivers.logger.debug "WD_EDGE_PATH: #{ENV['WD_EDGE_PATH']}"
35
+ ENV['WD_EDGE_PATH']
36
+ end
37
+
38
+ def win_location
39
+ envs = %w[LOCALAPPDATA PROGRAMFILES PROGRAMFILES(X86)]
40
+ directories = ['\\Microsoft\\Edge\\Application',
41
+ '\\Microsoft\\Edge Beta\\Application',
42
+ '\\Microsoft\\Edge Dev\\Application',
43
+ '\\Microsoft\\Edge SxS\\Application']
44
+ file = 'msedge.exe'
45
+
46
+ directories.each do |dir|
47
+ envs.each do |root|
48
+ option = "#{ENV[root]}\\#{dir}\\#{file}"
49
+ return option if File.exist?(option)
50
+ end
51
+ end
52
+ nil
53
+ end
54
+
55
+ def mac_location
56
+ directories = ['', File.expand_path('~')]
57
+ files = ['/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
58
+ '/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge Beta',
59
+ '/Applications/Microsoft Edge Dev.app/Contents/MacOS/Microsoft Edge Dev',
60
+ '/Applications/Microsoft Edge Canary.app/Contents/MacOS/Microsoft Edge Canary']
61
+
62
+ directories.each do |dir|
63
+ files.each do |file|
64
+ option = "#{dir}/#{file}"
65
+ return option if File.exist?(option)
66
+ end
67
+ end
68
+ nil
69
+ end
70
+
71
+ def linux_location
72
+ directories = %w[/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin /opt/microsoft/edge]
73
+ files = %w[microsoft-edge microsoft-edge-beta microsoft-edge-dev]
74
+
75
+ directories.each do |dir|
76
+ files.each do |file|
77
+ option = "#{dir}/#{file}"
78
+ return option if File.exist?(option)
79
+ end
80
+ end
81
+
82
+ nil
83
+ end
84
+
85
+ def win_version(location)
86
+ System.call("powershell (Get-ItemProperty '#{location}').VersionInfo.ProductVersion")&.strip
87
+ end
88
+
89
+ def linux_version(location)
90
+ System.call(location, '--product-version')&.strip
91
+ end
92
+
93
+ def mac_version(location)
94
+ System.call(location, '--version')&.strip
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'shellwords'
4
+ require 'webdrivers/common'
5
+ require 'webdrivers/chromedriver'
6
+ require 'webdrivers/edge_finder'
7
+
8
+ module Webdrivers
9
+ class Edgedriver < Chromedriver
10
+ class << self
11
+ undef :chrome_version
12
+ #
13
+ # Returns currently installed Edge version.
14
+ #
15
+ # @return [Gem::Version]
16
+ def browser_version
17
+ normalize_version EdgeFinder.version
18
+ end
19
+
20
+ #
21
+ # Returns url with domain for calls to get this driver.
22
+ #
23
+ # @return [String]
24
+ def base_url
25
+ 'https://msedgedriver.azureedge.net'
26
+ end
27
+
28
+ private
29
+
30
+ def latest_point_release(version)
31
+ # Microsoft doesn't currently provide LATEST_RELEASE_X.Y.Z - only use X
32
+ # but require the driver version be >= the passed in version
33
+ str = Network.get(URI.join(base_url, "LATEST_RELEASE_#{version.segments[0]}"))
34
+ latest_release = normalize_version(str.encode('ASCII-8BIT', 'UTF-16'))
35
+ raise VersionError unless latest_release >= version
36
+
37
+ latest_release
38
+ rescue NetworkError, VersionError
39
+ msg = failed_to_find_message(version)
40
+ Webdrivers.logger.debug msg
41
+ raise VersionError, msg
42
+ end
43
+
44
+ def failed_to_find_message(version)
45
+ msg = "Unable to find latest point release version for #{version}."
46
+ msg = begin
47
+ # str = Network.get(URI.join(base_url, 'LATEST_RELEASE'))
48
+ # Microsoft doesn't yet/ever support LATEST_RELEASE - Use Canary as latest
49
+ str = Network.get(URI.join(base_url, 'LATEST_CANARY'))
50
+ latest_release = normalize_version(str.encode('ASCII-8BIT', 'UTF-16'))
51
+ if version > latest_release
52
+ "#{msg} You appear to be using a non-production version of Edge."
53
+ else
54
+ msg
55
+ end
56
+ rescue NetworkError
57
+ "#{msg} A network issue is preventing determination of latest msedgedriver release."
58
+ end
59
+
60
+ "#{msg} Please set `Webdrivers::Edgedriver.required_version = <desired driver version>` "\
61
+ "to a known edgedriver version: Can not reach #{base_url}"
62
+ end
63
+
64
+ def file_name
65
+ System.platform == 'win' ? 'msedgedriver.exe' : 'msedgedriver'
66
+ end
67
+
68
+ def apple_m1_compatible?(driver_version)
69
+ if System.apple_m1_architecture? && driver_version >= normalize_version('87.0.669.0')
70
+ Webdrivers.logger.debug 'msedgedriver version is Apple M1 compatible.'
71
+ return true
72
+ end
73
+
74
+ Webdrivers.logger.debug 'msedgedriver version is NOT Apple M1 compatible. Required >= 87.0.669.0'
75
+ false
76
+ end
77
+
78
+ def driver_filename(driver_version)
79
+ if System.platform == 'win' || System.wsl_v1?
80
+ "win#{System.bitsize}" # 32 or 64-bit
81
+ elsif System.platform == 'linux'
82
+ 'linux64'
83
+ elsif System.platform == 'mac'
84
+ # Determine M1 or Intel architecture
85
+ apple_arch = apple_m1_compatible?(driver_version) ? 'arm' : 'mac'
86
+ "#{apple_arch}64"
87
+ else
88
+ raise 'Failed to determine driver filename to download for your OS.'
89
+ end
90
+ end
91
+
92
+ def direct_url(driver_version)
93
+ "#{base_url}/#{driver_version}/edgedriver_#{driver_filename(driver_version)}.zip"
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ ::Selenium::WebDriver::Edge::Service.driver_path = proc { ::Webdrivers::Edgedriver.update }
@@ -42,14 +42,6 @@ module Webdrivers
42
42
  System.platform == 'win' ? 'geckodriver.exe' : 'geckodriver'
43
43
  end
44
44
 
45
- def download_url
46
- @download_url ||= if required_version == EMPTY_VERSION
47
- direct_url(latest_version)
48
- else
49
- direct_url(required_version)
50
- end
51
- end
52
-
53
45
  def direct_url(version)
54
46
  "#{base_url}/download/v#{version}/geckodriver-v#{version}-#{platform_ext}"
55
47
  end
@@ -59,7 +51,7 @@ module Webdrivers
59
51
  when 'linux'
60
52
  "linux#{System.bitsize}.tar.gz"
61
53
  when 'mac'
62
- 'macos.tar.gz'
54
+ System.apple_m1_architecture? ? 'macos-aarch64.tar.gz' : 'macos.tar.gz'
63
55
  when 'win'
64
56
  "win#{System.bitsize}.zip"
65
57
  end
@@ -68,17 +60,4 @@ module Webdrivers
68
60
  end
69
61
  end
70
62
 
71
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
72
- ::Selenium::WebDriver::Firefox::Service.driver_path = proc { ::Webdrivers::Geckodriver.update }
73
- else
74
- # v3.141.0 and lower
75
- module Selenium
76
- module WebDriver
77
- module Firefox
78
- def self.driver_path
79
- @driver_path ||= Webdrivers::Geckodriver.update
80
- end
81
- end
82
- end
83
- end
84
- end
63
+ ::Selenium::WebDriver::Firefox::Service.driver_path = proc { ::Webdrivers::Geckodriver.update }
@@ -34,7 +34,7 @@ module Webdrivers
34
34
  #
35
35
  # @return [String]
36
36
  def base_url
37
- 'https://selenium-release.storage.googleapis.com/'
37
+ 'https://api.github.com/repos/seleniumhq/selenium/releases'
38
38
  end
39
39
 
40
40
  private
@@ -43,32 +43,26 @@ module Webdrivers
43
43
  'IEDriverServer.exe'
44
44
  end
45
45
 
46
+ def direct_url(version)
47
+ downloads[version]
48
+ end
49
+
46
50
  def downloads
47
- doc = Nokogiri::XML.parse(Network.get(base_url))
48
- items = doc.css('Key').collect(&:text)
49
- items.select! { |item| item.include?('IEDriverServer_Win32') }
50
- ds = items.each_with_object({}) do |item, hash|
51
- key = normalize_version item[/([^_]+)\.zip/, 1]
52
- hash[key] = "#{base_url}#{item}"
51
+ ds = download_manifest.each_with_object({}) do |item, hash|
52
+ version = normalize_version item['name'][/\.?([^_]+)\.zip/, 1]
53
+ hash[version] = item['browser_download_url']
53
54
  end
54
55
  Webdrivers.logger.debug "Versions now located on downloads site: #{ds.keys}"
55
56
  ds
56
57
  end
57
- end
58
- end
59
- end
60
58
 
61
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
62
- ::Selenium::WebDriver::IE::Service.driver_path = proc { ::Webdrivers::IEdriver.update }
63
- else
64
- # v3.141.0 and lower
65
- module Selenium
66
- module WebDriver
67
- module IE
68
- def self.driver_path
69
- @driver_path ||= Webdrivers::IEdriver.update
70
- end
59
+ def download_manifest
60
+ json = Network.get(base_url)
61
+ all_assets = JSON.parse(json).map { |release| release['assets'] }.flatten
62
+ all_assets.select { |asset| asset['name'].include?('IEDriverServer_Win32') }
71
63
  end
72
64
  end
73
65
  end
74
66
  end
67
+
68
+ ::Selenium::WebDriver::IE::Service.driver_path = proc { ::Webdrivers::IEdriver.update }
@@ -1,11 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'forwardable'
4
- require 'logger'
5
-
6
- # Code adapted from Selenium Implementation
7
- # https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/common/logger.rb
8
-
9
3
  module Webdrivers
10
4
  #
11
5
  # @example Enable full logging
@@ -18,94 +12,9 @@ module Webdrivers
18
12
  # Webdrivers.logger.info('This is info message')
19
13
  # Webdrivers.logger.warn('This is warning message')
20
14
  #
21
- class Logger
22
- extend Forwardable
23
- include ::Logger::Severity
24
-
25
- def_delegators :@logger, :debug, :debug?,
26
- :info, :info?,
27
- :warn, :warn?,
28
- :error, :error?,
29
- :fatal, :fatal?,
30
- :level
31
-
15
+ class Logger < Selenium::WebDriver::Logger
32
16
  def initialize
33
- @logger = create_logger($stdout)
34
- end
35
-
36
- def output=(io)
37
- # `Logger#reopen` was added in Ruby 2.3
38
- if @logger.respond_to?(:reopen)
39
- @logger.reopen(io)
40
- else
41
- @logger = create_logger(io)
42
- end
43
- end
44
-
45
- #
46
- # For Ruby < 2.3 compatibility
47
- # Based on https://github.com/ruby/ruby/blob/ruby_2_3/lib/logger.rb#L250
48
- #
49
-
50
- def level=(severity)
51
- if severity.is_a?(Integer)
52
- @logger.level = severity
53
- else
54
- case severity.to_s.downcase
55
- when 'debug'
56
- @logger.level = DEBUG
57
- when 'info'
58
- @logger.level = INFO
59
- when 'warn'
60
- @logger.level = WARN
61
- when 'error'
62
- @logger.level = ERROR
63
- when 'fatal'
64
- @logger.level = FATAL
65
- when 'unknown'
66
- @logger.level = UNKNOWN
67
- else
68
- raise ArgumentError, "invalid log level: #{severity}"
69
- end
70
- end
71
- end
72
-
73
- #
74
- # Returns IO object used by logger internally.
75
- #
76
- # Normally, we would have never needed it, but we want to
77
- # use it as IO object for all child processes to ensure their
78
- # output is redirected there.
79
- #
80
- # It is only used in debug level, in other cases output is suppressed.
81
- #
82
- # @api private
83
- #
84
- def io
85
- @logger.instance_variable_get(:@logdev).instance_variable_get(:@dev)
86
- end
87
-
88
- #
89
- # Marks code as deprecated with replacement.
90
- #
91
- # @param [String] old
92
- # @param [String] new
93
- #
94
- def deprecate(old, new)
95
- warn "[DEPRECATION] #{old} is deprecated. Use #{new} instead."
96
- end
97
-
98
- private
99
-
100
- def create_logger(output)
101
- logger = ::Logger.new(output)
102
- logger.progname = 'Webdrivers'
103
- logger.level = ($DEBUG ? DEBUG : WARN)
104
- logger.formatter = proc do |severity, time, progname, msg|
105
- "#{time.strftime('%F %T')} #{severity} #{progname} #{msg}\n"
106
- end
107
-
108
- logger
17
+ super('Webdrivers')
109
18
  end
110
19
  end
111
20
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'net/http'
4
+
3
5
  module Webdrivers
4
6
  #
5
7
  # @api private