webdrivers 3.9.1 → 3.9.2
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 +5 -5
- data/.github/ISSUE_TEMPLATE.md +13 -13
- data/.gitignore +7 -7
- data/.rubocop.yml +44 -44
- data/.travis.yml +24 -24
- data/CHANGELOG.md +137 -133
- data/Gemfile +6 -6
- data/LICENSE.txt +22 -22
- data/README.md +169 -169
- data/Rakefile +11 -11
- data/appveyor.yml +22 -22
- data/lib/webdrivers.rb +6 -6
- data/lib/webdrivers/chromedriver.rb +185 -167
- data/lib/webdrivers/common.rb +191 -157
- data/lib/webdrivers/geckodriver.rb +80 -72
- data/lib/webdrivers/iedriver.rb +70 -62
- data/lib/webdrivers/logger.rb +111 -111
- data/lib/webdrivers/mswebdriver.rb +55 -55
- data/lib/webdrivers/network.rb +61 -58
- data/lib/webdrivers/system.rb +154 -151
- data/spec/spec_helper.rb +18 -18
- data/spec/webdrivers/chromedriver_spec.rb +257 -243
- data/spec/webdrivers/geckodriver_spec.rb +210 -210
- data/spec/webdrivers/i_edriver_spec.rb +192 -192
- data/spec/webdrivers/ms_webdriver_spec.rb +30 -30
- data/spec/webdrivers_proxy_support_spec.rb +53 -53
- data/webdrivers.gemspec +31 -31
- metadata +4 -11
@@ -1,55 +1,55 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'webdrivers/common'
|
4
|
-
|
5
|
-
module Webdrivers
|
6
|
-
class MSWebdriver
|
7
|
-
class << self
|
8
|
-
attr_accessor :ignore
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module Selenium
|
14
|
-
module WebDriver
|
15
|
-
module Edge
|
16
|
-
if defined?(Selenium::WebDriver::VERSION) && Selenium::WebDriver::VERSION > '3.141.0'
|
17
|
-
class Service < WebDriver::Service
|
18
|
-
class << self
|
19
|
-
alias se_driver_path driver_path
|
20
|
-
|
21
|
-
def driver_path
|
22
|
-
unless Webdrivers::MSWebdriver.ignore
|
23
|
-
Webdrivers.logger.warn 'Microsoft WebDriver for the Edge browser is no longer supported by Webdrivers'\
|
24
|
-
' gem. Due to changes in Edge implementation, the correct version can no longer be accurately provided. '\
|
25
|
-
'Download driver, and specify the location with `Selenium::WebDriver::Edge.driver_path = "/driver/path"`, '\
|
26
|
-
'or place it in PATH Environment Variable. '\
|
27
|
-
'Download directions here: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads '\
|
28
|
-
'To remove this warning in Webdrivers 3.x, set `Webdrivers.MSWebdriver.ignore`'
|
29
|
-
end
|
30
|
-
|
31
|
-
se_driver_path
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
else
|
36
|
-
class << self
|
37
|
-
alias se_driver_path driver_path
|
38
|
-
|
39
|
-
def driver_path
|
40
|
-
unless Webdrivers::MSWebdriver.ignore
|
41
|
-
Webdrivers.logger.warn 'Microsoft WebDriver for the Edge browser is no longer supported by Webdrivers'\
|
42
|
-
' gem. Due to changes in Edge implementation, the correct version can no longer be accurately provided. '\
|
43
|
-
'Download driver, and specify the location with `Selenium::WebDriver::Edge.driver_path = "/driver/path"`, '\
|
44
|
-
'or place it in PATH Environment Variable. '\
|
45
|
-
'Download directions here: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads '\
|
46
|
-
'To remove this warning in Webdrivers 3.x, set `Webdrivers.MSWebdriver.ignore`'
|
47
|
-
end
|
48
|
-
|
49
|
-
se_driver_path
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'webdrivers/common'
|
4
|
+
|
5
|
+
module Webdrivers
|
6
|
+
class MSWebdriver
|
7
|
+
class << self
|
8
|
+
attr_accessor :ignore
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Selenium
|
14
|
+
module WebDriver
|
15
|
+
module Edge
|
16
|
+
if defined?(Selenium::WebDriver::VERSION) && Selenium::WebDriver::VERSION > '3.141.0'
|
17
|
+
class Service < WebDriver::Service
|
18
|
+
class << self
|
19
|
+
alias se_driver_path driver_path
|
20
|
+
|
21
|
+
def driver_path
|
22
|
+
unless Webdrivers::MSWebdriver.ignore
|
23
|
+
Webdrivers.logger.warn 'Microsoft WebDriver for the Edge browser is no longer supported by Webdrivers'\
|
24
|
+
' gem. Due to changes in Edge implementation, the correct version can no longer be accurately provided. '\
|
25
|
+
'Download driver, and specify the location with `Selenium::WebDriver::Edge.driver_path = "/driver/path"`, '\
|
26
|
+
'or place it in PATH Environment Variable. '\
|
27
|
+
'Download directions here: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads '\
|
28
|
+
'To remove this warning in Webdrivers 3.x, set `Webdrivers.MSWebdriver.ignore`'
|
29
|
+
end
|
30
|
+
|
31
|
+
se_driver_path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
else
|
36
|
+
class << self
|
37
|
+
alias se_driver_path driver_path
|
38
|
+
|
39
|
+
def driver_path
|
40
|
+
unless Webdrivers::MSWebdriver.ignore
|
41
|
+
Webdrivers.logger.warn 'Microsoft WebDriver for the Edge browser is no longer supported by Webdrivers'\
|
42
|
+
' gem. Due to changes in Edge implementation, the correct version can no longer be accurately provided. '\
|
43
|
+
'Download driver, and specify the location with `Selenium::WebDriver::Edge.driver_path = "/driver/path"`, '\
|
44
|
+
'or place it in PATH Environment Variable. '\
|
45
|
+
'Download directions here: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads '\
|
46
|
+
'To remove this warning in Webdrivers 3.x, set `Webdrivers.MSWebdriver.ignore`'
|
47
|
+
end
|
48
|
+
|
49
|
+
se_driver_path
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/webdrivers/network.rb
CHANGED
@@ -1,58 +1,61 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Webdrivers
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
Net::HTTP
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Webdrivers
|
4
|
+
#
|
5
|
+
# @api private
|
6
|
+
#
|
7
|
+
class Network
|
8
|
+
class << self
|
9
|
+
def get(url, limit = 10)
|
10
|
+
Webdrivers.logger.debug "Making network call to #{url}"
|
11
|
+
|
12
|
+
response = get_response(url, limit)
|
13
|
+
case response
|
14
|
+
when Net::HTTPSuccess
|
15
|
+
response.body
|
16
|
+
else
|
17
|
+
raise NetworkError, "#{response.class::EXCEPTION_TYPE}: #{response.code} \"#{response.message}\" with #{url}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_url(url, limit = 10)
|
22
|
+
Webdrivers.logger.debug "Making network call to #{url}"
|
23
|
+
|
24
|
+
get_response(url, limit).uri.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_response(url, limit = 10)
|
28
|
+
raise ConnectionError, 'Too many HTTP redirects' if limit.zero?
|
29
|
+
|
30
|
+
begin
|
31
|
+
response = http.get_response(URI(url))
|
32
|
+
rescue SocketError
|
33
|
+
raise ConnectionError, "Can not reach #{url}"
|
34
|
+
end
|
35
|
+
|
36
|
+
Webdrivers.logger.debug "Get response: #{response.inspect}"
|
37
|
+
|
38
|
+
if response.is_a?(Net::HTTPRedirection)
|
39
|
+
location = response['location']
|
40
|
+
Webdrivers.logger.debug "Redirected to #{location}"
|
41
|
+
get_response(location, limit - 1)
|
42
|
+
else
|
43
|
+
response
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def http
|
48
|
+
if using_proxy
|
49
|
+
Net::HTTP.Proxy(Webdrivers.proxy_addr, Webdrivers.proxy_port,
|
50
|
+
Webdrivers.proxy_user, Webdrivers.proxy_pass)
|
51
|
+
else
|
52
|
+
Net::HTTP
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def using_proxy
|
57
|
+
Webdrivers.proxy_addr && Webdrivers.proxy_port
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/webdrivers/system.rb
CHANGED
@@ -1,151 +1,154 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rubygems/package'
|
4
|
-
require 'zip'
|
5
|
-
|
6
|
-
module Webdrivers
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
tempfile.
|
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
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubygems/package'
|
4
|
+
require 'zip'
|
5
|
+
|
6
|
+
module Webdrivers
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
#
|
10
|
+
class System
|
11
|
+
class << self
|
12
|
+
def delete(file)
|
13
|
+
max_attempts = 3
|
14
|
+
attempts_made = 0
|
15
|
+
delay = 0.5
|
16
|
+
Webdrivers.logger.debug "Deleting #{file}"
|
17
|
+
|
18
|
+
begin
|
19
|
+
attempts_made += 1
|
20
|
+
File.delete file if File.exist? file
|
21
|
+
rescue Errno::EACCES # Solves an intermittent file locking issue on Windows
|
22
|
+
sleep(delay)
|
23
|
+
retry if File.exist?(file) && attempts_made <= max_attempts
|
24
|
+
raise
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def install_dir
|
29
|
+
Webdrivers.install_dir || File.expand_path(File.join(ENV['HOME'], '.webdrivers'))
|
30
|
+
end
|
31
|
+
|
32
|
+
def cache_version(file_name, version)
|
33
|
+
FileUtils.mkdir_p(install_dir) unless File.exist?(install_dir)
|
34
|
+
|
35
|
+
File.open("#{install_dir}/#{file_name.gsub('.exe', '')}.version", 'w+') do |file|
|
36
|
+
file.print(version)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def cached_version(file_name)
|
41
|
+
File.open("#{install_dir}/#{file_name.gsub('.exe', '')}.version", 'r', &:read)
|
42
|
+
end
|
43
|
+
|
44
|
+
def valid_cache?(file_name)
|
45
|
+
file = "#{install_dir}/#{file_name.gsub('.exe', '')}.version"
|
46
|
+
return false unless File.exist?(file)
|
47
|
+
|
48
|
+
Time.now - File.mtime(file) < Webdrivers.cache_time
|
49
|
+
end
|
50
|
+
|
51
|
+
def download(url, target)
|
52
|
+
FileUtils.mkdir_p(install_dir) unless File.exist?(install_dir)
|
53
|
+
|
54
|
+
download_file(url, target)
|
55
|
+
|
56
|
+
FileUtils.chmod 'ugo+rx', target
|
57
|
+
Webdrivers.logger.debug "Completed download and processing of #{target}"
|
58
|
+
target
|
59
|
+
end
|
60
|
+
|
61
|
+
def download_file(url, target)
|
62
|
+
file_name = File.basename(url)
|
63
|
+
Dir.chdir(install_dir) do
|
64
|
+
tempfile = Tempfile.open(['', file_name], binmode: true) do |file|
|
65
|
+
file.print Network.get(url)
|
66
|
+
file
|
67
|
+
end
|
68
|
+
|
69
|
+
raise "Could not download #{url}" unless File.exist?(tempfile.to_path)
|
70
|
+
|
71
|
+
Webdrivers.logger.debug "Successfully downloaded #{tempfile.to_path}"
|
72
|
+
|
73
|
+
decompress_file(tempfile, file_name, target)
|
74
|
+
tempfile.close!
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def exists?(file)
|
79
|
+
result = File.exist? file
|
80
|
+
Webdrivers.logger.debug "#{file} is#{' not' unless result} already downloaded"
|
81
|
+
result
|
82
|
+
end
|
83
|
+
|
84
|
+
def decompress_file(tempfile, file_name, target)
|
85
|
+
tempfile = tempfile.to_path
|
86
|
+
case tempfile
|
87
|
+
when /tar\.gz$/
|
88
|
+
untargz_file(tempfile, File.basename(target))
|
89
|
+
when /tar\.bz2$/
|
90
|
+
untarbz2_file(tempfile)
|
91
|
+
when /\.zip$/
|
92
|
+
unzip_file(tempfile)
|
93
|
+
else
|
94
|
+
Webdrivers.logger.debug 'No Decompression needed'
|
95
|
+
FileUtils.cp(tempfile, File.join(Dir.pwd, file_name))
|
96
|
+
end
|
97
|
+
raise "Could not decompress #{file_name} to get #{target}" unless File.exist?(File.basename(target))
|
98
|
+
end
|
99
|
+
|
100
|
+
def untarbz2_file(filename)
|
101
|
+
Webdrivers.logger.debug "Decompressing #{filename}"
|
102
|
+
|
103
|
+
call("tar xjf #{filename}").gsub('.tar.bz2', '')
|
104
|
+
end
|
105
|
+
|
106
|
+
def untargz_file(source, target)
|
107
|
+
Webdrivers.logger.debug "Decompressing #{source}"
|
108
|
+
|
109
|
+
tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(source))
|
110
|
+
|
111
|
+
File.open(target, 'w+b') do |ucf|
|
112
|
+
tar_extract.each { |entry| ucf << entry.read }
|
113
|
+
File.basename ucf
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def unzip_file(filename)
|
118
|
+
Webdrivers.logger.debug "Decompressing #{filename}"
|
119
|
+
|
120
|
+
Zip::File.open(filename) do |zip_file|
|
121
|
+
zip_file.each do |f|
|
122
|
+
@top_path ||= f.name
|
123
|
+
f_path = File.join(Dir.pwd, f.name)
|
124
|
+
delete(f_path)
|
125
|
+
FileUtils.mkdir_p(File.dirname(f_path)) unless File.exist?(File.dirname(f_path))
|
126
|
+
zip_file.extract(f, f_path)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
@top_path
|
130
|
+
end
|
131
|
+
|
132
|
+
def platform
|
133
|
+
if Selenium::WebDriver::Platform.linux?
|
134
|
+
'linux'
|
135
|
+
elsif Selenium::WebDriver::Platform.mac?
|
136
|
+
'mac'
|
137
|
+
elsif Selenium::WebDriver::Platform.windows?
|
138
|
+
'win'
|
139
|
+
else
|
140
|
+
raise NotImplementedError, 'Your OS is not supported by webdrivers gem.'
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def bitsize
|
145
|
+
Selenium::WebDriver::Platform.bitsize
|
146
|
+
end
|
147
|
+
|
148
|
+
def call(cmd)
|
149
|
+
Webdrivers.logger.debug "making System call: #{cmd}"
|
150
|
+
`#{cmd}`
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|