webdrivers 3.6.0 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +6 -6
- data/.travis.yml +11 -7
- data/CHANGELOG.md +100 -96
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +76 -76
- data/Rakefile +6 -6
- data/lib/webdrivers.rb +27 -27
- data/lib/webdrivers/chromedriver.rb +91 -48
- data/lib/webdrivers/common.rb +203 -203
- data/lib/webdrivers/geckodriver.rb +43 -43
- data/lib/webdrivers/iedriver.rb +43 -43
- data/lib/webdrivers/logger.rb +109 -109
- data/lib/webdrivers/mswebdriver.rb +57 -57
- data/lib/webdrivers/selenium.rb +29 -29
- data/spec/chromedriver_spec.rb +77 -75
- data/spec/geckodriver_spec.rb +62 -62
- data/spec/iedriver_spec.rb +38 -38
- data/spec/mswebdriver_spec.rb +26 -26
- data/spec/proxy_support_spec.rb +44 -44
- data/spec/spec_helper.rb +2 -2
- data/webdrivers.gemspec +27 -26
- metadata +12 -17
@@ -1,44 +1,44 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module Webdrivers
|
4
|
-
class Geckodriver < Common
|
5
|
-
class << self
|
6
|
-
|
7
|
-
def current_version
|
8
|
-
Webdrivers.logger.debug "Checking current version"
|
9
|
-
return nil unless downloaded?
|
10
|
-
string = %x(#{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
|
-
|
42
|
-
end
|
43
|
-
end
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Webdrivers
|
4
|
+
class Geckodriver < Common
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def current_version
|
8
|
+
Webdrivers.logger.debug "Checking current version"
|
9
|
+
return nil unless downloaded?
|
10
|
+
string = %x(#{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
|
+
|
42
|
+
end
|
43
|
+
end
|
44
44
|
end
|
data/lib/webdrivers/iedriver.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
require 'rubygems/version'
|
3
|
-
|
4
|
-
module Webdrivers
|
5
|
-
class IEdriver < Common
|
6
|
-
class << self
|
7
|
-
|
8
|
-
def current_version
|
9
|
-
Webdrivers.logger.debug "Checking current version"
|
10
|
-
return nil unless downloaded?
|
11
|
-
string = %x(#{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
|
-
'
|
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
|
-
|
42
|
-
end
|
43
|
-
end
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'rubygems/version'
|
3
|
+
|
4
|
+
module Webdrivers
|
5
|
+
class IEdriver < Common
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def current_version
|
9
|
+
Webdrivers.logger.debug "Checking current version"
|
10
|
+
return nil unless downloaded?
|
11
|
+
string = %x(#{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
|
+
|
42
|
+
end
|
43
|
+
end
|
44
44
|
end
|
data/lib/webdrivers/logger.rb
CHANGED
@@ -1,109 +1,109 @@
|
|
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
|
+
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,58 +1,58 @@
|
|
1
|
-
module Webdrivers
|
2
|
-
class MSWebdriver < Common
|
3
|
-
|
4
|
-
class << self
|
5
|
-
|
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
|
-
Webdrivers.logger.debug "Current version of Microsoft Edge is #{version.chomp!}"
|
16
|
-
|
17
|
-
build = version.split('.')[1] # "41.16299.248.0" => "16299"
|
18
|
-
Webdrivers.logger.debug "Expecting MicrosoftWebDriver.exe version #{build}"
|
19
|
-
build.to_i
|
20
|
-
end
|
21
|
-
|
22
|
-
# Webdriver binaries for Microsoft Edge are not backwards compatible.
|
23
|
-
# For this reason, instead of downloading the latest binary we download the correct one for the
|
24
|
-
# currently installed browser version.
|
25
|
-
alias :version :windows_version
|
26
|
-
|
27
|
-
def version=(*)
|
28
|
-
raise "Version can not be set for MSWebdriver because it is dependent on the version of Edge"
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def file_name
|
34
|
-
"MicrosoftWebDriver.exe"
|
35
|
-
end
|
36
|
-
|
37
|
-
def downloads
|
38
|
-
array = Nokogiri::HTML(get(base_url)).xpath("//li[@class='driver-download']/a")
|
39
|
-
array.each_with_object({}) do |link, hash|
|
40
|
-
next if link.text == 'Insiders'
|
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
|
-
|
56
|
-
end
|
57
|
-
end
|
1
|
+
module Webdrivers
|
2
|
+
class MSWebdriver < Common
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
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
|
+
Webdrivers.logger.debug "Current version of Microsoft Edge is #{version.chomp!}"
|
16
|
+
|
17
|
+
build = version.split('.')[1] # "41.16299.248.0" => "16299"
|
18
|
+
Webdrivers.logger.debug "Expecting MicrosoftWebDriver.exe version #{build}"
|
19
|
+
build.to_i
|
20
|
+
end
|
21
|
+
|
22
|
+
# Webdriver binaries for Microsoft Edge are not backwards compatible.
|
23
|
+
# For this reason, instead of downloading the latest binary we download the correct one for the
|
24
|
+
# currently installed browser version.
|
25
|
+
alias :version :windows_version
|
26
|
+
|
27
|
+
def version=(*)
|
28
|
+
raise "Version can not be set for MSWebdriver because it is dependent on the version of Edge"
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def file_name
|
34
|
+
"MicrosoftWebDriver.exe"
|
35
|
+
end
|
36
|
+
|
37
|
+
def downloads
|
38
|
+
array = Nokogiri::HTML(get(base_url)).xpath("//li[@class='driver-download']/a")
|
39
|
+
array.each_with_object({}) do |link, hash|
|
40
|
+
next if link.text == 'Insiders'
|
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
|
+
|
56
|
+
end
|
57
|
+
end
|
58
58
|
end
|