webdrivers 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca1ac3aeef06a8be8d433cde3199d6fe8609b88d
4
- data.tar.gz: c51bbd846ff0fbb6e21213be144a1f9c72538616
3
+ metadata.gz: 38a8045b1c217acbc4ef3163a4c5cf9c7b49f39d
4
+ data.tar.gz: c37958c1c522eaa4678052ffa59699287f182cce
5
5
  SHA512:
6
- metadata.gz: c9fc8f2e6c6e1268fc69fc7c76f197234da084b11f3298f8742449f4e44ee5d4b2605369c03ac0efcb5895814dcb4207c1514a3419486f2c5603c49576b4c48f
7
- data.tar.gz: 81ffe1608b1d783df44a7e75075ed601e4fb6553e244733153f4098803ff05e0ba4acaa604398c7cf232ffe05ec6211a6731d5ced87e337078b27299f6e92c45
6
+ metadata.gz: 3f393257af259775e469647eb1d6bd3bc2afd869ffc7fbf03a9bf00188d6be30157cf214610f0398c0451f06ef99b1d3d9ff0abbe5769c1595373308e097cacf
7
+ data.tar.gz: 30e8898a5314378a9df00b15100bdb5c63e914b991d683b42fccc3422ddd351ebcf4c0f67b181df010418333ca7dfcd3c35a49045f069337dce7e02a9a768977
@@ -1,4 +1,8 @@
1
- ### 3.2.3 (2017-01-04)
1
+ ### 3.3.0 (2018-04-29)
2
+
3
+ * Ensures downloading correct MSWebdriver version (Thanks kapoorlakshya)
4
+
5
+ ### 3.2.4 (2017-01-04)
2
6
 
3
7
  * Improve error message when unable to find the latest driver
4
8
 
@@ -9,18 +9,24 @@ module Webdrivers
9
9
  unless site_available?
10
10
  return current.nil? ? nil : binary
11
11
  end
12
- released = latest()
13
- location = binary()
12
+ released = latest()
13
+ location = binary()
14
+ binary_exists = File.exists?(location)
14
15
 
15
- return location if released.nil? && File.exist?(location)
16
+ return location if released.nil? && binary_exists
16
17
 
17
18
  if released.nil?
18
19
  msg = "Unable to find the latest version of #{file_name}; try downloading manually from #{base_url} and place in #{install_dir}"
19
20
  raise StandardError, msg
20
21
  end
21
22
 
22
- return location if current == released
23
- remove && download
23
+ if current == released && binary_exists # Already have latest/matching one
24
+ Webdrivers.logger.debug "Expected webdriver version found"
25
+ return location
26
+ end
27
+
28
+ remove if binary_exists # Remove outdated exe
29
+ download
24
30
  end
25
31
 
26
32
  def latest
@@ -33,7 +39,7 @@ module Webdrivers
33
39
  end
34
40
 
35
41
  def download(version = nil)
36
- url = download_url(version)
42
+ url = download_url(version)
37
43
  filename = File.basename url
38
44
 
39
45
  Dir.mkdir(install_dir) unless File.exists?(install_dir)
@@ -83,7 +89,7 @@ module Webdrivers
83
89
  def http
84
90
  if using_proxy
85
91
  return Net::HTTP.Proxy(Webdrivers.proxy_addr, Webdrivers.proxy_port,
86
- Webdrivers.proxy_user, Webdrivers.proxy_pass)
92
+ Webdrivers.proxy_user, Webdrivers.proxy_pass)
87
93
  end
88
94
  return Net::HTTP
89
95
  end
@@ -151,7 +157,7 @@ module Webdrivers
151
157
  tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(filename))
152
158
 
153
159
  File.open(file_name, "w+b") do |ucf|
154
- tar_extract.each {|entry| ucf << entry.read}
160
+ tar_extract.each { |entry| ucf << entry.read }
155
161
  File.basename ucf
156
162
  end
157
163
  end
@@ -160,7 +166,7 @@ module Webdrivers
160
166
  Zip::File.open("#{Dir.pwd}/#{filename}") do |zip_file|
161
167
  zip_file.each do |f|
162
168
  @top_path ||= f.name
163
- f_path = File.join(Dir.pwd, f.name)
169
+ f_path = File.join(Dir.pwd, f.name)
164
170
  FileUtils.rm_rf(f_path) if File.exist?(f_path)
165
171
  FileUtils.mkdir_p(File.dirname(f_path)) unless File.exist?(File.dirname(f_path))
166
172
  zip_file.extract(f, f_path)
@@ -170,7 +176,7 @@ module Webdrivers
170
176
  end
171
177
 
172
178
  def install_dir
173
- File.expand_path(File.join(ENV['HOME'], ".webdrivers")).tap {|dir| FileUtils.mkdir_p dir}
179
+ File.expand_path(File.join(ENV['HOME'], ".webdrivers")).tap { |dir| FileUtils.mkdir_p dir }
174
180
  end
175
181
  end
176
182
  end
@@ -4,51 +4,42 @@ module Webdrivers
4
4
 
5
5
  def current
6
6
  Webdrivers.logger.debug "Checking current version"
7
- version = %x(ver)
8
- Webdrivers.logger.debug "Current version of Windows Build is #{version}"
9
- version[/\d+\.\d+\.\d+/][/[^\.]\d+$/]
10
- end
11
7
 
12
- def latest
13
- # unknown; have to always download
8
+ # current() from other webdrivers returns the version from the webdriver EXE.
9
+ # Unfortunately, MicrosoftWebDriver.exe does not have an option to get the version.
10
+ # To work around it we query the currently installed version of Microsoft Edge instead
11
+ # and compare it to the list of available downloads.
12
+ version = `powershell (Get-AppxPackage -Name Microsoft.MicrosoftEdge).Version`
13
+ raise "Failed to check Microsoft Edge version." if version.empty? # Package name changed?
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
14
19
  end
15
20
 
16
21
  private
17
22
 
18
23
  def normalize(string)
19
- string.match(/(\d+)\.(\d+\.\d+)/).to_a.map {|v| v.tr('.', '')}[1..-1].join('.').to_f
24
+ string.match(/(\d+)\.(\d+\.\d+)/).to_a.map { |v| v.tr('.', '') }[1 .. -1].join('.').to_f
20
25
  end
21
26
 
22
27
  def file_name
23
28
  "MicrosoftWebDriver.exe"
24
29
  end
25
30
 
26
- def download_url(_version = nil)
31
+ def downloads
27
32
  raise StandardError, "Can not reach site" unless site_available?
28
-
29
- case current.to_i
30
- when 10240
31
- Webdrivers.logger.debug "Attempting to Download Build for 10240"
32
- "https://download.microsoft.com/download/8/D/0/8D0D08CF-790D-4586-B726-C6469A9ED49C/MicrosoftWebDriver.msi"
33
- when 10586
34
- Webdrivers.logger.debug "Attempting to Download Build for 10586"
35
- "https://download.microsoft.com/download/C/0/7/C07EBF21-5305-4EC8-83B1-A6FCC8F93F45/MicrosoftWebDriver.msi"
36
- when 14393
37
- Webdrivers.logger.debug "Attempting to Download Build for 14393"
38
- "https://download.microsoft.com/download/3/2/D/32D3E464-F2EF-490F-841B-05D53C848D15/MicrosoftWebDriver.exe"
39
- when 15063
40
- Webdrivers.logger.debug "Attempting to Download Build for 15063"
41
- "https://download.microsoft.com/download/3/4/2/342316D7-EBE0-4F10-ABA2-AE8E0CDF36DD/MicrosoftWebDriver.exe"
42
- else
43
- Webdrivers.logger.debug "Attempting to Download Latest Insider's Version"
44
- "https://download.microsoft.com/download/1/4/1/14156DA0-D40F-460A-B14D-1B264CA081A5/MicrosoftWebDriver.exe"
33
+ array = Nokogiri::HTML(get(base_url)).xpath("//li[@class='driver-download']/a")
34
+ array.each_with_object({}) do |link, hash|
35
+ next if link.text == 'Insiders'
36
+ hash[link.text.scan(/\d+/).first.to_i] = link['href']
45
37
  end
46
38
  end
47
39
 
48
40
  def base_url
49
- 'https://www.microsoft.com/en-us/download'
41
+ 'https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/'
50
42
  end
51
-
52
43
  end
53
44
  end
54
45
  end
@@ -19,7 +19,7 @@ describe Webdrivers::Geckodriver do
19
19
 
20
20
  it 'finds latest version' do
21
21
  expect(geckodriver.latest).to be > 0.17
22
- expect(geckodriver.latest).to be < 0.2
22
+ expect(geckodriver.latest).to be <= 0.201
23
23
  end
24
24
 
25
25
  it 'downloads latest version by default' do
@@ -19,7 +19,7 @@ describe Webdrivers::MSWebdriver do
19
19
  before { allow(mswebdriver).to receive(:site_available?).and_return(false) }
20
20
 
21
21
  it 'raises exception downloading' do
22
- expect {mswebdriver.download}.to raise_error(StandardError, "Can not reach site")
22
+ expect { mswebdriver.download }.to raise_error(StandardError, "Can not reach site")
23
23
  end
24
24
  end
25
25
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "webdrivers"
6
- s.version = "3.2.4"
6
+ s.version = "3.3.0"
7
7
  s.authors = ["Titus Fortner"]
8
8
  s.email = ["titusfortner@gmail.com"]
9
9
  s.homepage = "https://github.com/titusfortner/webdrivers"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webdrivers
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Fortner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-04 00:00:00.000000000 Z
11
+ date: 2018-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec