oct-automation-utilities 0.0.15 → 0.0.16
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 +4 -4
- data/lib/oct-automation-utilities.rb +50 -74
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 895dd2a86ac4e6687d8fd788cfa8b4dd935d4476
|
4
|
+
data.tar.gz: 22a6b988a6600b2d81124ea7a6b4857d68127dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9072c5c2f1c6f0b5c55c53f27f3d97ad24f3a7eefc4a895ed61b9f2cca386cba0b021ad699c3c379618d943999d4259976cb52fd26745417ce4d3c82cd4eaa3
|
7
|
+
data.tar.gz: 195296ec6ceca7f2fd9b28f7eb5f5f60d851ccd7a4d5eba93a28f6f1ca52703f9ad88ede9baa5d3311f4189b068c0ebbbb8047fc107995cba27851448044f147
|
@@ -1,60 +1,48 @@
|
|
1
1
|
module OctAutomationUtilities
|
2
2
|
require 'logger'
|
3
3
|
require 'capybara/rspec'
|
4
|
-
|
5
|
-
|
6
|
-
$step_num = 01
|
4
|
+
require 'yaml'
|
5
|
+
require 'csv'
|
7
6
|
|
8
7
|
class Utilities
|
9
8
|
include Capybara::DSL
|
10
9
|
include Capybara::RSpecMatchers
|
11
|
-
include
|
12
|
-
|
13
|
-
#test data
|
14
|
-
attr_accessor :capture_screen, :screen_shot_path, :exe_time, :test_name, :project_directory, :test_time
|
10
|
+
include RSpec::Matchers
|
15
11
|
|
16
|
-
#List of Objext
|
17
12
|
attr_accessor :obj_expected_page_content
|
18
13
|
|
19
|
-
def initialize
|
20
|
-
app = AutomationFramework::Application.new
|
21
|
-
self.project_directory = get_project_directory
|
22
|
-
self.test_name = 'default'
|
23
|
-
self.test_time = get_time
|
24
|
-
@config = AutomationFramework::Configuration.new
|
25
|
-
@log = Logger.new 'logger.log'
|
26
|
-
self.setup_log_level app.log_level
|
27
|
-
self.capture_screen = app.capture_screen_shot
|
28
|
-
end
|
29
|
-
|
30
14
|
def setup_directory(test_name = "default#{get_time}")
|
31
|
-
Dir.exist?("#{self.project_directory}/results") ? true : create_results_folder
|
32
|
-
Dir.exist?("#{self.project_directory}/results/#{test_name}") ? true : create_test_folder(test_name)
|
33
|
-
create_time_results_folder(test_name)
|
34
|
-
#Need to set self.screen_shot_path so that we can override the path as needed.
|
35
|
-
self.screen_shot_path = "#{self.project_directory}/results/#{test_name}/#{self.test_time}"
|
36
|
-
$test = self.screen_shot_path
|
37
|
-
$step_num = 01
|
38
|
-
self.log("Started - #{test_name}\n\nResults Path: #{self.screen_shot_path}", 'info')
|
39
15
|
|
40
16
|
end
|
41
17
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
18
|
+
def capture_screen_shot(msg='', status = '')
|
19
|
+
page.has_no_title?('foo')
|
20
|
+
current_test_time = self.get_time
|
21
|
+
failedmsg = ''
|
22
|
+
|
23
|
+
if status == 'fail'
|
24
|
+
failedmsg = "Test Failed!"
|
25
|
+
end
|
26
|
+
if self.get_data_from_config_file('capture_screen_shot') == 'true' || self.get_data_from_config_file('capture_screen_shot') == '' || status == 'fail'
|
27
|
+
|
28
|
+
screen_shot_path = self.get_data_from_config_file('screen_shot_path')
|
29
|
+
create_current_run_folder("#{screen_shot_path}/#{msg}/#{current_test_time}")
|
30
|
+
self.log "#{failedmsg} A screenshot of the Page can be viewed here: #{screen_shot_path}/#{msg}/#{current_test_time}", "fatal"
|
31
|
+
page.driver.save_screenshot("#{screen_shot_path}/#{msg}/#{current_test_time}/#{msg}.png")
|
54
32
|
end
|
55
33
|
end
|
56
34
|
|
35
|
+
def create_current_run_folder(folder_path)
|
36
|
+
FileUtils.mkdir_p(folder_path) unless File.exists?(folder_path)
|
37
|
+
Dir.exist?("#{folder_path}") ? true : create_test_folder(folder_path)
|
38
|
+
end
|
39
|
+
|
57
40
|
def log(msg, severity = 'info')
|
41
|
+
if @log.respond_to?(:level) == false
|
42
|
+
@log = Logger.new 'logger.log'
|
43
|
+
self.setup_log_level(self.get_data_from_config_file('log_level'))
|
44
|
+
end
|
45
|
+
|
58
46
|
case severity
|
59
47
|
when 'progname'
|
60
48
|
@log.progname = msg
|
@@ -72,13 +60,29 @@ module OctAutomationUtilities
|
|
72
60
|
puts msg
|
73
61
|
end
|
74
62
|
|
63
|
+
def setup_log_level(log_level)
|
64
|
+
case log_level
|
65
|
+
when 'info'
|
66
|
+
@log.level = Logger::INFO
|
67
|
+
when 'debug'
|
68
|
+
@log.level = Logger::DEBUG
|
69
|
+
when 'warn'
|
70
|
+
@log.level = Logger::WARN
|
71
|
+
when 'error'
|
72
|
+
@log.level = Logger::ERROR
|
73
|
+
when 'fatal'
|
74
|
+
@log.level = Logger::FATAL
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
75
78
|
def create_results_folder
|
76
79
|
Dir.mkdir("#{self.project_directory}/results")
|
77
80
|
end
|
78
81
|
|
79
82
|
def create_test_folder(test_name)
|
80
|
-
|
81
|
-
|
83
|
+
test_folder_path = "self.get_project_directory}/results/#{test_name}"
|
84
|
+
puts "create_test_folder #{test_folder_path}"
|
85
|
+
Dir.mkdir("#{test_folder_path}")
|
82
86
|
end
|
83
87
|
|
84
88
|
def create_time_results_folder(test_name)
|
@@ -100,31 +104,6 @@ module OctAutomationUtilities
|
|
100
104
|
self.capture_screen_shot("Verify content - #{self.obj_expected_page_content}")
|
101
105
|
end
|
102
106
|
|
103
|
-
def capture_screen_shot(msg='', status = '')
|
104
|
-
begin
|
105
|
-
if self.capture_screen == 'true' or status == 'fail'
|
106
|
-
#used to sync the page so it can capture the screen shot.
|
107
|
-
page.has_no_title?('foo')
|
108
|
-
msgx = "#{$test}/#{$step_num.to_s}-#{msg.to_s}"
|
109
|
-
if status == 'fail'
|
110
|
-
self.log "failed screenshot name: #{msgx}", "fatal"
|
111
|
-
page.driver.save_screenshot("#{msgx[0,101].to_s}-#{status}.png")
|
112
|
-
else
|
113
|
-
self.log "screenshot name: #{msgx}", "debug"
|
114
|
-
page.driver.save_screenshot("#{msgx[0,101].to_s}.png")
|
115
|
-
end
|
116
|
-
$step_num = ($step_num.to_i + 1).to_s
|
117
|
-
end
|
118
|
-
if status == ''
|
119
|
-
status = 'PASSED'
|
120
|
-
end
|
121
|
-
self.log("#{msg} - #{status}", 'info')
|
122
|
-
rescue Exception => e
|
123
|
-
self.log("#{msg} - FAILED", 'info')
|
124
|
-
raise e
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
107
|
def switch_windows(window_title)
|
129
108
|
page.within_window(window_title)
|
130
109
|
end
|
@@ -204,15 +183,7 @@ module OctAutomationUtilities
|
|
204
183
|
end
|
205
184
|
|
206
185
|
def browser_maximize
|
207
|
-
if @config.head_less == 'false'
|
208
186
|
page.driver.browser.manage.window.maximize
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
def browser_launch(bro, url)
|
213
|
-
visit url
|
214
|
-
self.browser_maximize
|
215
|
-
self.log("Browser #{bro} launched with url #{url}", 'info')
|
216
187
|
end
|
217
188
|
|
218
189
|
#Description: waits until given text appears on the page
|
@@ -388,6 +359,11 @@ module OctAutomationUtilities
|
|
388
359
|
page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
|
389
360
|
end
|
390
361
|
|
362
|
+
def get_data_from_config_file(property_name)
|
363
|
+
config = YAML.load(File.read(File.path 'spec/support/config.yml'))
|
364
|
+
config[property_name]
|
365
|
+
end
|
366
|
+
|
391
367
|
end
|
392
368
|
|
393
369
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oct-automation-utilities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Tracy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Utilities class that performs common automation functionality that can
|
15
15
|
be used over multiple projects
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.
|
41
|
+
rubygems_version: 2.2.2
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: Utilities for Automation Framework
|