oct-automation-utilities 0.0.16 → 0.0.17
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 +74 -50
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 416dfb44ae60effcb25e6b505a65fc88b45a5c4d
|
4
|
+
data.tar.gz: 14ee0a0c0f643e0de385f33f743ba51fdf97770a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5ecbae8a300033f05c8a0e003f2721cebf485b53e24189996daae22921c5700437f3a7aaf215a9732d38d652363579e8d7774dc2e0009a39b10859992b80c25
|
7
|
+
data.tar.gz: 2812ecc8eac03ec248b78c409746c07b5771e83b550ab0446af0c66d6623f62ebe4870e902fbdca873166cbfd76da0f5236b3faf7dc50e392abd2bc367ae46c1
|
@@ -1,48 +1,60 @@
|
|
1
1
|
module OctAutomationUtilities
|
2
2
|
require 'logger'
|
3
3
|
require 'capybara/rspec'
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
$test = ''
|
6
|
+
$step_num = 01
|
6
7
|
|
7
8
|
class Utilities
|
8
9
|
include Capybara::DSL
|
9
10
|
include Capybara::RSpecMatchers
|
10
|
-
include RSpec::Matchers
|
11
|
+
include ::RSpec::Matchers
|
11
12
|
|
12
|
-
|
13
|
+
#test data
|
14
|
+
attr_accessor :capture_screen, :screen_shot_path, :exe_time, :test_name, :project_directory, :test_time
|
13
15
|
|
14
|
-
|
16
|
+
#List of Objext
|
17
|
+
attr_accessor :obj_expected_page_content
|
15
18
|
|
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
|
16
28
|
end
|
17
29
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
30
|
+
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')
|
27
39
|
|
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")
|
32
|
-
end
|
33
40
|
end
|
34
41
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
42
|
+
def setup_log_level(log_level)
|
43
|
+
case log_level
|
44
|
+
when 'info'
|
45
|
+
@log.level = Logger::INFO
|
46
|
+
when 'debug'
|
47
|
+
@log.level = Logger::DEBUG
|
48
|
+
when 'warn'
|
49
|
+
@log.level = Logger::WARN
|
50
|
+
when 'error'
|
51
|
+
@log.level = Logger::ERROR
|
52
|
+
when 'fatal'
|
53
|
+
@log.level = Logger::FATAL
|
54
|
+
end
|
38
55
|
end
|
39
56
|
|
40
57
|
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
|
-
|
46
58
|
case severity
|
47
59
|
when 'progname'
|
48
60
|
@log.progname = msg
|
@@ -60,29 +72,13 @@ module OctAutomationUtilities
|
|
60
72
|
puts msg
|
61
73
|
end
|
62
74
|
|
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
|
-
|
78
75
|
def create_results_folder
|
79
76
|
Dir.mkdir("#{self.project_directory}/results")
|
80
77
|
end
|
81
78
|
|
82
79
|
def create_test_folder(test_name)
|
83
|
-
|
84
|
-
|
85
|
-
Dir.mkdir("#{test_folder_path}")
|
80
|
+
puts "create_test_folder #{self.project_directory}/results/#{test_name}"
|
81
|
+
Dir.mkdir("#{self.project_directory}/results/#{test_name}")
|
86
82
|
end
|
87
83
|
|
88
84
|
def create_time_results_folder(test_name)
|
@@ -104,6 +100,31 @@ module OctAutomationUtilities
|
|
104
100
|
self.capture_screen_shot("Verify content - #{self.obj_expected_page_content}")
|
105
101
|
end
|
106
102
|
|
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
|
+
|
107
128
|
def switch_windows(window_title)
|
108
129
|
page.within_window(window_title)
|
109
130
|
end
|
@@ -183,7 +204,15 @@ module OctAutomationUtilities
|
|
183
204
|
end
|
184
205
|
|
185
206
|
def browser_maximize
|
207
|
+
if @config.head_less == 'false'
|
186
208
|
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')
|
187
216
|
end
|
188
217
|
|
189
218
|
#Description: waits until given text appears on the page
|
@@ -359,11 +388,6 @@ module OctAutomationUtilities
|
|
359
388
|
page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
|
360
389
|
end
|
361
390
|
|
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
|
-
|
367
391
|
end
|
368
392
|
|
369
393
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Tracy
|
8
|
-
- Nick Robertson, Sam Vaugh, Berry North
|
8
|
+
- Nick Robertson, Sam Vaugh, Berry North, Matt Robbins
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-10-19 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.4.5
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: Utilities for Automation Framework
|