webdrivers 3.8.0 → 3.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +14 -0
- data/.gitignore +7 -7
- data/.rubocop.yml +35 -19
- data/.travis.yml +24 -16
- data/CHANGELOG.md +120 -113
- data/Gemfile +6 -4
- data/LICENSE.txt +22 -22
- data/README.md +154 -153
- data/Rakefile +9 -9
- data/appveyor.yml +23 -0
- data/lib/webdrivers.rb +28 -26
- data/lib/webdrivers/chromedriver.rb +161 -140
- data/lib/webdrivers/common.rb +221 -205
- data/lib/webdrivers/geckodriver.rb +41 -43
- data/lib/webdrivers/iedriver.rb +41 -43
- data/lib/webdrivers/logger.rb +111 -109
- data/lib/webdrivers/mswebdriver.rb +59 -57
- data/lib/webdrivers/selenium.rb +40 -38
- data/spec/spec_helper.rb +12 -5
- data/spec/webdrivers/chromedriver_spec.rb +129 -104
- data/spec/webdrivers/geckodriver_spec.rb +66 -60
- data/spec/webdrivers/i_edriver_spec.rb +41 -36
- data/spec/webdrivers/ms_webdriver_spec.rb +26 -24
- data/spec/webdrivers_proxy_support_spec.rb +53 -51
- data/webdrivers.gemspec +30 -27
- metadata +27 -4
@@ -1,43 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
data/lib/webdrivers/iedriver.rb
CHANGED
@@ -1,43 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
data/lib/webdrivers/logger.rb
CHANGED
@@ -1,109 +1,111 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@logger
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
#
|
46
|
-
#
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
when '
|
56
|
-
@logger.level =
|
57
|
-
when '
|
58
|
-
@logger.level =
|
59
|
-
when '
|
60
|
-
@logger.level =
|
61
|
-
when '
|
62
|
-
@logger.level =
|
63
|
-
when '
|
64
|
-
@logger.level =
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
logger
|
102
|
-
logger.
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
build.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|