webdrivers 2.4.0 → 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/CHANGELOG.md +4 -113
- data/LICENSE.txt +1 -2
- data/README.md +9 -9
- data/lib/webdrivers/chromedriver.rb +129 -21
- data/lib/webdrivers/selenium.rb +11 -0
- data/lib/webdrivers.rb +1 -8
- data/spec/chromedriver_spec.rb +27 -21
- data/webdrivers.gemspec +3 -2
- metadata +22 -30
- data/bin/IEDriverServer +0 -5
- data/bin/MicrosoftWebDriver +0 -5
- data/bin/chromedriver +0 -5
- data/bin/geckodriver +0 -5
- data/bin/phantomjs +0 -5
- data/lib/webdrivers/common.rb +0 -106
- data/lib/webdrivers/edgedriver.rb +0 -34
- data/lib/webdrivers/geckodriver.rb +0 -42
- data/lib/webdrivers/iedriver.rb +0 -35
- data/lib/webdrivers/phantomjs.rb +0 -40
- data/spec/edgedriver_spec.rb +0 -28
- data/spec/geckodriver_spec.rb +0 -38
- data/spec/iedriver_spec.rb +0 -29
- data/spec/phantomjs_spec.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28974e49008ce2ee61b8456679884651537c5527
|
4
|
+
data.tar.gz: 2c4a8ce5c5ec17a568a4dd966de0594a2490d15f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24676074712c8cc796347070ea7aef26388ca1c10a834a456cb10a9d1c661d21bddb4cf67e776aff37b29f092dca9fe1c1441163d245f6db3ffe1f6b83fbffdb
|
7
|
+
data.tar.gz: f0e5923038eb6f006f283c876d6d317e1b8b1cfe40d3d715982a0d224bc5f4aaef1c8beda52a0ad43327ecdf751932b66aefb3695998efd3b37b1727a5670f56
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,114 +1,5 @@
|
|
1
|
-
|
2
|
-
==========
|
1
|
+
### 3.0.0.beta1 (2017-08-15)
|
3
2
|
|
4
|
-
2.
|
5
|
-
|
6
|
-
|
7
|
-
* Update MicrosoftWebDriver version
|
8
|
-
* Use rubyzip gem instead of zip
|
9
|
-
* Bug fixes for download method
|
10
|
-
|
11
|
-
|
12
|
-
2.3.2 - 2016-11-26
|
13
|
-
----------
|
14
|
-
|
15
|
-
* Bug fixes for Windows
|
16
|
-
|
17
|
-
|
18
|
-
2.3.1 - 2016-11-26
|
19
|
-
----------
|
20
|
-
|
21
|
-
* Bug fixes for Windows
|
22
|
-
|
23
|
-
|
24
|
-
2.3.0 - 2016-11-26
|
25
|
-
----------
|
26
|
-
|
27
|
-
* Implement IEDriver support
|
28
|
-
* Implement MicrosoftWebDriver support
|
29
|
-
|
30
|
-
|
31
|
-
2.2.1 - 2016-11-26
|
32
|
-
----------
|
33
|
-
|
34
|
-
* Bug fixes for Windows
|
35
|
-
|
36
|
-
|
37
|
-
2.2.0 - 2016-11-26
|
38
|
-
----------
|
39
|
-
|
40
|
-
* Implement phantomjs support
|
41
|
-
|
42
|
-
|
43
|
-
2.1.1 - 2016-11-26
|
44
|
-
----------
|
45
|
-
|
46
|
-
* Improve Decompression Approach
|
47
|
-
|
48
|
-
|
49
|
-
2.1.0 - 2016-11-25
|
50
|
-
----------
|
51
|
-
|
52
|
-
* Implemented geckodriver support
|
53
|
-
|
54
|
-
|
55
|
-
2.0.0 - 2016-11-25
|
56
|
-
----------
|
57
|
-
|
58
|
-
* Renamed fork from chromedriver-helper to webdrivers
|
59
|
-
* Re-implemented chromedriver usage
|
60
|
-
|
61
|
-
|
62
|
-
1.0.0 - 2015-06-06
|
63
|
-
----------
|
64
|
-
|
65
|
-
* Updated gemspec info. Happy 1.0!
|
66
|
-
|
67
|
-
|
68
|
-
0.0.9 - 2015-06-06
|
69
|
-
----------
|
70
|
-
|
71
|
-
* No longer require 'curl' or 'wget', or 'unzip' utilities to be installed. You know, for Windows. (Thanks, @elementc!)
|
72
|
-
* Support JRuby by removing dependency on native-C-extension gem. (Thanks, Marques Lee!)
|
73
|
-
|
74
|
-
|
75
|
-
0.0.8 - 2015-01-23
|
76
|
-
----------
|
77
|
-
|
78
|
-
* Guaranteeing that we get the *latest* version of chromedriver. (#15) (Thanks, @AlexRiedler!)
|
79
|
-
|
80
|
-
|
81
|
-
0.0.7 - 26 Aug 2014
|
82
|
-
----------
|
83
|
-
|
84
|
-
* Added support for windows binaries. (Thanks, @elementc!)
|
85
|
-
|
86
|
-
|
87
|
-
0.0.6 - 26 Aug 2014
|
88
|
-
----------
|
89
|
-
|
90
|
-
* Fixed to work with new Google download page. #7 (Thanks, @mars!)
|
91
|
-
|
92
|
-
|
93
|
-
0.0.5 - 15 Aug 2012
|
94
|
-
----------
|
95
|
-
|
96
|
-
* Fixed support for JRuby on non-Windows platforms. #4 (Thanks, Tim Olsen!)
|
97
|
-
|
98
|
-
|
99
|
-
0.0.4 - 1 Aug 2012
|
100
|
-
----------
|
101
|
-
|
102
|
-
* Including `chromedriver-update` to easily allow people to force-upgrade. #3
|
103
|
-
|
104
|
-
|
105
|
-
0.0.3 - 20 Mar 2012
|
106
|
-
----------
|
107
|
-
|
108
|
-
* Updated download URL. #2 (Thanks, Alistair Hutchison!)
|
109
|
-
|
110
|
-
|
111
|
-
0.0.2 - 6 December 2011
|
112
|
-
----------
|
113
|
-
|
114
|
-
* Birthday!
|
3
|
+
* Complete Rewrite of 2.x
|
4
|
+
* Implemented with Monkey Patch not Shims
|
5
|
+
* Supports chromedriver on
|
data/LICENSE.txt
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
(The MIT License)
|
2
2
|
|
3
|
-
Copyright (c)
|
4
|
-
Copyright (c) 2016: Titus Fortner
|
3
|
+
Copyright (c) 2017: Titus Fortner
|
5
4
|
|
6
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
7
6
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -6,26 +6,25 @@ Run Selenium tests more easily with automatic installation and updates for all s
|
|
6
6
|
|
7
7
|
# Description
|
8
8
|
|
9
|
-
`webdrivers`
|
9
|
+
`webdrivers` downloads drivers and directs Selenium to use them.
|
10
10
|
|
11
11
|
Currently supported:
|
12
12
|
* `chromedriver`
|
13
13
|
* `geckodriver`
|
14
|
-
* `phantomjs`
|
15
14
|
* `IEDriverServer`
|
16
15
|
* `MicrosoftWebDriver`
|
17
16
|
|
18
|
-
Drivers are stored in `~/.webdrivers
|
19
|
-
|
17
|
+
Drivers are stored in `~/.webdrivers` directory
|
20
18
|
|
21
19
|
# Usage
|
22
20
|
|
23
|
-
|
21
|
+
in your Gemfile:
|
24
22
|
|
25
|
-
|
23
|
+
`gem "webdrivers", "~> 3.0"`
|
26
24
|
|
27
|
-
|
25
|
+
in your project:
|
28
26
|
|
27
|
+
`require 'webdrivers'`
|
29
28
|
|
30
29
|
# License
|
31
30
|
|
@@ -38,6 +37,7 @@ see LICENSE.txt for full details and copyright.
|
|
38
37
|
Bug reports and pull requests are welcome [on GitHub](https://github.com/titusfortner/webdrivers).
|
39
38
|
|
40
39
|
|
41
|
-
|
40
|
+
## Copyright
|
42
41
|
|
43
|
-
|
42
|
+
Copyright (c) 2017 Titus Fortner
|
43
|
+
See LICENSE for details
|
@@ -1,41 +1,149 @@
|
|
1
1
|
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'zip'
|
2
4
|
|
3
|
-
module Webdrivers
|
4
|
-
class Chromedriver < Common
|
5
5
|
|
6
|
+
module Webdrivers
|
7
|
+
class Chromedriver
|
6
8
|
class << self
|
7
|
-
|
8
|
-
|
9
|
+
|
10
|
+
def update
|
11
|
+
unless site_available?
|
12
|
+
return current.nil? ? nil : binary
|
13
|
+
end
|
14
|
+
return binary if current == latest
|
15
|
+
remove && download
|
9
16
|
end
|
10
17
|
|
11
|
-
def
|
12
|
-
return nil unless
|
13
|
-
|
18
|
+
def current
|
19
|
+
return nil unless downloaded?
|
20
|
+
puts binary
|
21
|
+
string = %x(#{binary} --version)
|
22
|
+
puts string
|
23
|
+
normalize string.match(/ChromeDriver (\d\.\d+)/)[1]
|
14
24
|
end
|
15
25
|
|
16
|
-
def
|
17
|
-
|
18
|
-
matched = version.match(/^(\d+)\.(\d+)$/)
|
19
|
-
minor = sprintf '%02d', matched[2]
|
20
|
-
hash["#{matched[1]}.#{minor}"] = version
|
21
|
-
end
|
22
|
-
padded.keys.sort.last
|
26
|
+
def latest
|
27
|
+
downloads.keys.sort.last
|
23
28
|
end
|
24
29
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
def remove
|
31
|
+
FileUtils.rm_f binary
|
32
|
+
end
|
33
|
+
|
34
|
+
def download(version = nil)
|
35
|
+
url = downloads[version || latest]
|
36
|
+
filename = File.basename url
|
37
|
+
|
38
|
+
Dir.chdir install_dir do
|
39
|
+
FileUtils.rm_f filename
|
40
|
+
File.open(filename, "wb") do |saved_file|
|
41
|
+
URI.parse(url).open("rb") do |read_file|
|
42
|
+
saved_file.write(read_file.read)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
raise "Could not download #{url}" unless File.exists? filename
|
46
|
+
dcf = decompress_file(filename)
|
47
|
+
extract_file(dcf) if respond_to? :extract_file
|
31
48
|
end
|
49
|
+
raise "Could not unzip #{filename} to get #{binary}" unless File.exists?(binary)
|
50
|
+
FileUtils.chmod "ugo+rx", binary
|
51
|
+
binary
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def normalize(string)
|
57
|
+
string.size == 3 ? string.gsub('.', '.0').to_f : string.to_f
|
58
|
+
end
|
59
|
+
|
60
|
+
def file_name
|
61
|
+
'chromedriver'
|
62
|
+
end
|
63
|
+
|
64
|
+
def downloaded?
|
65
|
+
File.exist? binary
|
66
|
+
end
|
67
|
+
|
68
|
+
def binary
|
69
|
+
File.join install_dir, file_name
|
32
70
|
end
|
33
71
|
|
34
72
|
def base_url
|
35
73
|
'http://chromedriver.storage.googleapis.com'
|
36
74
|
end
|
37
75
|
|
38
|
-
|
76
|
+
def site_available?
|
77
|
+
true if open(base_url)
|
78
|
+
rescue
|
79
|
+
false
|
80
|
+
end
|
81
|
+
|
82
|
+
def platform
|
83
|
+
cfg = RbConfig::CONFIG
|
84
|
+
case cfg['host_os']
|
85
|
+
when /linux/
|
86
|
+
cfg['host_cpu'] =~ /x86_64|amd64/ ? "linux64" : "linux32"
|
87
|
+
when /darwin/
|
88
|
+
"mac"
|
89
|
+
else
|
90
|
+
"win"
|
91
|
+
end
|
92
|
+
end
|
39
93
|
|
94
|
+
def decompress_file(filename)
|
95
|
+
case filename
|
96
|
+
when /tar\.gz$/
|
97
|
+
untargz_file(filename)
|
98
|
+
when /tar\.bz2$/
|
99
|
+
system "tar xjf #{filename}"
|
100
|
+
filename.gsub('.tar.bz2', '')
|
101
|
+
when /\.zip$/
|
102
|
+
unzip_file(filename)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def untargz_file(filename)
|
107
|
+
tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(filename))
|
108
|
+
tar_extract.rewind
|
109
|
+
|
110
|
+
ucf = File.open(file_name, "w+")
|
111
|
+
tar_extract.each {|entry| ucf << entry.read}
|
112
|
+
ucf.close
|
113
|
+
File.basename ucf
|
114
|
+
end
|
115
|
+
|
116
|
+
def unzip_file(filename)
|
117
|
+
Zip::File.open("#{Dir.pwd}/#{filename}") do |zip_file|
|
118
|
+
zip_file.each do |f|
|
119
|
+
@top_path ||= f.name
|
120
|
+
f_path = File.join(Dir.pwd, f.name)
|
121
|
+
FileUtils.rm_rf(f_path) if File.exist?(f_path)
|
122
|
+
FileUtils.mkdir_p(File.dirname(f_path)) unless File.exist?(File.dirname(f_path))
|
123
|
+
zip_file.extract(f, f_path)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
@top_path
|
127
|
+
end
|
128
|
+
|
129
|
+
def install_dir
|
130
|
+
File.expand_path(File.join(ENV['HOME'], ".webdrivers")).tap {|dir| FileUtils.mkdir_p dir}
|
131
|
+
end
|
132
|
+
|
133
|
+
def downloads
|
134
|
+
raise StandardError, "Can not reach site" unless site_available?
|
135
|
+
|
136
|
+
@downloads ||= begin
|
137
|
+
doc = Nokogiri::XML.parse(OpenURI.open_uri(base_url))
|
138
|
+
items = doc.css("Contents Key").collect(&:text)
|
139
|
+
items.select! {|item| item.include?('linux64')}
|
140
|
+
items.each_with_object({}) do |item, hash|
|
141
|
+
key = normalize item[/^[^\/]+/]
|
142
|
+
hash[key] = "#{base_url}/#{item}"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
40
148
|
end
|
41
149
|
end
|
data/lib/webdrivers.rb
CHANGED
@@ -1,9 +1,2 @@
|
|
1
|
-
require "webdrivers/
|
1
|
+
require "webdrivers/selenium"
|
2
2
|
require "webdrivers/chromedriver"
|
3
|
-
require "webdrivers/edgedriver"
|
4
|
-
require "webdrivers/geckodriver"
|
5
|
-
require "webdrivers/iedriver"
|
6
|
-
require "webdrivers/phantomjs"
|
7
|
-
require 'fileutils'
|
8
|
-
require 'rbconfig'
|
9
|
-
require 'open-uri'
|
data/spec/chromedriver_spec.rb
CHANGED
@@ -4,35 +4,41 @@ describe Webdrivers::Chromedriver do
|
|
4
4
|
|
5
5
|
let(:chromedriver) { Webdrivers::Chromedriver }
|
6
6
|
|
7
|
-
it '
|
8
|
-
chromedriver.
|
9
|
-
suffix = chromedriver.platform == 'win' ? '.exe' : ''
|
10
|
-
file = "#{chromedriver.platform_install_dir}/chromedriver#{suffix}"
|
11
|
-
expect(File.exist?(file)).to eq true
|
12
|
-
FileUtils.rm(file)
|
7
|
+
it 'parses chromedriver versions before 2.10' do
|
8
|
+
expect(chromedriver.send :normalize, '2.9').to eq 2.09
|
13
9
|
end
|
14
10
|
|
15
|
-
it
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
context "on a linux platform" do
|
20
|
-
before { allow(chromedriver).to receive(:platform) { "linux32" } }
|
21
|
-
|
22
|
-
it { expect(chromedriver.file_name).to match(/chromedriver$/) }
|
11
|
+
it 'finds latest version' do
|
12
|
+
expect(chromedriver.latest).to be > 2.30
|
13
|
+
expect(chromedriver.latest).to be < 2.9
|
14
|
+
end
|
23
15
|
|
24
|
-
|
16
|
+
it 'downloads latest version by default' do
|
17
|
+
chromedriver.download
|
18
|
+
expect(chromedriver.current).to eq chromedriver.latest
|
19
|
+
end
|
25
20
|
|
26
|
-
|
21
|
+
it 'downloads specified version' do
|
22
|
+
chromedriver.remove
|
23
|
+
chromedriver.download(2.29)
|
24
|
+
expect(chromedriver.current).to eq 2.29
|
27
25
|
end
|
28
26
|
|
29
|
-
|
30
|
-
|
27
|
+
it 'removes chromedriver' do
|
28
|
+
chromedriver.remove
|
29
|
+
expect(chromedriver.current).to be_nil
|
30
|
+
end
|
31
31
|
|
32
|
-
|
32
|
+
context 'when offline' do
|
33
|
+
before { allow(chromedriver).to receive(:site_available?).and_return(false) }
|
33
34
|
|
34
|
-
it
|
35
|
+
it 'raises exception finding latest version' do
|
36
|
+
expect {chromedriver.latest}.to raise_error(StandardError, "Can not reach site")
|
37
|
+
end
|
35
38
|
|
36
|
-
it
|
39
|
+
it 'raises exception downloading' do
|
40
|
+
expect {chromedriver.download}.to raise_error(StandardError, "Can not reach site")
|
41
|
+
end
|
37
42
|
end
|
43
|
+
|
38
44
|
end
|
data/webdrivers.gemspec
CHANGED
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "webdrivers"
|
6
|
-
s.version = "
|
6
|
+
s.version = "3.0.0.beta1"
|
7
7
|
s.authors = ["Titus Fortner"]
|
8
8
|
s.email = ["titusfortner@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/titusfortner/webdrivers"
|
10
|
-
s.summary = "Easy
|
10
|
+
s.summary = "Easy download and use of browser drivers."
|
11
11
|
s.description = "Run Selenium tests more easily with install and updates for all supported webdrivers."
|
12
12
|
s.licenses = ["MIT"]
|
13
13
|
|
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_runtime_dependency "nokogiri", "~> 1.6"
|
23
23
|
s.add_runtime_dependency "rubyzip", "~> 1.0"
|
24
|
+
s.add_runtime_dependency "selenium-webdriver", "~> 3.0"
|
24
25
|
end
|
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:
|
4
|
+
version: 3.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -66,16 +66,25 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: selenium-webdriver
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
69
83
|
description: Run Selenium tests more easily with install and updates for all supported
|
70
84
|
webdrivers.
|
71
85
|
email:
|
72
86
|
- titusfortner@gmail.com
|
73
|
-
executables:
|
74
|
-
- IEDriverServer
|
75
|
-
- MicrosoftWebDriver
|
76
|
-
- chromedriver
|
77
|
-
- geckodriver
|
78
|
-
- phantomjs
|
87
|
+
executables: []
|
79
88
|
extensions: []
|
80
89
|
extra_rdoc_files: []
|
81
90
|
files:
|
@@ -86,23 +95,10 @@ files:
|
|
86
95
|
- LICENSE.txt
|
87
96
|
- README.md
|
88
97
|
- Rakefile
|
89
|
-
- bin/IEDriverServer
|
90
|
-
- bin/MicrosoftWebDriver
|
91
|
-
- bin/chromedriver
|
92
|
-
- bin/geckodriver
|
93
|
-
- bin/phantomjs
|
94
98
|
- lib/webdrivers.rb
|
95
99
|
- lib/webdrivers/chromedriver.rb
|
96
|
-
- lib/webdrivers/
|
97
|
-
- lib/webdrivers/edgedriver.rb
|
98
|
-
- lib/webdrivers/geckodriver.rb
|
99
|
-
- lib/webdrivers/iedriver.rb
|
100
|
-
- lib/webdrivers/phantomjs.rb
|
100
|
+
- lib/webdrivers/selenium.rb
|
101
101
|
- spec/chromedriver_spec.rb
|
102
|
-
- spec/edgedriver_spec.rb
|
103
|
-
- spec/geckodriver_spec.rb
|
104
|
-
- spec/iedriver_spec.rb
|
105
|
-
- spec/phantomjs_spec.rb
|
106
102
|
- spec/spec_helper.rb
|
107
103
|
- webdrivers.gemspec
|
108
104
|
homepage: https://github.com/titusfortner/webdrivers
|
@@ -120,19 +116,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
116
|
version: '0'
|
121
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
118
|
requirements:
|
123
|
-
- - "
|
119
|
+
- - ">"
|
124
120
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
121
|
+
version: 1.3.1
|
126
122
|
requirements: []
|
127
123
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.5.2
|
129
125
|
signing_key:
|
130
126
|
specification_version: 4
|
131
|
-
summary: Easy
|
127
|
+
summary: Easy download and use of browser drivers.
|
132
128
|
test_files:
|
133
129
|
- spec/chromedriver_spec.rb
|
134
|
-
- spec/edgedriver_spec.rb
|
135
|
-
- spec/geckodriver_spec.rb
|
136
|
-
- spec/iedriver_spec.rb
|
137
|
-
- spec/phantomjs_spec.rb
|
138
130
|
- spec/spec_helper.rb
|
data/bin/IEDriverServer
DELETED
data/bin/MicrosoftWebDriver
DELETED
data/bin/chromedriver
DELETED
data/bin/geckodriver
DELETED
data/bin/phantomjs
DELETED
data/lib/webdrivers/common.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'rubygems/package'
|
2
|
-
require 'zip'
|
3
|
-
|
4
|
-
module Webdrivers
|
5
|
-
class Common
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def install *args
|
9
|
-
download
|
10
|
-
exec binary_path, *args
|
11
|
-
end
|
12
|
-
|
13
|
-
def download
|
14
|
-
return if File.exists?(binary_path) && !internet_connection?
|
15
|
-
raise StandardError, "Unable to Reach #{base_url}" unless internet_connection?
|
16
|
-
return if newest_version == current_version
|
17
|
-
|
18
|
-
url = download_url
|
19
|
-
filename = File.basename url
|
20
|
-
Dir.chdir platform_install_dir do
|
21
|
-
FileUtils.rm_f filename
|
22
|
-
File.open(filename, "wb") do |saved_file|
|
23
|
-
URI.parse(url).open("rb") do |read_file|
|
24
|
-
saved_file.write(read_file.read)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
raise "Could not download #{url}" unless File.exists? filename
|
28
|
-
dcf = decompress_file(filename)
|
29
|
-
extract_file(dcf) if respond_to? :extract_file
|
30
|
-
end
|
31
|
-
raise "Could not unzip #{filename} to get #{binary_path}" unless File.exists? binary_path
|
32
|
-
FileUtils.chmod "ugo+rx", binary_path
|
33
|
-
end
|
34
|
-
|
35
|
-
def decompress_file(filename)
|
36
|
-
case filename
|
37
|
-
when /tar\.gz$/
|
38
|
-
untargz_file(filename)
|
39
|
-
when /tar\.bz2$/
|
40
|
-
system "tar xjf #{filename}"
|
41
|
-
filename.gsub('.tar.bz2', '')
|
42
|
-
when /\.zip$/
|
43
|
-
unzip_file(filename)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def untargz_file(filename)
|
48
|
-
tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(filename))
|
49
|
-
tar_extract.rewind
|
50
|
-
|
51
|
-
ucf = File.open(file_name, "w+")
|
52
|
-
tar_extract.each { |entry| ucf << entry.read }
|
53
|
-
ucf.close
|
54
|
-
File.basename ucf
|
55
|
-
end
|
56
|
-
|
57
|
-
def unzip_file(filename)
|
58
|
-
Zip::File.open("#{Dir.pwd}/#{filename}") do |zip_file|
|
59
|
-
zip_file.each do |f|
|
60
|
-
@top_path ||= f.name
|
61
|
-
f_path = File.join(Dir.pwd, f.name)
|
62
|
-
FileUtils.rm_rf(f_path) if File.exist?(f_path)
|
63
|
-
FileUtils.mkdir_p(File.dirname(f_path)) unless File.exist?(File.dirname(f_path))
|
64
|
-
zip_file.extract(f, f_path)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
@top_path
|
68
|
-
end
|
69
|
-
|
70
|
-
def download_url(version = nil)
|
71
|
-
downloads[version || newest_version]
|
72
|
-
end
|
73
|
-
|
74
|
-
def binary_path
|
75
|
-
File.join platform_install_dir, file_name
|
76
|
-
end
|
77
|
-
|
78
|
-
def platform_install_dir
|
79
|
-
File.join(install_dir, platform).tap { |dir| FileUtils.mkdir_p dir }
|
80
|
-
end
|
81
|
-
|
82
|
-
def install_dir
|
83
|
-
File.expand_path(File.join(ENV['HOME'], ".webdrivers")).tap { |dir| FileUtils.mkdir_p dir }
|
84
|
-
end
|
85
|
-
|
86
|
-
def platform
|
87
|
-
cfg = RbConfig::CONFIG
|
88
|
-
case cfg['host_os']
|
89
|
-
when /linux/
|
90
|
-
cfg['host_cpu'] =~ /x86_64|amd64/ ? "linux64" : "linux32"
|
91
|
-
when /darwin/
|
92
|
-
"mac"
|
93
|
-
else
|
94
|
-
"win"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def internet_connection?
|
99
|
-
true #if open(base_url)
|
100
|
-
rescue
|
101
|
-
false
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module Webdrivers
|
4
|
-
class Edgedriver < Common
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def file_name
|
8
|
-
"MicrosoftWebDriver.exe"
|
9
|
-
end
|
10
|
-
|
11
|
-
def current_version
|
12
|
-
# No version information available
|
13
|
-
end
|
14
|
-
|
15
|
-
def newest_version
|
16
|
-
version = %x(ver)
|
17
|
-
version[/\d+\.\d+\.\d+/][/[^\.]\d+$/]
|
18
|
-
end
|
19
|
-
|
20
|
-
def download_url(version = nil)
|
21
|
-
if newest_version.to_i >= 14986
|
22
|
-
'https://download.microsoft.com/download/1/4/1/14156DA0-D40F-460A-B14D-1B264CA081A5/MicrosoftWebDriver.exe'
|
23
|
-
else
|
24
|
-
'https://download.microsoft.com/download/3/2/D/32D3E464-F2EF-490F-841B-05D53C848D15/MicrosoftWebDriver.exe'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def base_url
|
29
|
-
'http://google.com'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module Webdrivers
|
4
|
-
class Geckodriver < Common
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def file_name
|
8
|
-
platform == "win" ? "geckodriver.exe" : "geckodriver"
|
9
|
-
end
|
10
|
-
|
11
|
-
def current_version
|
12
|
-
return nil unless File.exists?(binary_path)
|
13
|
-
%x(#{binary_path} --version).match(/geckodriver (\d\.\d+\.\d+)/)[1]
|
14
|
-
end
|
15
|
-
|
16
|
-
def newest_version
|
17
|
-
padded = downloads.keys.each_with_object({}) do |version, hash|
|
18
|
-
matched = version.match(/^(\d+)\.(\d+)\.(\d+)$/)
|
19
|
-
minor = sprintf '%02d', matched[2]
|
20
|
-
hash["#{matched[1]}.#{minor}.#{matched[3]}"] = version
|
21
|
-
end
|
22
|
-
padded.keys.sort.last
|
23
|
-
end
|
24
|
-
|
25
|
-
def downloads
|
26
|
-
doc = Nokogiri::XML.parse(OpenURI.open_uri(base_url))
|
27
|
-
items = doc.css(".release-downloads a").collect {|item| item["href"]}
|
28
|
-
items.reject! {|item| item.include?('archive')}
|
29
|
-
items.select! {|item| item.include?(platform)}
|
30
|
-
items.each_with_object({}) do |item, hash|
|
31
|
-
hash[item[/v(\d+\.\d+\.\d+)/, 1]] = "https://github.com#{item}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def base_url
|
36
|
-
'https://github.com/mozilla/geckodriver/releases'
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
data/lib/webdrivers/iedriver.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module Webdrivers
|
4
|
-
class IEDriver < Common
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def file_name
|
8
|
-
"IEDriverServer.exe"
|
9
|
-
end
|
10
|
-
|
11
|
-
def current_version
|
12
|
-
return nil unless File.exists?(binary_path)
|
13
|
-
%x(#{binary_path} --version).strip.match(/IEDriverServer.exe (\d\.\d+\.\d*\.\d*)/)[1]
|
14
|
-
end
|
15
|
-
|
16
|
-
def newest_version
|
17
|
-
downloads.keys.sort.last
|
18
|
-
end
|
19
|
-
|
20
|
-
def downloads
|
21
|
-
doc = Nokogiri::XML.parse(OpenURI.open_uri(base_url))
|
22
|
-
items = doc.css("Key").collect(&:text)
|
23
|
-
items.select! { |item| item.include?('IEDriverServer_Win32') }
|
24
|
-
items.each_with_object({}) do |item, hash|
|
25
|
-
hash[item[/^[^\/]+/]] = "#{base_url}#{item}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def base_url
|
30
|
-
'http://selenium-release.storage.googleapis.com/'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
data/lib/webdrivers/phantomjs.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module Webdrivers
|
4
|
-
class PhantomJS < Common
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def file_name
|
8
|
-
platform == "win" ? "phantomjs.exe" : "phantomjs"
|
9
|
-
end
|
10
|
-
|
11
|
-
def current_version
|
12
|
-
return nil unless File.exists?(binary_path)
|
13
|
-
%x(#{binary_path} --version).strip.match(/(\d\.\d+\.\d+)/)[1]
|
14
|
-
end
|
15
|
-
|
16
|
-
def newest_version
|
17
|
-
downloads.keys.sort.last
|
18
|
-
end
|
19
|
-
|
20
|
-
def downloads
|
21
|
-
doc = Nokogiri::XML.parse(OpenURI.open_uri(base_url))
|
22
|
-
items = doc.css(".execute").collect { |item| item["href"] }
|
23
|
-
format_platform = platform.dup.gsub('32', '-i686').gsub('64', '-x86_64')
|
24
|
-
items.select! { |item| item.include?(format_platform) }
|
25
|
-
items.each_with_object({}) do |item, hash|
|
26
|
-
hash[item[/-(\d+\.\d+\.\d+)-/, 1]] = "https://bitbucket.org#{item}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def base_url
|
31
|
-
'https://bitbucket.org/ariya/phantomjs/downloads'
|
32
|
-
end
|
33
|
-
|
34
|
-
def extract_file(filename)
|
35
|
-
FileUtils.mv("#{platform_install_dir}/#{filename}/bin/#{file_name}", file_name)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
data/spec/edgedriver_spec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Webdrivers::Edgedriver do
|
4
|
-
|
5
|
-
let(:edgedriver) { Webdrivers::Edgedriver }
|
6
|
-
|
7
|
-
it 'downloads' do
|
8
|
-
allow(edgedriver).to receive(:newest_version).and_return(0)
|
9
|
-
edgedriver.download
|
10
|
-
file = "#{edgedriver.platform_install_dir}/MicrosoftWebDriver.exe"
|
11
|
-
expect(File.exist?(file)).to eq true
|
12
|
-
FileUtils.rm(file)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'gets latest version' do
|
16
|
-
skip unless edgedriver.platform == 'win'
|
17
|
-
expect(edgedriver.newest_version.to_f).to be >= 2.25
|
18
|
-
end
|
19
|
-
|
20
|
-
context "on a windows platform" do
|
21
|
-
before { allow(edgedriver).to receive(:platform) { "win" } }
|
22
|
-
|
23
|
-
it { expect(edgedriver.file_name).to match(/MicrosoftWebDriver\.exe$/) }
|
24
|
-
|
25
|
-
it { expect(edgedriver.binary_path).to match '.webdrivers/win/MicrosoftWebDriver.exe' }
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
data/spec/geckodriver_spec.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Webdrivers::Geckodriver do
|
4
|
-
|
5
|
-
let(:geckodriver) { Webdrivers::Geckodriver }
|
6
|
-
|
7
|
-
it 'downloads' do
|
8
|
-
geckodriver.download
|
9
|
-
suffix = geckodriver.platform == 'win' ? '.exe' : ''
|
10
|
-
file = "#{geckodriver.platform_install_dir}/geckodriver#{suffix}"
|
11
|
-
expect(File.exist?(file)).to eq true
|
12
|
-
FileUtils.rm(file)
|
13
|
-
end
|
14
|
-
|
15
|
-
it { expect(geckodriver.newest_version.to_f).to be >= 0.11 }
|
16
|
-
|
17
|
-
it { expect(geckodriver.downloads.size).to be >= 4 }
|
18
|
-
|
19
|
-
context "on a linux platform" do
|
20
|
-
before { allow(geckodriver).to receive(:platform) { "linux32" } }
|
21
|
-
|
22
|
-
it { expect(geckodriver.file_name).to match(/geckodriver$/) }
|
23
|
-
|
24
|
-
it { expect(geckodriver.binary_path).to match '.webdrivers/linux32/geckodriver' }
|
25
|
-
|
26
|
-
it { expect(geckodriver.download_url('0.11.0')).to match("v0.11.0/geckodriver-v0.11.0-linux32.tar.gz") }
|
27
|
-
end
|
28
|
-
|
29
|
-
context "on a windows platform" do
|
30
|
-
before { allow(geckodriver).to receive(:platform) { "win" } }
|
31
|
-
|
32
|
-
it { expect(geckodriver.file_name).to match(/geckodriver\.exe$/) }
|
33
|
-
|
34
|
-
it { expect(geckodriver.binary_path).to match '.webdrivers/win/geckodriver' }
|
35
|
-
|
36
|
-
it { expect(geckodriver.download_url('0.9.0')).to match("v0.9.0/geckodriver-v0.9.0-win64.zip") }
|
37
|
-
end
|
38
|
-
end
|
data/spec/iedriver_spec.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Webdrivers::IEDriver do
|
4
|
-
|
5
|
-
let(:iedriver) { Webdrivers::IEDriver }
|
6
|
-
|
7
|
-
it 'downloads' do
|
8
|
-
allow(iedriver).to receive(:current_version).and_return(0)
|
9
|
-
iedriver.download
|
10
|
-
file = "#{iedriver.platform_install_dir}/IEDriverServer.exe"
|
11
|
-
expect(File.exist?(file)).to eq true
|
12
|
-
FileUtils.rm(file)
|
13
|
-
end
|
14
|
-
|
15
|
-
it { expect(iedriver.newest_version.to_f).to be >= 2.25 }
|
16
|
-
|
17
|
-
|
18
|
-
context "on a windows platform" do
|
19
|
-
before { allow(iedriver).to receive(:platform) { "win" } }
|
20
|
-
|
21
|
-
it { expect(iedriver.downloads.size).to be >= 16 }
|
22
|
-
|
23
|
-
it { expect(iedriver.file_name).to match(/IEDriverServer\.exe$/) }
|
24
|
-
|
25
|
-
it { expect(iedriver.binary_path).to match '.webdrivers/win/IEDriverServer.exe' }
|
26
|
-
|
27
|
-
it { expect(iedriver.download_url('2.53')).to match("2.53/IEDriverServer_Win32") }
|
28
|
-
end
|
29
|
-
end
|
data/spec/phantomjs_spec.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Webdrivers::PhantomJS do
|
4
|
-
|
5
|
-
let(:phantomjs) { Webdrivers::PhantomJS }
|
6
|
-
|
7
|
-
it 'downloads' do
|
8
|
-
phantomjs.download
|
9
|
-
suffix = phantomjs.platform == 'win' ? '.exe' : ''
|
10
|
-
file = "#{phantomjs.platform_install_dir}/phantomjs#{suffix}"
|
11
|
-
expect(File.exist?(file)).to eq true
|
12
|
-
FileUtils.rm(file)
|
13
|
-
end
|
14
|
-
|
15
|
-
it { expect(phantomjs.newest_version.to_f).to be >= 0.11 }
|
16
|
-
|
17
|
-
it { expect(phantomjs.downloads.size).to be >= 4 }
|
18
|
-
|
19
|
-
context "on a linux platform" do
|
20
|
-
before { allow(phantomjs).to receive(:platform) { "linux64" } }
|
21
|
-
|
22
|
-
it { expect(phantomjs.file_name).to match(/phantomjs$/) }
|
23
|
-
|
24
|
-
it { expect(phantomjs.binary_path).to match '.webdrivers/linux64/phantomjs' }
|
25
|
-
|
26
|
-
it { expect(phantomjs.download_url('1.9.6')).to match("phantomjs-1.9.6-linux-") }
|
27
|
-
end
|
28
|
-
|
29
|
-
context "on a windows platform" do
|
30
|
-
before { allow(phantomjs).to receive(:platform) { "win" } }
|
31
|
-
|
32
|
-
it { expect(phantomjs.file_name).to match(/phantomjs\.exe$/) }
|
33
|
-
|
34
|
-
it { expect(phantomjs.binary_path).to match '.webdrivers/win/phantomjs' }
|
35
|
-
|
36
|
-
it { expect(phantomjs.download_url('1.9.7')).to match("phantomjs-1.9.7-windows.zip") }
|
37
|
-
end
|
38
|
-
end
|