pretest 1.12.0
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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +39 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +63 -0
- data/LICENSE.txt +662 -0
- data/README.md +69 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/pretest +5 -0
- data/bin/setup +6 -0
- data/lib/pretest.rb +2 -0
- data/lib/pretest/cli.rb +59 -0
- data/lib/pretest/config/linux.rb +60 -0
- data/lib/pretest/config/mac.rb +74 -0
- data/lib/pretest/config/operational_system.rb +34 -0
- data/lib/pretest/config/unix.rb +21 -0
- data/lib/pretest/config/windows.rb +135 -0
- data/lib/pretest/environment/check.rb +48 -0
- data/lib/pretest/mobile/environment.rb +81 -0
- data/lib/pretest/structure/clone.rb +115 -0
- data/lib/pretest/structure/clone/Gemfile.tt +55 -0
- data/lib/pretest/structure/clone/app_installation_hook.rb.tt +28 -0
- data/lib/pretest/structure/clone/app_life_cycle_hooks.rb.tt +13 -0
- data/lib/pretest/structure/clone/cucumber.yml.tt +1 -0
- data/lib/pretest/structure/clone/dry_run.rb.tt +16 -0
- data/lib/pretest/structure/clone/env.rb.tt +91 -0
- data/lib/pretest/structure/clone/example.feature.tt +35 -0
- data/lib/pretest/structure/clone/example.rb.tt +30 -0
- data/lib/pretest/structure/clone/first_launch.rb.tt +28 -0
- data/lib/pretest/structure/clone/hooks.rb.tt +18 -0
- data/lib/pretest/structure/clone/step_definitions.rb.tt +129 -0
- data/lib/pretest/version.rb +3 -0
- data/pretest.gemspec +30 -0
- metadata +224 -0
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
<h1>Pretest</h1>
|
3
|
+
|
4
|
+
<p>
|
5
|
+
Pretest is a gem that helps you to start your automation projects. With pretest you can start and configure your environment for web and mobile automation projects with just a few commands.
|
6
|
+
</p>
|
7
|
+
|
8
|
+
[](https://badge.fury.io/rb/pretest)
|
9
|
+
|
10
|
+
<h2>Requirements</h2>
|
11
|
+
|
12
|
+
<p>
|
13
|
+
Ruby installed in your machine (we recommend ruby 32 bits version if you're using Windows, and at least Windows 7 or a newer version) and the browsers that you want to use in your web automation (except for the phantomjs, that is installed automatically if the command "pretest environment" is used).
|
14
|
+
|
15
|
+
If you're having problems with firefox, we recommend to use the version 47.0.1 (https://ftp.mozilla.org/pub/firefox/releases/) due to issues with webdriver on newer versions.
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<h2>Installation</h2>
|
19
|
+
|
20
|
+
gem install pretest
|
21
|
+
|
22
|
+
<h2>How to use</h2>
|
23
|
+
|
24
|
+
<p>
|
25
|
+
For this we have some commands that can configure your environment for tests with chromedriver / phantomjs / IEDriverServer, and then its created a new folder that can be used to store others Webdriver's that you can use for your automations projects.
|
26
|
+
We have commands to create a new project structure, and a new project scaffold with examples of steps / features / and pages already created, that you can use to start to learn and create your own projects.
|
27
|
+
</p>
|
28
|
+
|
29
|
+
<h2>Commands</h2>
|
30
|
+
|
31
|
+
<ul>
|
32
|
+
<li>pretest</li>
|
33
|
+
<li>pretest help [COMMAND]</li>
|
34
|
+
<li>pretest environment</li>
|
35
|
+
<li>pretest create project_name</li>
|
36
|
+
<li>pretest create project_name --web_scaffold</li>
|
37
|
+
<li>pretest create project_name --api</li>
|
38
|
+
<li>pretest create project_name --api_scaffold</li>
|
39
|
+
</ul>
|
40
|
+
|
41
|
+
<h2>Usage</h2>
|
42
|
+
|
43
|
+
<p>
|
44
|
+
<strong>pretest:</strong> This command is used to list all the actual commands released in pretest
|
45
|
+
</p>
|
46
|
+
|
47
|
+
<p>
|
48
|
+
<strong>pretest help [COMMAND]:</strong> This command is used to list the actual command options (example: "pretest help create")
|
49
|
+
</p>
|
50
|
+
|
51
|
+
<p>
|
52
|
+
<strong>pretest environment:</strong> This command is used to configure your environment variables, download the webdrivers that can be use in your projects and install a development tool to compile your code (just if needed).
|
53
|
+
</p>
|
54
|
+
|
55
|
+
<p>
|
56
|
+
<strong>pretest create project_name:</strong> This command is used to create a new project for web automation with all the structure already created and environment configured.
|
57
|
+
</p>
|
58
|
+
|
59
|
+
<p>
|
60
|
+
<strong>pretest create project_name --web_scaffold:</strong> This command is used to create a new project for web automation with all the structure already created and environment configured, including some steps, features and pages with examples that can be used to develop new tests cases.
|
61
|
+
</p>
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Lemon-Studio/pretest.
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
The code licensed here under the GNU Affero General Public License, version 3 AGPL-3.0. [GNU AGPL 3.0 License](https://github.com/Lemon-Studio/pretest/blob/master/LICENSE.txt). Pretest has been developed by the LemonStudioLTDA team (Lucas Machado and Murilo Machado), as detailed in [LemonStudioLTDA Website](http://www.vilasboasit.com).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'pretest'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/pretest
ADDED
data/bin/setup
ADDED
data/lib/pretest.rb
ADDED
data/lib/pretest/cli.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'pretest/structure/clone'
|
3
|
+
require 'pretest/environment/check'
|
4
|
+
require 'pretest/mobile/environment'
|
5
|
+
|
6
|
+
module Pretest
|
7
|
+
class StructureGenerator < Thor
|
8
|
+
desc 'create [NAME]', 'This will generate your project structure'
|
9
|
+
method_option :web, type: :boolean, desc:
|
10
|
+
'Create a Web Automation Project Structure'
|
11
|
+
method_option :web_scaffold, type: :boolean, desc:
|
12
|
+
'Creates a Web Automation Project Structure with some steps,' \
|
13
|
+
' pages and features already created'
|
14
|
+
method_option :api, type: :boolean, desc:
|
15
|
+
'Create a API Automation Project Structure'
|
16
|
+
method_option :api_scaffold, type: :boolean, desc:
|
17
|
+
'Creates a API Automation Project Structure with some steps ' \
|
18
|
+
'and features already created'
|
19
|
+
method_option :clean_install, type: :boolean, desc:
|
20
|
+
'Creates a Clean Web Automation Project Structure'
|
21
|
+
method_option :ios, type: :boolean, desc:
|
22
|
+
'Create a iOS Mobile Automation Project Structure'
|
23
|
+
method_option :android, type: :boolean, desc:
|
24
|
+
'Create a Android Mobile Automation Project Structure'
|
25
|
+
|
26
|
+
def create(name)
|
27
|
+
web = options[:web] ? 'true' : 'false'
|
28
|
+
web_scaffold = options[:web_scaffold] ? 'true' : 'false'
|
29
|
+
api = options[:api] ? 'true' : 'false'
|
30
|
+
api_scaffold = options[:api_scaffold] ? 'true' : 'false'
|
31
|
+
clean_install = options[:clean_install] ? 'true' : 'false'
|
32
|
+
ios = options[:ios] ? 'true' : 'false'
|
33
|
+
android = options[:android] ? 'true' : 'false'
|
34
|
+
|
35
|
+
Pretest::Structure::Clone.start([name,
|
36
|
+
web,
|
37
|
+
web_scaffold,
|
38
|
+
api,
|
39
|
+
api_scaffold,
|
40
|
+
clean_install,
|
41
|
+
ios,
|
42
|
+
android])
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'environment', 'Check, configure, and install environment ' \
|
46
|
+
'variables and webdrivers in the current OS'
|
47
|
+
|
48
|
+
def environment
|
49
|
+
Pretest::Environment::Check.start
|
50
|
+
end
|
51
|
+
|
52
|
+
desc 'mobile_environment [ENVIRONMENT]', 'Check, configure and' \
|
53
|
+
' install environment variables and sdk path in the current OS'
|
54
|
+
|
55
|
+
def mobile_environment(env)
|
56
|
+
Pretest::Mobile::Environment.start([env])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative 'unix'
|
2
|
+
|
3
|
+
module Linux
|
4
|
+
include Unix
|
5
|
+
def set_linux_env
|
6
|
+
puts 'Installing ChromeDriver'
|
7
|
+
set_linux_chromedriver
|
8
|
+
puts 'Installing PhantomJS'
|
9
|
+
set_linux_phantomjs
|
10
|
+
puts 'Installing GeckoDriver'
|
11
|
+
set_linux_geckodriver
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def set_linux_chromedriver
|
17
|
+
remove_bin('chromedriver')
|
18
|
+
system "sudo rm -rf chromedriver_linux#{@bits}.zip" if Dir.entries('.').include?("chromedriver_linux#{@bits}.zip")
|
19
|
+
system "sudo rm -rf chromedriver_linux#{@bits}" if Dir.entries('.').include?("chromedriver_linux#{@bits}")
|
20
|
+
system "sudo curl -OL http://chromedriver.storage.googleapis.com/2.45/chromedriver_linux#{@bits}.zip"
|
21
|
+
system "sudo unzip chromedriver_linux#{@bits}.zip"
|
22
|
+
system 'sudo chmod +x chromedriver'
|
23
|
+
system 'sudo mv -f chromedriver /usr/local/bin/chromedriver'
|
24
|
+
system "sudo rm -rf chromedriver_linux#{@bits}.zip"
|
25
|
+
puts 'done!'
|
26
|
+
rescue StandardError => e
|
27
|
+
puts "Something went wrong with chromedriver instalation, if the following message did not help with the solution, please submit this message to our Repository in 'https://github.com/Lemon-Studio/pretest/issues'\n\n" \
|
28
|
+
"#{e}\n\n"
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_linux_geckodriver
|
32
|
+
remove_bin('geckodriver')
|
33
|
+
system 'sudo rm -rf geckodriver-v0.23.0-linux64.tar.gz' if Dir.entries('.').include?('geckodriver-v0.23.0-linux64.tar.gz')
|
34
|
+
system 'sudo rm -rf geckodriver-v0.23.0-linux64' if Dir.entries('.').include?('geckodriver-v0.23.0-linux64')
|
35
|
+
system 'sudo curl -OL https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz'
|
36
|
+
system 'sudo tar -xvzf geckodriver-v0.23.0-linux64.tar.gz'
|
37
|
+
system 'sudo chmod +x geckodriver'
|
38
|
+
system 'sudo mv -f geckodriver /usr/local/bin/geckodriver'
|
39
|
+
system 'sudo rm -rf geckodriver-v0.23.0-linux64.tar.gz'
|
40
|
+
puts 'done!'
|
41
|
+
rescue StandardError => e
|
42
|
+
puts "Something went wrong with geckodriver instalation, if the following message did not help with the solution, please submit this message to our Repository in 'https://github.com/Lemon-Studio/pretest/issues'\n\n" \
|
43
|
+
"#{e}\n\n"
|
44
|
+
end
|
45
|
+
|
46
|
+
def set_linux_phantomjs
|
47
|
+
remove_bin('phantomjs')
|
48
|
+
system "sudo rm -rf phantomjs-2.1.1-#{@phantomjs_bits}.tar.bz2" if Dir.entries('.').include?("phantomjs-2.1.1-#{@phantomjs_bits}.tar.bz2")
|
49
|
+
system "sudo rm -rf phantomjs-2.1.1-#{@phantomjs_bits}" if Dir.entries('.').include?("phantomjs-2.1.1-#{@phantomjs_bits}")
|
50
|
+
system "sudo curl -OL https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-#{@phantomjs_bits}.tar.bz2"
|
51
|
+
system "sudo tar xvjf phantomjs-2.1.1-#{@phantomjs_bits}.tar.bz2 > /dev/null"
|
52
|
+
system "sudo chmod +x phantomjs-2.1.1-#{@phantomjs_bits}/bin/phantomjs"
|
53
|
+
system "sudo mv -f phantomjs-2.1.1-#{@phantomjs_bits}/bin/phantomjs /usr/local/bin"
|
54
|
+
system "sudo rm -rf phantomjs-2.1.1-#{@phantomjs_bits}.tar.bz2"
|
55
|
+
puts 'done!'
|
56
|
+
rescue StandardError => e
|
57
|
+
puts "Something went wrong with phantomjs instalation, if the following message did not help with the solution, please submit this message to our Repository in 'https://github.com/Lemon-Studio/pretest/issues'\n\n" \
|
58
|
+
"#{e}\n\n"
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative 'unix'
|
2
|
+
|
3
|
+
module MacOS
|
4
|
+
include Unix
|
5
|
+
def set_mac_env
|
6
|
+
puts 'Installing/checking HomeBrew'
|
7
|
+
mac_update_brew
|
8
|
+
puts 'Installing PhantomJS'
|
9
|
+
mac_phantomjs_installer
|
10
|
+
puts 'Installing ChromeDriver'
|
11
|
+
mac_chromedriver_installer
|
12
|
+
puts 'Installing/Checking Xcode'
|
13
|
+
system 'xcode-select --install > /dev/null'
|
14
|
+
puts 'done!'
|
15
|
+
puts 'Installing GeckoDriver'
|
16
|
+
mac_gecko_installer
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def mac_update_brew
|
22
|
+
system "which -s brew
|
23
|
+
if [[ $? != 0 ]] ; then
|
24
|
+
ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)'
|
25
|
+
fi > /dev/null"
|
26
|
+
puts 'done!'
|
27
|
+
end
|
28
|
+
|
29
|
+
def mac_chromedriver_installer
|
30
|
+
remove_bin('chromedriver')
|
31
|
+
system 'sudo rm -rf chromedriver_mac64.zip' if Dir.entries('.').include?('chromedriver_mac64.zip')
|
32
|
+
system 'sudo rm -rf chromedriver_mac64' if Dir.entries('.').include?('chromedriver_mac64')
|
33
|
+
system 'sudo curl -OL https://chromedriver.storage.googleapis.com/2.45/chromedriver_mac64.zip'
|
34
|
+
system 'sudo unzip chromedriver_mac64.zip > /dev/null'
|
35
|
+
system 'sudo chmod +x chromedriver'
|
36
|
+
system 'sudo mv -f chromedriver /usr/local/bin'
|
37
|
+
system 'sudo rm -rf chromedriver_mac64.zip'
|
38
|
+
puts 'done!'
|
39
|
+
rescue StandardError => e
|
40
|
+
puts "Something went wrong with chromedriver instalation, if the following message did not help with the solution, please submit this message to our Repository in 'https://github.com/Lemon-Studio/pretest/issues'\n\n" \
|
41
|
+
"#{e}\n\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
def mac_gecko_installer
|
45
|
+
remove_bin('geckodriver')
|
46
|
+
system 'sudo rm -rf geckodriver-v0.23.0-macos.tar.gz' if Dir.entries('.').include?('geckodriver-v0.23.0-macos.tar.gz')
|
47
|
+
system 'sudo rm -rf geckodriver' if Dir.entries('.').include?('geckodriver')
|
48
|
+
system 'curl -OL https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-macos.tar.gz'
|
49
|
+
system 'sudo tar xvjf geckodriver-v0.23.0-macos.tar.gz'
|
50
|
+
system 'sudo chmod +x geckodriver'
|
51
|
+
system 'sudo mv -f geckodriver /usr/local/bin'
|
52
|
+
system 'sudo rm -rf geckodriver-v0.23.0-macos.tar.gz'
|
53
|
+
puts 'done!'
|
54
|
+
rescue StandardError => e
|
55
|
+
puts "Something went wrong with geckodriver instalation, if the following message did not help with the solution, please submit this message to our Repository in 'https://github.com/Lemon-Studio/pretest/issues'\n\n" \
|
56
|
+
"#{e}\n\n"
|
57
|
+
end
|
58
|
+
|
59
|
+
def mac_phantomjs_installer
|
60
|
+
remove_bin('phantomjs')
|
61
|
+
system 'sudo rm -rf phantomjs-2.1.1-macosx.zip' if Dir.entries('.').include?('phantomjs-2.1.1-macosx.zip')
|
62
|
+
system 'sudo rm -rf phantomjs-2.1.1-macosx' if Dir.entries('.').include?('phantomjs-2.1.1-macosx')
|
63
|
+
system 'sudo curl -OL https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip'
|
64
|
+
system 'unzip phantomjs-2.1.1-macosx.zip > /dev/null'
|
65
|
+
system 'sudo chmod +x phantomjs-2.1.1-macosx/bin/phantomjs'
|
66
|
+
system 'sudo mv -f phantomjs-2.1.1-macosx/bin/phantomjs /usr/local/bin'
|
67
|
+
system 'sudo rm -rf phantomjs-2.1.1-macosx.zip'
|
68
|
+
system 'sudo rm -rf phantomjs-2.1.1-macosx'
|
69
|
+
puts 'done!'
|
70
|
+
rescue StandardError => e
|
71
|
+
puts "Something went wrong with phantomjs instalation, if the following message did not help with the solution, please submit this message to our Repository in 'https://github.com/Lemon-Studio/pretest/issues'\n\n" \
|
72
|
+
"#{e}\n\n"
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative 'mac'
|
2
|
+
require_relative 'linux'
|
3
|
+
require_relative 'windows'
|
4
|
+
require_relative 'unix'
|
5
|
+
|
6
|
+
module Config
|
7
|
+
include MacOS
|
8
|
+
include Linux
|
9
|
+
include Windows
|
10
|
+
# include Unix
|
11
|
+
def mac?
|
12
|
+
!(/darwin/ =~ RUBY_PLATFORM).nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
def windows?
|
16
|
+
!(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil?
|
17
|
+
end
|
18
|
+
|
19
|
+
def unix?
|
20
|
+
!windows?
|
21
|
+
end
|
22
|
+
|
23
|
+
def linux?
|
24
|
+
unix? && !mac?
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_bits
|
28
|
+
if RUBY_PLATFORM.include?('32') && !RUBY_PLATFORM.include?('64')
|
29
|
+
(@bits = '32') && (@phantomjs_bits = 'linux-i686') && (@devkit = '32-4.7.2-20130224-1151')
|
30
|
+
else
|
31
|
+
(@bits = '64') && (@phantomjs_bits = 'linux-x86_64') && (@devkit = '64-4.7.2-20130224-1432')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'open3'
|
5
|
+
require 'pry'
|
6
|
+
|
7
|
+
module Unix
|
8
|
+
def remove_bin(file)
|
9
|
+
output, _status = Open3.capture2("which #{file}")
|
10
|
+
return false if output.nil?
|
11
|
+
return false if output.empty?
|
12
|
+
|
13
|
+
output = output.delete("\n") unless output.empty?
|
14
|
+
until output.empty?
|
15
|
+
system "sudo rm -rf #{output}"
|
16
|
+
output, _status = Open3.capture2("which #{file}").delete("\n")
|
17
|
+
output = '' if output.nil?
|
18
|
+
output = output.delete("\n") unless output.empty?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
def set_windows_env
|
5
|
+
Dir.mkdir('C:\\env_folder') unless Dir.entries('C:\\').include?('env_folder')
|
6
|
+
Dir.chdir('C:\\env_folder')
|
7
|
+
@ruby = get_ruby_path
|
8
|
+
puts "We're going to move the webdrivers to '#{@ruby}'"
|
9
|
+
puts 'Downloading webdrivers to C:\\env_folder'
|
10
|
+
windows_download
|
11
|
+
puts 'Unziping webdrivers files'
|
12
|
+
unzip_windows_files
|
13
|
+
puts 'Checking Ruby Development Kit...'
|
14
|
+
dk_check_and_install
|
15
|
+
move_webdrivers
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def unzip_file(file, destination)
|
21
|
+
Zip::File.open(file) do |zip_file|
|
22
|
+
zip_file.each do |f|
|
23
|
+
f_path = File.join(destination, f.name)
|
24
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
25
|
+
f.extract(f_path)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
system "del #{file}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def zip_download(name, url)
|
32
|
+
zipfile = url
|
33
|
+
resource = RestClient::Resource.new(
|
34
|
+
zipfile,
|
35
|
+
timeout: 120,
|
36
|
+
open_timeout: 60
|
37
|
+
)
|
38
|
+
response = resource.get
|
39
|
+
if response.code == 200
|
40
|
+
f = File.new(name, 'wb')
|
41
|
+
f << response.body
|
42
|
+
f.close
|
43
|
+
puts "#{name} Download Complete"
|
44
|
+
else
|
45
|
+
puts "#{name} Download Failed"
|
46
|
+
raise("Response Code was not 200: Response Code #{response.code}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def windows_download
|
51
|
+
set_bits
|
52
|
+
Dir.chdir('C:\\env_folder')
|
53
|
+
|
54
|
+
FileUtils.rm_rf('C:\\env_folder\\phantomjs-2.1.1-windows.zip') if Dir.entries('C:\\env_folder').include?('phantomjs-2.1.1-windows.zip')
|
55
|
+
FileUtils.rm_rf('C:\\env_folder\\IEDriverServer_Win32_3.4.0.zip') if Dir.entries('C:\\env_folder').include?('IEDriverServer_Win32_3.4.0.zip')
|
56
|
+
FileUtils.rm_rf("C:\\env_folder\\geckodriver-v0.23.0-win#{@bits}.zip") if Dir.entries('C:\\env_folder').include?("geckodriver-v0.23.0-win#{@bits}.zip")
|
57
|
+
FileUtils.rm_rf('C:\\env_folder\\chromedriver_win32.zip') if Dir.entries('C:\\env_folder').include?('chromedriver_win32.zip')
|
58
|
+
|
59
|
+
FileUtils.rm_rf('C:\\env_folder\\chromedriver.exe') if Dir.entries('C:\\env_folder').include?('chromedriver.exe')
|
60
|
+
FileUtils.rm_rf('C:\\env_folder\\IEDriverServer.exe') if Dir.entries('C:\\env_folder').include?('IEDriverServer.exe')
|
61
|
+
FileUtils.rm_rf('C:\\env_folder\\geckodriver.exe') if Dir.entries('C:\\env_folder').include?('geckodriver.exe')
|
62
|
+
FileUtils.rm_rf('C:\\env_folder\\phantomjs-2.1.1-windows') if Dir.entries('C:\\env_folder').include?('phantomjs-2.1.1-windows')
|
63
|
+
FileUtils.rm_rf('C:\\env_folder\\phantomjs.exe') if Dir.entries('C:\\env_folder').include?('phantomjs.exe')
|
64
|
+
|
65
|
+
zip_download('chromedriver_win32.zip', 'https://chromedriver.storage.googleapis.com/2.45/chromedriver_win32.zip') unless Dir.entries('.').include?('chromedriver_win32.zip') || Dir.entries('.').include?('chrome.exe')
|
66
|
+
zip_download('phantomjs-2.1.1-windows.zip', 'https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-windows.zip') unless Dir.entries('.').include?('phantomjs-2.1.1-windows.zip') || Dir.entries('.').include?('phantomjs.exe')
|
67
|
+
zip_download('IEDriverServer_Win32_3.4.0.zip', 'http://selenium-release.storage.googleapis.com/3.4/IEDriverServer_Win32_3.4.0.zip') unless Dir.entries('.').include?('IEDriverServer_Win32_3.4.0.zip') || Dir.entries('.').include?('IEDriverServer.exe')
|
68
|
+
zip_download("geckodriver-v0.23.0-win#{@bits}.zip", "https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-win#{@bits}.zip") unless Dir.entries('.').include?("geckodriver-v0.23.0-win#{@bits}") || Dir.entries('.').include?('geckodriver.exe')
|
69
|
+
end
|
70
|
+
|
71
|
+
def unzip_windows_files
|
72
|
+
set_bits
|
73
|
+
unzip_file('chromedriver_win32.zip', '.') unless Dir.entries('.').include?('chromedriver.exe')
|
74
|
+
unzip_file('phantomjs-2.1.1-windows.zip', '.') unless Dir.entries('.').include?('phantomjs.exe') || File.directory?('phantomjs-2.1.1-windows')
|
75
|
+
unzip_file('IEDriverServer_Win32_3.4.0.zip', '.') unless Dir.entries('.').include?('IEDriverServer.exe')
|
76
|
+
unzip_file("geckodriver-v0.23.0-win#{@bits}.zip", '.') unless Dir.entries('.').include?('geckodriver.exe')
|
77
|
+
end
|
78
|
+
|
79
|
+
def dk_check_and_install
|
80
|
+
set_bits
|
81
|
+
rbenv = ''
|
82
|
+
rbpath = ''
|
83
|
+
rblist = ''
|
84
|
+
rbenv += ENV['PATH']
|
85
|
+
raise 'There is no Ruby environment variable defined in current PATH' if ENV['PATH'].include?('Ruby') == false
|
86
|
+
|
87
|
+
rbenv = rbenv.split(';')
|
88
|
+
rbenv.each do |rb|
|
89
|
+
rbpath = rb if rb.include?('Ruby')
|
90
|
+
end
|
91
|
+
rbpath = rbpath.gsub!('bin', 'lib\\ruby\\site_ruby\\')
|
92
|
+
Dir.entries(rbpath).each { |files| rblist << files.to_s }
|
93
|
+
if rblist.include?('devkit')
|
94
|
+
else
|
95
|
+
zip_download("DevKit-mingw64-#{@devkit}-sfx.exe", "http://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-#{@devkit}-sfx.exe")
|
96
|
+
unzip_install_dk("DevKit-mingw64-#{@devkit}-sfx.exe")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def unzip_install_dk(file)
|
101
|
+
Dir.chdir('C:\\env_folder')
|
102
|
+
FileUtils.rm_rf('C:\\env_folder\\devkit') if Dir.entries('C:\\env_folder').include?('devkit')
|
103
|
+
Dir.mkdir('devkit')
|
104
|
+
FileUtils.mv(file.to_s, 'C:\\env_folder\\devkit\\')
|
105
|
+
Dir.chdir('devkit')
|
106
|
+
system "#{file} -o '.' -y"
|
107
|
+
system "del #{file}"
|
108
|
+
system 'ruby dk.rb init'
|
109
|
+
system 'ruby dk.rb install'
|
110
|
+
end
|
111
|
+
|
112
|
+
def move_webdrivers
|
113
|
+
FileUtils.rm_rf("#{@ruby}}\\phantomjs.exe") if Dir.entries(@ruby).include?('phantomjs.exe')
|
114
|
+
FileUtils.rm_rf("#{@ruby}}\\geckodriver.exe") if Dir.entries(@ruby).include?('geckodriver.exe')
|
115
|
+
FileUtils.rm_rf("#{@ruby}}\\chromedriver.exe") if Dir.entries(@ruby).include?('chromedriver.exe')
|
116
|
+
FileUtils.rm_rf("#{@ruby}}\\IEDriverServer.exe") if Dir.entries(@ruby).include?('IEDriverServer.exe')
|
117
|
+
|
118
|
+
FileUtils.mv('C:\\env_folder\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe', @ruby)
|
119
|
+
FileUtils.mv('C:\\env_folder\\chromedriver.exe', @ruby)
|
120
|
+
FileUtils.mv('C:\\env_folder\\IEDriverServer.exe', @ruby)
|
121
|
+
FileUtils.mv('C:\\env_folder\\geckodriver.exe', @ruby)
|
122
|
+
|
123
|
+
FileUtils.rm_rf('C:\\env_folder\\phantomjs-2.1.1-windows') if Dir.entries('.').include?('phantomjs-2.1.1-windows')
|
124
|
+
end
|
125
|
+
|
126
|
+
def get_ruby_path
|
127
|
+
env = ENV['PATH'].split(';')
|
128
|
+
rb_path = env.each do |path|
|
129
|
+
return path if path.upcase.include?('RUBY') && path.upcase.include?('BIN')
|
130
|
+
end
|
131
|
+
raise "We couldn't locate the ruby installed on the current machine" if rb_path.nil?
|
132
|
+
|
133
|
+
rb_path
|
134
|
+
end
|
135
|
+
end
|