webdrivers 3.0.0.beta2 → 3.0.0.beta3

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: 617d5fa4e06abcdbf66ad776593c1e409303f4a7
4
- data.tar.gz: f92d3f5b6e78c7f4de29b3cee38e17dfb1e7bb5c
3
+ metadata.gz: d0ba1dd22f090f956f3ba261493c79a981d56478
4
+ data.tar.gz: 65e20863ce312b350540fddb229f41ca2aa35e33
5
5
  SHA512:
6
- metadata.gz: 219decd97dc9bf88005d95605133a77b325841e0eb933fd6c47527d4de5ac0be2ed47bb2be57e8c8b15fe6a52ab145eeffaedd8ad656e2ab77f2011e833f817f
7
- data.tar.gz: 892b73d4f0d90c26f5b39bbb4afe58901282817ac6a4c49a1397ac30e7d0084c48626c3f7bc99d9e233a0df1a766cef267e8bc88684255785d65833de0388fbb
6
+ metadata.gz: 8c041236b5f0a9bf3b70b87901e0444110e0adb6b6ac0a60cd3a0034ba37e187bdaecb82d334c520f1d74869d89dae1c80253e8ec9c08c30eaa96584da95228e
7
+ data.tar.gz: c871783df7514d33d898e02a5d5e150cda8d0f8d351f09454130ef3a3a3ee639256f0967eed6b1775b4aa4e45164895403d17ad3c56ad41adb1b3212e27b7fac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 3.0.0.beta3 (2017-08-17)
2
+
3
+ * Supports Windows
4
+ * Supports mswebdriver and iedriver
5
+
1
6
  ### 3.0.0.beta2 (2017-08-16)
2
7
 
3
8
  * Supports geckodriver on Mac and Linux
data/lib/webdrivers.rb CHANGED
@@ -2,3 +2,5 @@ require "webdrivers/selenium"
2
2
  require "webdrivers/common"
3
3
  require "webdrivers/chromedriver"
4
4
  require "webdrivers/geckodriver"
5
+ require "webdrivers/iedriver"
6
+ require "webdrivers/mswebdriver"
@@ -21,7 +21,7 @@ module Webdrivers
21
21
  end
22
22
 
23
23
  def file_name
24
- 'chromedriver'
24
+ platform == "win" ? "chromedriver.exe" : "chromedriver"
25
25
  end
26
26
 
27
27
  def base_url
@@ -1,5 +1,4 @@
1
1
  require 'rubygems/package'
2
- require 'nokogiri'
3
2
  require 'open-uri'
4
3
  require 'zip'
5
4
 
@@ -24,7 +23,7 @@ module Webdrivers
24
23
  end
25
24
 
26
25
  def download(version = nil)
27
- url = downloads[version || latest]
26
+ url = download_url(version)
28
27
  filename = File.basename url
29
28
 
30
29
  Dir.chdir install_dir do
@@ -45,6 +44,10 @@ module Webdrivers
45
44
 
46
45
  private
47
46
 
47
+ def download_url(version)
48
+ downloads[version || latest]
49
+ end
50
+
48
51
  def downloaded?
49
52
  File.exist? binary
50
53
  end
@@ -55,7 +58,7 @@ module Webdrivers
55
58
 
56
59
  def site_available?
57
60
  true if open(base_url)
58
- rescue
61
+ rescue => ex
59
62
  false
60
63
  end
61
64
 
@@ -1,6 +1,5 @@
1
1
  require 'nokogiri'
2
2
  require 'open-uri'
3
- require 'zip'
4
3
 
5
4
  module Webdrivers
6
5
  class Geckodriver < Common
@@ -34,7 +33,7 @@ module Webdrivers
34
33
  end
35
34
 
36
35
  def file_name
37
- 'geckodriver'
36
+ platform == "win" ? "geckodriver.exe" : "geckodriver"
38
37
  end
39
38
 
40
39
  def base_url
@@ -0,0 +1,46 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ module Webdrivers
5
+ class IEdriver < Common
6
+ class << self
7
+
8
+ def current
9
+ return nil unless downloaded?
10
+ puts binary
11
+ string = %x(#{binary} --version)
12
+ puts string
13
+ normalize string.match(/IEDriverServer.exe (\d\.\d+\.\d*\.\d*)/)[1]
14
+ end
15
+
16
+ private
17
+
18
+ def normalize(string)
19
+ string.to_f
20
+ end
21
+
22
+ def file_name
23
+ "IEDriverServer.exe"
24
+ end
25
+
26
+ def base_url
27
+ 'http://selenium-release.storage.googleapis.com/'
28
+ end
29
+
30
+ def downloads
31
+ raise StandardError, "Can not reach site" unless site_available?
32
+
33
+ @downloads ||= begin
34
+ doc = Nokogiri::XML.parse(OpenURI.open_uri(base_url))
35
+ items = doc.css("Key").collect(&:text)
36
+ items.select! { |item| item.include?('IEDriverServer_Win32') }
37
+ items.each_with_object({}) do |item, hash|
38
+ key = normalize item[/^[^\/]+/]
39
+ hash[key] = "#{base_url}#{item}"
40
+ end
41
+ end
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,43 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ module Webdrivers
5
+ class MSWebdriver < Common
6
+ class << self
7
+
8
+ def current
9
+ version = %x(ver)
10
+ version[/\d+\.\d+\.\d+/][/[^\.]\d+$/]
11
+ end
12
+
13
+ def latest
14
+ # unknown; have to always download
15
+ end
16
+
17
+ private
18
+
19
+ def normalize(string)
20
+ string.match(/(\d+)\.(\d+\.\d+)/).to_a.map {|v| v.tr('.', '') }[1..-1].join('.').to_f
21
+ end
22
+
23
+ def file_name
24
+ "MicrosoftWebDriver.exe"
25
+ end
26
+
27
+ def download_url(_version = nil)
28
+ raise StandardError, "Can not reach site" unless site_available?
29
+
30
+ if current.to_i >= 16257
31
+ 'https://download.microsoft.com/download/1/4/1/14156DA0-D40F-460A-B14D-1B264CA081A5/MicrosoftWebDriver.exe'
32
+ else
33
+ 'https://download.microsoft.com/download/3/2/D/32D3E464-F2EF-490F-841B-05D53C848D15/MicrosoftWebDriver.exe'
34
+ end
35
+ end
36
+
37
+ def base_url
38
+ 'https://www.microsoft.com/en-us/download'
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -13,5 +13,17 @@ module Selenium
13
13
  @driver_path ||= Webdrivers::Geckodriver.update
14
14
  end
15
15
  end
16
+
17
+ module Edge
18
+ def self.driver_path
19
+ @driver_path ||= Webdrivers::MSWebdriver.update
20
+ end
21
+ end
22
+
23
+ module IE
24
+ def self.driver_path
25
+ @driver_path ||= Webdrivers::IEdriver.update
26
+ end
27
+ end
16
28
  end
17
29
  end
@@ -0,0 +1,34 @@
1
+ require "spec_helper"
2
+
3
+ describe Webdrivers::IEdriver do
4
+
5
+ let(:iedriver) { Webdrivers::IEdriver }
6
+
7
+ it 'finds latest version' do
8
+ expect(iedriver.latest).to be > 3.4
9
+ expect(iedriver.latest).to be < 4
10
+ end
11
+
12
+ it 'downloads iedriver' do
13
+ iedriver.remove
14
+ expect(File.exist?(iedriver.download)).to be true
15
+ end
16
+
17
+ it 'removes iedriver' do
18
+ iedriver.remove
19
+ expect(iedriver.current).to be_nil
20
+ end
21
+
22
+ context 'when offline' do
23
+ before { allow(iedriver).to receive(:site_available?).and_return(false) }
24
+
25
+ it 'raises exception finding latest version' do
26
+ expect {iedriver.latest}.to raise_error(StandardError, "Can not reach site")
27
+ end
28
+
29
+ it 'raises exception downloading' do
30
+ expect {iedriver.download}.to raise_error(StandardError, "Can not reach site")
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe Webdrivers::MSWebdriver do
4
+
5
+ let(:mswebdriver) { Webdrivers::MSWebdriver }
6
+
7
+ it 'downloads mswebdriver' do
8
+ mswebdriver.remove
9
+ allow(mswebdriver).to receive(:current).and_return(0)
10
+ expect(File.exist?(mswebdriver.download)).to be true
11
+ end
12
+
13
+ it 'removes mswebdriver' do
14
+ mswebdriver.remove
15
+ expect(File.exist?(mswebdriver.send :binary)).to be false
16
+ end
17
+
18
+ context 'when offline' do
19
+ before { allow(mswebdriver).to receive(:site_available?).and_return(false) }
20
+
21
+ it 'raises exception downloading' do
22
+ expect {mswebdriver.download}.to raise_error(StandardError, "Can not reach site")
23
+ end
24
+ end
25
+
26
+ end
data/webdrivers.gemspec CHANGED
@@ -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.0.0.beta2"
6
+ s.version = "3.0.0.beta3"
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.0.0.beta2
4
+ version: 3.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Fortner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -99,9 +99,13 @@ files:
99
99
  - lib/webdrivers/chromedriver.rb
100
100
  - lib/webdrivers/common.rb
101
101
  - lib/webdrivers/geckodriver.rb
102
+ - lib/webdrivers/iedriver.rb
103
+ - lib/webdrivers/mswebdriver.rb
102
104
  - lib/webdrivers/selenium.rb
103
105
  - spec/chromedriver_spec.rb
104
106
  - spec/geckodriver_spec.rb
107
+ - spec/iedriver_spec.rb
108
+ - spec/mswebdriver_spec.rb
105
109
  - spec/spec_helper.rb
106
110
  - webdrivers.gemspec
107
111
  homepage: https://github.com/titusfortner/webdrivers
@@ -131,4 +135,6 @@ summary: Easy download and use of browser drivers.
131
135
  test_files:
132
136
  - spec/chromedriver_spec.rb
133
137
  - spec/geckodriver_spec.rb
138
+ - spec/iedriver_spec.rb
139
+ - spec/mswebdriver_spec.rb
134
140
  - spec/spec_helper.rb