webdrivers 3.8.0 → 3.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,43 +1,41 @@
1
- require 'nokogiri'
2
-
3
- module Webdrivers
4
- class Geckodriver < Common
5
- class << self
6
- def current_version
7
- Webdrivers.logger.debug 'Checking current version'
8
- return nil unless downloaded?
9
-
10
- string = `#{binary} --version`
11
- Webdrivers.logger.debug "Current version of #{binary} is #{string}"
12
- normalize string.match(/geckodriver (\d+\.\d+\.\d+)/)[1]
13
- end
14
-
15
- private
16
-
17
- def downloads
18
- Webdrivers.logger.debug "Versions previously located on downloads site: #{@downloads.keys}" if @downloads
19
-
20
- @downloads ||= begin
21
- doc = Nokogiri::HTML.parse(get(base_url))
22
- items = doc.css('.py-1 a').collect { |item| item['href'] }
23
- items.reject! { |item| item.include?('archive') }
24
- items.select! { |item| item.include?(platform) }
25
- ds = items.each_with_object({}) do |item, hash|
26
- key = normalize item[/v(\d+\.\d+\.\d+)/, 1]
27
- hash[key] = "https://github.com#{item}"
28
- end
29
- Webdrivers.logger.debug "Versions now located on downloads site: #{ds.keys}"
30
- ds
31
- end
32
- end
33
-
34
- def file_name
35
- platform == 'win' ? 'geckodriver.exe' : 'geckodriver'
36
- end
37
-
38
- def base_url
39
- 'https://github.com/mozilla/geckodriver/releases'
40
- end
41
- end
42
- end
43
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'nokogiri'
4
+
5
+ module Webdrivers
6
+ class Geckodriver < Common
7
+ class << self
8
+ def current_version
9
+ Webdrivers.logger.debug 'Checking current version'
10
+ return nil unless downloaded?
11
+
12
+ string = `#{binary} --version`
13
+ Webdrivers.logger.debug "Current version of #{binary} is #{string}"
14
+ normalize_version string.match(/geckodriver (\d+\.\d+\.\d+)/)[1]
15
+ end
16
+
17
+ private
18
+
19
+ def downloads # rubocop:disable Metrics/AbcSize
20
+ doc = Nokogiri::HTML.parse(get(base_url))
21
+ items = doc.css('.py-1 a').collect { |item| item['href'] }
22
+ items.reject! { |item| item.include?('archive') }
23
+ items.select! { |item| item.include?(platform) }
24
+ ds = items.each_with_object({}) do |item, hash|
25
+ key = normalize_version item[/v(\d+\.\d+\.\d+)/, 1]
26
+ hash[key] = "https://github.com#{item}"
27
+ end
28
+ Webdrivers.logger.debug "Versions now located on downloads site: #{ds.keys}"
29
+ ds
30
+ end
31
+
32
+ def file_name
33
+ platform == 'win' ? 'geckodriver.exe' : 'geckodriver'
34
+ end
35
+
36
+ def base_url
37
+ 'https://github.com/mozilla/geckodriver/releases'
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,43 +1,41 @@
1
- require 'nokogiri'
2
- require 'rubygems/version'
3
-
4
- module Webdrivers
5
- class IEdriver < Common
6
- class << self
7
- def current_version
8
- Webdrivers.logger.debug 'Checking current version'
9
- return nil unless downloaded?
10
-
11
- string = `#{binary} --version`
12
- Webdrivers.logger.debug "Current version of #{binary} is #{string}"
13
- normalize string.match(/IEDriverServer.exe (\d\.\d+\.\d*\.\d*)/)[1]
14
- end
15
-
16
- private
17
-
18
- def file_name
19
- 'IEDriverServer.exe'
20
- end
21
-
22
- def base_url
23
- 'https://selenium-release.storage.googleapis.com/'
24
- end
25
-
26
- def downloads
27
- Webdrivers.logger.debug "Versions previously located on downloads site: #{@downloads.keys}" if @downloads
28
-
29
- @downloads ||= begin
30
- doc = Nokogiri::XML.parse(get(base_url))
31
- items = doc.css('Key').collect(&:text)
32
- items.select! { |item| item.include?('IEDriverServer_Win32') }
33
- ds = items.each_with_object({}) do |item, hash|
34
- key = normalize item[/([^_]+)\.zip/, 1]
35
- hash[key] = "#{base_url}#{item}"
36
- end
37
- Webdrivers.logger.debug "Versions now located on downloads site: #{ds.keys}"
38
- ds
39
- end
40
- end
41
- end
42
- end
43
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'nokogiri'
4
+ require 'rubygems/version'
5
+
6
+ module Webdrivers
7
+ class IEdriver < Common
8
+ class << self
9
+ def current_version
10
+ Webdrivers.logger.debug 'Checking current version'
11
+ return nil unless downloaded?
12
+
13
+ string = `#{binary} --version`
14
+ Webdrivers.logger.debug "Current version of #{binary} is #{string}"
15
+ normalize_version string.match(/IEDriverServer.exe (\d\.\d+\.\d*\.\d*)/)[1]
16
+ end
17
+
18
+ private
19
+
20
+ def file_name
21
+ 'IEDriverServer.exe'
22
+ end
23
+
24
+ def base_url
25
+ 'https://selenium-release.storage.googleapis.com/'
26
+ end
27
+
28
+ def downloads
29
+ doc = Nokogiri::XML.parse(get(base_url))
30
+ items = doc.css('Key').collect(&:text)
31
+ items.select! { |item| item.include?('IEDriverServer_Win32') }
32
+ ds = items.each_with_object({}) do |item, hash|
33
+ key = normalize_version item[/([^_]+)\.zip/, 1]
34
+ hash[key] = "#{base_url}#{item}"
35
+ end
36
+ Webdrivers.logger.debug "Versions now located on downloads site: #{ds.keys}"
37
+ ds
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,109 +1,111 @@
1
- require 'forwardable'
2
- require 'logger'
3
-
4
- # Code adapted from Selenium Implementation
5
- # https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/common/logger.rb
6
-
7
- module Webdrivers
8
- #
9
- # @example Enable full logging
10
- # Webdrivers.logger.level = :debug
11
- #
12
- # @example Log to file
13
- # Webdrivers.logger.output = 'webdrivers.log'
14
- #
15
- # @example Use logger manually
16
- # Webdrivers.logger.info('This is info message')
17
- # Webdrivers.logger.warn('This is warning message')
18
- #
19
- class Logger
20
- extend Forwardable
21
- include ::Logger::Severity
22
-
23
- def_delegators :@logger, :debug, :debug?,
24
- :info, :info?,
25
- :warn, :warn?,
26
- :error, :error?,
27
- :fatal, :fatal?,
28
- :level
29
-
30
- def initialize
31
- @logger = create_logger($stdout)
32
- end
33
-
34
- def output=(io)
35
- # `Logger#reopen` was added in Ruby 2.3
36
- if @logger.respond_to?(:reopen)
37
- @logger.reopen(io)
38
- else
39
- @logger = create_logger(io)
40
- end
41
- end
42
-
43
- #
44
- # For Ruby < 2.3 compatibility
45
- # Based on https://github.com/ruby/ruby/blob/ruby_2_3/lib/logger.rb#L250
46
- #
47
-
48
- def level=(severity)
49
- if severity.is_a?(Integer)
50
- @logger.level = severity
51
- else
52
- case severity.to_s.downcase
53
- when 'debug'.freeze
54
- @logger.level = DEBUG
55
- when 'info'.freeze
56
- @logger.level = INFO
57
- when 'warn'.freeze
58
- @logger.level = WARN
59
- when 'error'.freeze
60
- @logger.level = ERROR
61
- when 'fatal'.freeze
62
- @logger.level = FATAL
63
- when 'unknown'.freeze
64
- @logger.level = UNKNOWN
65
- else
66
- raise ArgumentError, "invalid log level: #{severity}"
67
- end
68
- end
69
- end
70
-
71
- #
72
- # Returns IO object used by logger internally.
73
- #
74
- # Normally, we would have never needed it, but we want to
75
- # use it as IO object for all child processes to ensure their
76
- # output is redirected there.
77
- #
78
- # It is only used in debug level, in other cases output is suppressed.
79
- #
80
- # @api private
81
- #
82
- def io
83
- @logger.instance_variable_get(:@logdev).instance_variable_get(:@dev)
84
- end
85
-
86
- #
87
- # Marks code as deprecated with replacement.
88
- #
89
- # @param [String] old
90
- # @param [String] new
91
- #
92
- def deprecate(old, new)
93
- warn "[DEPRECATION] #{old} is deprecated. Use #{new} instead."
94
- end
95
-
96
- private
97
-
98
- def create_logger(output)
99
- logger = ::Logger.new(output)
100
- logger.progname = 'Webdrivers'
101
- logger.level = ($DEBUG ? DEBUG : WARN)
102
- logger.formatter = proc do |severity, time, progname, msg|
103
- "#{time.strftime('%F %T')} #{severity} #{progname} #{msg}\n"
104
- end
105
-
106
- logger
107
- end
108
- end
109
- end
1
+ # frozen_string_literal: true
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
+ module Webdrivers
10
+ #
11
+ # @example Enable full logging
12
+ # Webdrivers.logger.level = :debug
13
+ #
14
+ # @example Log to file
15
+ # Webdrivers.logger.output = 'webdrivers.log'
16
+ #
17
+ # @example Use logger manually
18
+ # Webdrivers.logger.info('This is info message')
19
+ # Webdrivers.logger.warn('This is warning message')
20
+ #
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
+
32
+ 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
109
+ end
110
+ end
111
+ end
@@ -1,57 +1,59 @@
1
- module Webdrivers
2
- class MSWebdriver < Common
3
- class << self
4
- def windows_version
5
- Webdrivers.logger.debug 'Checking current version'
6
-
7
- # current_version() from other webdrivers returns the version from the webdriver EXE.
8
- # Unfortunately, MicrosoftWebDriver.exe does not have an option to get the version.
9
- # To work around it we query the currently installed version of Microsoft Edge instead
10
- # and compare it to the list of available downloads.
11
- version = `powershell (Get-AppxPackage -Name Microsoft.MicrosoftEdge).Version`
12
- raise 'Failed to check Microsoft Edge version.' if version.empty? # Package name changed?
13
-
14
- Webdrivers.logger.debug "Current version of Microsoft Edge is #{version.chomp!}"
15
-
16
- build = version.split('.')[1] # "41.16299.248.0" => "16299"
17
- Webdrivers.logger.debug "Expecting MicrosoftWebDriver.exe version #{build}"
18
- build.to_i
19
- end
20
-
21
- # Webdriver binaries for Microsoft Edge are not backwards compatible.
22
- # For this reason, instead of downloading the latest binary we download the correct one for the
23
- # currently installed browser version.
24
- alias version windows_version
25
-
26
- def version=(*)
27
- raise 'Version can not be set for MSWebdriver because it is dependent on the version of Edge'
28
- end
29
-
30
- private
31
-
32
- def file_name
33
- 'MicrosoftWebDriver.exe'
34
- end
35
-
36
- def downloads
37
- array = Nokogiri::HTML(get(base_url)).xpath("//li[@class='driver-download']/a")
38
- array.each_with_object({}) do |link, hash|
39
- next if link.text == 'Insiders'
40
-
41
- key = normalize link.text.scan(/\d+/).first.to_i
42
- hash[key] = link['href']
43
- end
44
- end
45
-
46
- def base_url
47
- 'https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/'
48
- end
49
-
50
- # Assume we have the latest if file exists since MicrosoftWebdriver.exe does not have an
51
- # argument to check the current version.
52
- def correct_binary?
53
- File.exist?(binary)
54
- end
55
- end
56
- end
57
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Webdrivers
4
+ class MSWebdriver < Common
5
+ class << self
6
+ def windows_version
7
+ Webdrivers.logger.debug 'Checking current version'
8
+
9
+ # current_version() from other webdrivers returns the version from the webdriver EXE.
10
+ # Unfortunately, MicrosoftWebDriver.exe does not have an option to get the version.
11
+ # To work around it we query the currently installed version of Microsoft Edge instead
12
+ # and compare it to the list of available downloads.
13
+ version = `powershell (Get-AppxPackage -Name Microsoft.MicrosoftEdge).Version`
14
+ raise 'Failed to check Microsoft Edge version.' if version.empty? # Package name changed?
15
+
16
+ Webdrivers.logger.debug "Current version of Microsoft Edge is #{version.chomp!}"
17
+
18
+ build = version.split('.')[1] # "41.16299.248.0" => "16299"
19
+ Webdrivers.logger.debug "Expecting MicrosoftWebDriver.exe version #{build}"
20
+ build.to_i
21
+ end
22
+
23
+ # Webdriver binaries for Microsoft Edge are not backwards compatible.
24
+ # For this reason, instead of downloading the latest binary we download the correct one for the
25
+ # currently installed browser version.
26
+ alias version windows_version
27
+
28
+ def version=(*)
29
+ raise 'Version can not be set for MSWebdriver because it is dependent on the version of Edge'
30
+ end
31
+
32
+ private
33
+
34
+ def file_name
35
+ 'MicrosoftWebDriver.exe'
36
+ end
37
+
38
+ def downloads
39
+ array = Nokogiri::HTML(get(base_url)).xpath("//li[@class='driver-download']/a")
40
+ array.each_with_object({}) do |link, hash|
41
+ next if link.text == 'Insiders'
42
+
43
+ key = normalize_version link.text.scan(/\d+/).first.to_i
44
+ hash[key] = link['href']
45
+ end
46
+ end
47
+
48
+ def base_url
49
+ 'https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/'
50
+ end
51
+
52
+ # Assume we have the latest if file exists since MicrosoftWebdriver.exe does not have an
53
+ # argument to check the current version.
54
+ def correct_binary?
55
+ File.exist?(binary)
56
+ end
57
+ end
58
+ end
59
+ end