taf 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/functions/handlers/base_handler.rb +9 -9
- data/lib/functions/handlers/browser_back.rb +2 -2
- data/lib/functions/handlers/browser_forward.rb +2 -2
- data/lib/functions/handlers/browser_quit.rb +2 -2
- data/lib/functions/handlers/browser_refresh.rb +2 -2
- data/lib/functions/handlers/capture_alert.rb +2 -2
- data/lib/functions/handlers/check_box.rb +1 -1
- data/lib/functions/handlers/check_boxdata.rb +4 -2
- data/lib/functions/handlers/check_browser_title.rb +1 -1
- data/lib/functions/handlers/check_logs.rb +1 -1
- data/lib/functions/handlers/check_screendata.rb +1 -1
- data/lib/functions/handlers/check_url.rb +1 -1
- data/lib/functions/handlers/click_button.rb +3 -2
- data/lib/functions/handlers/execute_system_command.rb +1 -1
- data/lib/functions/handlers/handle_browser_window.rb +1 -1
- data/lib/functions/handlers/insert_value_config.rb +1 -1
- data/lib/functions/handlers/ipause.rb +1 -1
- data/lib/functions/handlers/list_all_dropdowns_values.rb +2 -2
- data/lib/functions/handlers/open_portal_url.rb +1 -1
- data/lib/functions/handlers/open_url.rb +1 -1
- data/lib/functions/handlers/ping_test.rb +11 -12
- data/lib/functions/handlers/portal_login.rb +1 -1
- data/lib/functions/handlers/radio_button.rb +2 -2
- data/lib/functions/handlers/select_dropdown.rb +2 -2
- data/lib/functions/handlers/send_special_keys.rb +1 -1
- data/lib/functions/handlers/write_box_data.rb +4 -2
- data/lib/functions/handlers/write_to_editor.rb +1 -1
- data/lib/main.rb +57 -45
- data/lib/parser/parser.rb +10 -10
- data/lib/report/junit_report.rb +3 -3
- data/lib/report/report.rb +36 -38
- data/lib/report/report_summary.rb +1 -1
- data/lib/taf_config.rb +1 -0
- data/lib/utils/browser.rb +20 -22
- data/lib/utils/create_directories.rb +1 -3
- data/lib/utils/test_engine.rb +9 -9
- data/lib/utils/test_steps.rb +6 -7
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47c34f68219bf7188b916a891f7a86f4d14b08a437d08201382e7f3202e21143
|
4
|
+
data.tar.gz: 501befb0dc3bf630031a1094df678c1fa100e3be6c31d799dd914ac173e83938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1a1b0383b4d37a35b566a2739601f8818f887b9b8ac6e25702fde9ffa39416595c5f806fa8e6f550e008da6b7cbbb486fe105de60abb0b29dd53cfcb87f77b8
|
7
|
+
data.tar.gz: a3c32e949362a648f88e797185fa0883a8d010085b21d18a390ad5e6274f298eb31c6234bce00c15933dddb6ae01ed46a6cafb69c7b43fe00071db44918254ac
|
@@ -62,18 +62,18 @@ module TestSteps
|
|
62
62
|
password = ENV['PORTAL_MEM']
|
63
63
|
nums = (1..256).to_a
|
64
64
|
found_mem_nums = nums.each_with_object([]) do |num_val, mem_word|
|
65
|
-
|
66
|
-
|
65
|
+
elm_id = "user_memorable_parts_#{num_val}"
|
66
|
+
mem_word.push(num_val) if Browser.b.select(id: elm_id).exist?
|
67
67
|
end.compact
|
68
68
|
|
69
69
|
array_password = password.split('')
|
70
70
|
array_password.map!(&:upcase)
|
71
71
|
|
72
|
-
found_mem_nums.each
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
found_mem_nums.each do |mem_num|
|
73
|
+
char = array_password[(mem_num - 1)]
|
74
|
+
elm_id = "user_memorable_parts_#{mem_num}"
|
75
|
+
Browser.b.select_list(id: elm_id).option(value: char.to_s).select
|
76
|
+
end
|
77
77
|
|
78
78
|
Browser.b.button(value: 'Sign in').wait_until(&:exists?).click
|
79
79
|
if Browser.b.title.eql?(b_title_sucess)
|
@@ -84,6 +84,6 @@ module TestSteps
|
|
84
84
|
return false
|
85
85
|
end
|
86
86
|
end
|
87
|
-
end
|
87
|
+
end
|
88
88
|
end
|
89
|
-
end
|
89
|
+
end
|
@@ -5,7 +5,7 @@ module TestSteps
|
|
5
5
|
class BrowserBack < Base
|
6
6
|
register :browser_back
|
7
7
|
|
8
|
-
def perform(
|
8
|
+
def perform(_step_attributes)
|
9
9
|
Browser.b.back
|
10
10
|
MyLog.log.info('Browser navigated back')
|
11
11
|
true
|
@@ -15,4 +15,4 @@ module TestSteps
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
@@ -5,7 +5,7 @@ module TestSteps
|
|
5
5
|
class BrowserForward < Base
|
6
6
|
register :browser_forward
|
7
7
|
|
8
|
-
def perform(
|
8
|
+
def perform(_step_attributes)
|
9
9
|
Browser.b.forward
|
10
10
|
MyLog.log.info('Browser navigated forward')
|
11
11
|
true
|
@@ -15,4 +15,4 @@ module TestSteps
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
@@ -5,7 +5,7 @@ module TestSteps
|
|
5
5
|
class BrowserQuit < Base
|
6
6
|
register :browser_quit
|
7
7
|
|
8
|
-
def perform(
|
8
|
+
def perform(_step_attributes)
|
9
9
|
Browser.b.quit
|
10
10
|
MyLog.log.info('Browser has closed successfully')
|
11
11
|
true
|
@@ -15,4 +15,4 @@ module TestSteps
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
@@ -5,7 +5,7 @@ module TestSteps
|
|
5
5
|
class BrowserRefresh < Base
|
6
6
|
register :browser_refresh
|
7
7
|
|
8
|
-
def perform(
|
8
|
+
def perform(_step_attributes)
|
9
9
|
Browser.b.refresh
|
10
10
|
MyLog.log.info('The Browser has been refreshed')
|
11
11
|
true
|
@@ -15,4 +15,4 @@ module TestSteps
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
@@ -5,7 +5,7 @@ module TestSteps
|
|
5
5
|
class CaptureAlert < Base
|
6
6
|
register :capture_alert
|
7
7
|
|
8
|
-
def perform(
|
8
|
+
def perform(_step_attributes)
|
9
9
|
Browser.b.div(class: 'alert').exist?
|
10
10
|
alertmsg = Browser.b.div(class: 'alert').text
|
11
11
|
MyLog.log.info("Alert shown: #{alertmsg}")
|
@@ -16,4 +16,4 @@ module TestSteps
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
@@ -14,10 +14,12 @@ module TestSteps
|
|
14
14
|
Browser.b.textarea(:"#{locate}" => box).exist?,
|
15
15
|
Browser.b.text_field(:"#{locate}" => box).exist?
|
16
16
|
]
|
17
|
-
|
17
|
+
|
18
18
|
raise 'Multiple matches' if found_box.select { |i| i }.empty?
|
19
|
+
|
19
20
|
index = found_box.index(true)
|
20
21
|
return unless index
|
22
|
+
|
21
23
|
if index.zero?
|
22
24
|
Browser.b.textarea(:"#{locate}" => box).wait_until(&:exists?)
|
23
25
|
(Browser.b.textarea(:"#{locate}" => box).value == value)
|
@@ -36,4 +38,4 @@ module TestSteps
|
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
39
|
-
end
|
41
|
+
end
|
@@ -8,7 +8,7 @@ module TestSteps
|
|
8
8
|
def perform(step_attributes)
|
9
9
|
b_title = step_attributes[:testvalue]
|
10
10
|
|
11
|
-
Browser.b.wait_until { Browser.b.title.eql?
|
11
|
+
Browser.b.wait_until { Browser.b.title.eql? b_title }
|
12
12
|
MyLog.log.info("Browser title: #{b_title}")
|
13
13
|
true
|
14
14
|
rescue StandardError
|
@@ -8,7 +8,7 @@ module TestSteps
|
|
8
8
|
def perform(step_attributes)
|
9
9
|
check_text = step_attributes[:testvalue]
|
10
10
|
|
11
|
-
Browser.b.wait_until { Browser.b.element.text.include?
|
11
|
+
Browser.b.wait_until { Browser.b.element.text.include? check_text }
|
12
12
|
MyLog.log.info("Text found: #{check_text}")
|
13
13
|
true
|
14
14
|
rescue StandardError
|
@@ -9,13 +9,14 @@ module TestSteps
|
|
9
9
|
button = step_attributes[:testvalue]
|
10
10
|
locate = step_attributes[:locate]
|
11
11
|
|
12
|
-
elms = %i
|
12
|
+
elms = %i[button span a div link image h1 h2 h3 h4]
|
13
13
|
|
14
14
|
found_button = elms.map do |elm|
|
15
15
|
Browser.b.send(elm, :"#{locate}" => button).exists?
|
16
16
|
end.compact
|
17
17
|
|
18
18
|
raise 'Multiple matches' if found_button.select { |i| i }.empty?
|
19
|
+
|
19
20
|
index = found_button.index(true)
|
20
21
|
return unless index
|
21
22
|
|
@@ -49,4 +50,4 @@ module TestSteps
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
52
|
-
end
|
53
|
+
end
|
@@ -12,7 +12,7 @@ module TestSteps
|
|
12
12
|
Browser.b.element(:"#{locate}" => dropdown).wait_until(&:exists?)
|
13
13
|
Browser.b.select_list(:"#{locate}" => dropdown).options.each do |i|
|
14
14
|
MyLog.log.info("List of dropdown for #{dropdown} are: #{i.text}")
|
15
|
-
|
15
|
+
return true
|
16
16
|
end
|
17
17
|
rescue StandardError
|
18
18
|
MyLog.log.warn("List dropdown: #{dropdown} does not exist")
|
@@ -20,4 +20,4 @@ module TestSteps
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
@@ -5,21 +5,20 @@ module TestSteps
|
|
5
5
|
class PingTest < Base
|
6
6
|
register :ping_test
|
7
7
|
|
8
|
+
# TODO: retry every 'x' until timeout reached.
|
8
9
|
def perform(step_attributes)
|
9
10
|
url = step_attributes[:testvalue]
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
return false
|
22
|
-
end
|
12
|
+
check = Net::Ping::HTTP.new(url)
|
13
|
+
|
14
|
+
check.ping?
|
15
|
+
sleep 5
|
16
|
+
if check.ping?
|
17
|
+
MyLog.log.info("pinged: #{url}")
|
18
|
+
return true
|
19
|
+
else
|
20
|
+
MyLog.log.warn("Failed to ping: #{url}")
|
21
|
+
return false
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
@@ -12,7 +12,7 @@ module TestSteps
|
|
12
12
|
locate2 = step_attributes[:locate2]
|
13
13
|
|
14
14
|
Browser.b.radio(:"#{locate}" => radio).wait_until(&:exists?)
|
15
|
-
Browser.b.radio(:"#{locate}" => radio, :"#{locate2}" =>
|
15
|
+
Browser.b.radio(:"#{locate}" => radio, :"#{locate2}" => value2.to_s).set
|
16
16
|
MyLog.log.info("Radio button: #{radio} has been selected")
|
17
17
|
true
|
18
18
|
rescue StandardError
|
@@ -21,4 +21,4 @@ module TestSteps
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
|
-
end
|
24
|
+
end
|
@@ -12,7 +12,7 @@ module TestSteps
|
|
12
12
|
locate2 = step_attributes[:locate2]
|
13
13
|
|
14
14
|
Browser.b.select_list(:"#{locate}" => dropdown).wait_until(&:exists?)
|
15
|
-
Browser.b.select_list(:"#{locate}" => dropdown).option(:"#{locate2}" =>
|
15
|
+
Browser.b.select_list(:"#{locate}" => dropdown).option(:"#{locate2}" => value2.to_s).select
|
16
16
|
MyLog.log.info("Dropdown item: #{value2} has been selected")
|
17
17
|
true
|
18
18
|
rescue StandardError
|
@@ -24,4 +24,4 @@ module TestSteps
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
@@ -14,10 +14,12 @@ module TestSteps
|
|
14
14
|
Browser.b.textarea(:"#{locate}" => box).exist?,
|
15
15
|
Browser.b.text_field(:"#{locate}" => box).exist?
|
16
16
|
]
|
17
|
-
|
17
|
+
|
18
18
|
raise 'Multiple matches' if found_box.select { |i| i }.empty?
|
19
|
+
|
19
20
|
index = found_box.index(true)
|
20
21
|
return unless index
|
22
|
+
|
21
23
|
if index.zero?
|
22
24
|
Browser.b.textarea(:"#{locate}" => box).wait_until(&:exists?).set value
|
23
25
|
(Browser.b.textarea(:"#{locate}" => box).value == value)
|
@@ -36,4 +38,4 @@ module TestSteps
|
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
39
|
-
end
|
41
|
+
end
|
data/lib/main.rb
CHANGED
@@ -10,58 +10,70 @@
|
|
10
10
|
module Main
|
11
11
|
require_relative './taf_config.rb'
|
12
12
|
|
13
|
-
|
14
|
-
#
|
15
|
-
|
13
|
+
def self.cmdline_input
|
14
|
+
# check if the test suite file name exists on the command line
|
15
|
+
# allow a user to input 2 arguments in to CMD line the 2 values are:
|
16
|
+
# Testcase Folder and Browser.
|
17
|
+
options = {}
|
18
|
+
ARGV.push('-h') if ARGV.empty?
|
19
|
+
OptionParser.new do |parser|
|
20
|
+
# Whenever we see -b, -t or --browser, or --tests with an
|
21
|
+
# argument, save the argument.
|
22
|
+
parser.banner = 'Usage: taf [options]'
|
23
|
+
parser.on('-h', '--help', "2 arguments are required: {Browser} {Testcase folder}'") do
|
24
|
+
puts parser
|
25
|
+
Process.exit
|
26
|
+
end
|
16
27
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
$currentTestFail = false
|
26
|
-
# initialised stores for the input xlsx test data
|
27
|
-
$XlsxDoc = ''
|
28
|
+
parser.on('-b', '--browser browser', 'Supported Browsers: chrome, chrome-headless, firefox, firefox-headless.') do |b|
|
29
|
+
options[:browser] = b
|
30
|
+
$browserType = options[:browser]
|
31
|
+
unless ['chrome', 'chrome-headless', 'firefox', 'firefox-headless'].include?($browserType)
|
32
|
+
MyLog.log.warn 'A valid Browser has not been supplied as a command-line parameter as expected'
|
33
|
+
Process.exit
|
34
|
+
end
|
35
|
+
end
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
$testcasesFolder = 'unknown'
|
40
|
-
error_to_display = 'Test case location has not been supplied as a command-line parameter as expected'
|
41
|
-
$browserType = 'unknown'
|
42
|
-
error_to_display = 'Browser has not been supplied as a command-line parameter as expected'
|
43
|
-
raise IOError, error_to_display
|
37
|
+
parser.on('-t', '--tests testfolder', 'i.e. tests/') do |t|
|
38
|
+
options[:testfolder] = t
|
39
|
+
$testcasesFolder = options[:testfolder]
|
40
|
+
if Parser.test_files.size.positive?
|
41
|
+
MyLog.log.info "There are: #{Parser.test_files.size} test files to process"
|
42
|
+
MyLog.log.info "List of Tests files: #{Parser.test_files} \n"
|
43
|
+
else
|
44
|
+
MyLog.log.warn 'A valid Test case location has not been supplied as a command-line parameter as expected'
|
45
|
+
Process.exit
|
46
|
+
end
|
44
47
|
end
|
45
|
-
|
46
|
-
rescue StandardError => error
|
47
|
-
warn error
|
48
|
-
MyLog.log.warn error
|
49
|
-
abort
|
48
|
+
end.parse!
|
50
49
|
end
|
51
50
|
|
52
|
-
|
51
|
+
begin
|
52
|
+
# variables to manage the failure reporting
|
53
|
+
$testStepPasses = 0
|
54
|
+
$testStepFailures = 0
|
55
|
+
$testStepNotrun = 0
|
56
|
+
$totalTestPasses = 0
|
57
|
+
$totalTestFailures = 0
|
58
|
+
$totalTestNotrun = 0
|
59
|
+
$previousTestFail = false
|
60
|
+
$currentTestFail = false
|
61
|
+
# initialised stores for the input xlsx test data
|
62
|
+
$XlsxDoc = ''
|
63
|
+
# parses the cmd line imput into the taf
|
64
|
+
Main.cmdline_input
|
65
|
+
end
|
53
66
|
|
54
|
-
|
55
|
-
|
67
|
+
# process the test files to execute the tests
|
68
|
+
TestEngine.process_testfiles
|
56
69
|
|
57
|
-
|
58
|
-
|
70
|
+
# get the overall test end time
|
71
|
+
$test_end_time = Report.current_time
|
59
72
|
|
60
|
-
|
61
|
-
|
62
|
-
|
73
|
+
# output the overall test summary
|
74
|
+
ReportSummary.print_overall_test_summary
|
75
|
+
JunitReport.test_summary_junit
|
63
76
|
|
64
|
-
|
65
|
-
|
66
|
-
end
|
77
|
+
# Exit status code.
|
78
|
+
Process.exit($totalTestFailures.zero? ? 0 : 1)
|
67
79
|
end
|
data/lib/parser/parser.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
module Parser
|
9
9
|
require_relative '../taf_config.rb'
|
10
10
|
# variables:
|
11
|
-
@
|
11
|
+
@xlsx_file_name_type = '.xlsx'
|
12
12
|
|
13
13
|
def self.test_files
|
14
14
|
@test_files ||= Dir.glob("#{$testcasesFolder}/*.xlsx").reject do |file|
|
@@ -17,20 +17,20 @@ module Parser
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# readTestData
|
20
|
-
def self.read_test_data(
|
20
|
+
def self.read_test_data(test_file_name)
|
21
21
|
# get the file type
|
22
|
-
|
23
|
-
if
|
24
|
-
MyLog.log.info "Processing test file: #{
|
22
|
+
file_type = File.extname(test_file_name)
|
23
|
+
if file_type.casecmp(@xlsx_file_name_type).zero?
|
24
|
+
MyLog.log.info "Processing test file: #{test_file_name}"
|
25
25
|
MyLog.log.info "Browser Type: #{$browserType}"
|
26
|
-
$xlsxDoc = RubyXL::Parser.parse(
|
26
|
+
$xlsxDoc = RubyXL::Parser.parse(test_file_name)
|
27
27
|
XlsxParser.parse_xlxs_test_header_data
|
28
28
|
return 'XLSX'
|
29
29
|
else
|
30
30
|
# if unable to read the test file list then construct a custom error
|
31
31
|
# message and raise an exception.
|
32
|
-
error_to_display = "Test File Name: '#{
|
33
|
-
|
32
|
+
error_to_display = "Test File Name: '#{test_file_name}' " \
|
33
|
+
'type not recognised (must be .xslx)'
|
34
34
|
raise IOError, error_to_display
|
35
35
|
end
|
36
36
|
|
@@ -41,7 +41,7 @@ module Parser
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# parseTestStepData
|
44
|
-
def self.parse_test_step_data(
|
45
|
-
XlsxParser.parse_test_step_data(
|
44
|
+
def self.parse_test_step_data(test_file_type)
|
45
|
+
XlsxParser.parse_test_step_data(test_file_type)
|
46
46
|
end
|
47
47
|
end
|
data/lib/report/junit_report.rb
CHANGED
@@ -39,10 +39,10 @@ module JunitReport
|
|
39
39
|
xml.testsuites(testsuite_attrs) do |testsuites|
|
40
40
|
@testStepReportSummary2.each do |testStepReportSummary2|
|
41
41
|
testsuites.testsuite(testStepReportSummary2) do |testsuite|
|
42
|
-
$testStep_xml[testStepReportSummary2['name']].each do |
|
42
|
+
$testStep_xml[testStepReportSummary2['name']].each do |test_step_index, testStep_xml|
|
43
43
|
testsuite.testcase(testStep_xml) do |testcase|
|
44
|
-
failure = $failtestStep_xml&.[](testStepReportSummary2['name'])&.[](
|
45
|
-
skipped = $skiptestStep_xml&.[](testStepReportSummary2['name'])&.[](
|
44
|
+
failure = $failtestStep_xml&.[](testStepReportSummary2['name'])&.[](test_step_index)
|
45
|
+
skipped = $skiptestStep_xml&.[](testStepReportSummary2['name'])&.[](test_step_index)
|
46
46
|
testcase.failure(failure) if failure
|
47
47
|
testcase.skipped(skipped) if skipped
|
48
48
|
end
|
data/lib/report/report.rb
CHANGED
@@ -9,53 +9,47 @@
|
|
9
9
|
# report.rb - methods for outputting console.
|
10
10
|
module Report
|
11
11
|
require_relative '../taf_config.rb'
|
12
|
-
# setup the test results output file
|
13
|
-
# results file variable
|
14
|
-
def self.results
|
15
|
-
results_file = @results_file
|
16
|
-
end
|
17
12
|
|
18
13
|
# get the current time in the format Day - Month - Date - Time (HH:MM:SS)
|
19
14
|
def self.current_time
|
20
|
-
|
21
|
-
f_time = time.strftime('%a %b %d %H:%M:%S %Z')
|
22
|
-
f_time
|
15
|
+
Time.new.strftime('%a %b %d %H:%M:%S %Z')
|
23
16
|
end
|
24
17
|
|
25
18
|
# print the test Step info to the test results file
|
26
|
-
def self.print_test_step_header(test_file_name,
|
27
|
-
MyLog.log.info "Test start time: #{
|
28
|
-
MyLog.log.info "Test step: #{$
|
19
|
+
def self.print_test_step_header(test_file_name, test_step_index)
|
20
|
+
MyLog.log.info "Test start time: #{current_time}"
|
21
|
+
MyLog.log.info "Test step: #{$test_step} : #{$test_step_des}"
|
29
22
|
|
30
23
|
step = {
|
31
|
-
'id' => $
|
32
|
-
'classname' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $
|
33
|
-
'name' => $
|
24
|
+
'id' => $test_step,
|
25
|
+
'classname' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $test_step.to_s + ' ' + $test_step_des.to_s,
|
26
|
+
'name' => $test_step_des,
|
34
27
|
'file' => test_file_name
|
35
28
|
}
|
36
29
|
# output to console to show test step
|
37
30
|
# puts step
|
38
31
|
|
39
32
|
return unless test_file_name
|
33
|
+
|
40
34
|
$testStep_xml ||= {}
|
41
35
|
$testStep_xml[test_file_name] ||= {}
|
42
|
-
$testStep_xml[test_file_name][
|
36
|
+
$testStep_xml[test_file_name][test_step_index] = step
|
43
37
|
end
|
44
38
|
|
45
39
|
# print the Pass / Fail status of a test to the test results file
|
46
|
-
def self.test_pass_fail(
|
47
|
-
if
|
40
|
+
def self.test_pass_fail(pass_fail, test_file_name, test_step_index)
|
41
|
+
if pass_fail == true
|
48
42
|
$previousTestFail = $currentTestFail
|
49
43
|
$currentTestFail = false
|
50
44
|
$testStepPasses += 1
|
51
|
-
MyLog.log.info "Test #{$
|
52
|
-
elsif
|
45
|
+
MyLog.log.info "Test #{$test_step} has Passed ".green
|
46
|
+
elsif pass_fail == false
|
53
47
|
$previousTestFail = $currentTestFail
|
54
48
|
$currentTestFail = true
|
55
49
|
$testStepFailures += 1
|
56
|
-
MyLog.log.info "Test #{$
|
50
|
+
MyLog.log.info "Test #{$test_step} has FAILED ".red
|
57
51
|
failstep = {
|
58
|
-
'message' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $
|
52
|
+
'message' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $test_step.to_s + ' Test has FAILED - Check logs',
|
59
53
|
'type' => 'FAILURE',
|
60
54
|
'file' => test_file_name
|
61
55
|
}
|
@@ -63,15 +57,16 @@ module Report
|
|
63
57
|
# puts failstep
|
64
58
|
|
65
59
|
return unless test_file_name
|
60
|
+
|
66
61
|
$failtestStep_xml ||= {}
|
67
62
|
$failtestStep_xml[test_file_name] ||= []
|
68
|
-
$failtestStep_xml[test_file_name][
|
63
|
+
$failtestStep_xml[test_file_name][test_step_index] = failstep
|
69
64
|
else
|
70
65
|
$currentTestFail = false
|
71
66
|
$testStepNotrun += 1
|
72
|
-
MyLog.log.info "Test #{$
|
67
|
+
MyLog.log.info "Test #{$test_step} no checks performed ".blue
|
73
68
|
skipstep = {
|
74
|
-
'message' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $
|
69
|
+
'message' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $test_step.to_s + ' No checks performed - Check logs',
|
75
70
|
'type' => 'SKIPPED',
|
76
71
|
'file' => test_file_name
|
77
72
|
}
|
@@ -79,30 +74,33 @@ module Report
|
|
79
74
|
# puts skipstep
|
80
75
|
|
81
76
|
return unless test_file_name
|
77
|
+
|
82
78
|
$skiptestStep_xml ||= {}
|
83
79
|
$skiptestStep_xml[test_file_name] ||= []
|
84
|
-
$skiptestStep_xml[test_file_name][
|
85
|
-
|
86
|
-
MyLog.log.info "Test end time: #{
|
80
|
+
$skiptestStep_xml[test_file_name][test_step_index] = skipstep
|
81
|
+
end
|
82
|
+
MyLog.log.info "Test end time: #{current_time}"
|
87
83
|
end
|
88
84
|
|
89
85
|
# check if the test failure threshold has been reached for total failures or consecutive failures.
|
90
86
|
# If a certain number of consecutive tests fail then throw an exception
|
91
|
-
def self.check_failure_threshold(test_file_name,
|
92
|
-
|
87
|
+
def self.check_failure_threshold(test_file_name, _test_step_index)
|
88
|
+
consecutive_fail_threshold = 5
|
93
89
|
if $previousTestFail && $currentTestFail
|
94
|
-
@
|
90
|
+
@consecutive_test_fail += 1
|
95
91
|
else
|
96
|
-
@
|
92
|
+
@consecutive_test_fail = 0
|
97
93
|
end
|
98
94
|
|
99
|
-
if @
|
100
|
-
# write info to stdout
|
101
|
-
MyLog.log.warn "Terminating the current test case: #{test_file_name} as the test failure threshold (#{consecutiveFailThreshold}) has been reached."
|
102
|
-
MyLog.log.warn '...continuing with the next test case (if there is one)'
|
95
|
+
return if @consecutive_test_fail < consecutive_fail_threshold
|
103
96
|
|
104
|
-
|
105
|
-
|
106
|
-
|
97
|
+
# write info to stdout
|
98
|
+
MyLog.log.warn "Terminating the current test case: #{test_file_name} as" \
|
99
|
+
" the test failure threshold (#{consecutive_fail_threshold}) has been " \
|
100
|
+
' reached.'
|
101
|
+
MyLog.log.warn '...continuing with the next test case (if there is one)'
|
102
|
+
|
103
|
+
raise FailureThresholdExceeded,
|
104
|
+
"#{consecutive_fail_threshold} Test Steps Failed."
|
107
105
|
end
|
108
106
|
end
|
@@ -30,7 +30,7 @@ module ReportSummary
|
|
30
30
|
# output to the console
|
31
31
|
|
32
32
|
MyLog.log.info "Finished processing all test files - executed via test suite: #{$testcasesFolder}"
|
33
|
-
MyLog.log.info "Overall Test Summary:"
|
33
|
+
MyLog.log.info "Overall Test Summary: \n"
|
34
34
|
@testStepReportSummary.each do |testStepReportSummary|
|
35
35
|
testStepReportSummary.each_line do |line|
|
36
36
|
MyLog.log.info(line.strip)
|
data/lib/taf_config.rb
CHANGED
data/lib/utils/browser.rb
CHANGED
@@ -30,7 +30,7 @@ module Browser
|
|
30
30
|
rescue BrowserFailedOpen => error
|
31
31
|
# construct the error message from custom text and the actual system error
|
32
32
|
# message (converted to a string)
|
33
|
-
error_text =
|
33
|
+
error_text = 'Unable to open'\
|
34
34
|
"the requested browser: #{lc_browser_type} " + error.to_s
|
35
35
|
raise error_text
|
36
36
|
end
|
@@ -68,7 +68,7 @@ module Browser
|
|
68
68
|
options = Selenium::WebDriver::Firefox::Options.new(args: ['-headless'])
|
69
69
|
caps['acceptInsecureCerts'] = true
|
70
70
|
driver = Selenium::WebDriver.for(:firefox, options: options,
|
71
|
-
|
71
|
+
desired_capabilities: caps)
|
72
72
|
@browser = Watir::Browser.new(driver)
|
73
73
|
# makes the browser full screen.
|
74
74
|
@browser.driver.manage.window.resize_to(1920, 1200)
|
@@ -101,42 +101,40 @@ module Browser
|
|
101
101
|
|
102
102
|
# define browser value
|
103
103
|
def self.b
|
104
|
-
|
104
|
+
@browser
|
105
105
|
end
|
106
106
|
|
107
107
|
# Check browser version
|
108
108
|
def self.browser_version
|
109
|
-
|
109
|
+
@browser.driver.capabilities[:version]
|
110
110
|
rescue StandardError
|
111
|
-
|
111
|
+
'No Browser version'
|
112
112
|
end
|
113
113
|
|
114
114
|
# create screenshot filename and save the screenshot if the test has failed or
|
115
115
|
# if explictly required
|
116
116
|
def self.check_save_screenshot(screen_shot)
|
117
|
-
if
|
117
|
+
if $currentTestFail || screen_shot
|
118
118
|
time = Time.now.strftime('%H%M')
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
scFileName = full_sc_dirname + "/Test_step-#{$testStep}_#{time}.png"
|
127
|
-
end
|
119
|
+
sc_dir = CreateDirectories.construct_testspecdirs
|
120
|
+
|
121
|
+
sc_file_name = if $currentTestFail
|
122
|
+
"#{sc_dir}/Test_step-#{$test_step}_Failed_#{time}.png"
|
123
|
+
else
|
124
|
+
"#{sc_dir}/Test_step-#{$test_step}_#{time}.png"
|
125
|
+
end
|
128
126
|
|
129
127
|
# Screenshot capture for websites
|
130
|
-
Browser.b.screenshot.save
|
131
|
-
MyLog.log.info("Screenshot saved to: #{
|
132
|
-
|
133
|
-
|
134
|
-
|
128
|
+
Browser.b.screenshot.save sc_file_name
|
129
|
+
MyLog.log.info("Screenshot saved to: #{sc_file_name} \n")
|
130
|
+
else
|
131
|
+
MyLog.log.debug "No screenshot requested \n"
|
132
|
+
end
|
135
133
|
|
136
134
|
# if any issues with saving the screenshot then log a warning
|
137
|
-
|
135
|
+
rescue StandardError => error
|
138
136
|
# construct the error message from custom text and the actual system
|
139
137
|
# error message (converted to a string).
|
140
|
-
MyLog.log.warn("Error saving the screenshot: #{
|
138
|
+
MyLog.log.warn("Error saving the screenshot: #{sc_file_name} #{error}")
|
141
139
|
end
|
142
140
|
end
|
@@ -41,7 +41,6 @@ module CreateDirectories
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.construct_testspecdirs
|
44
|
-
|
45
44
|
time = Time.new
|
46
45
|
f_date = time.strftime('%d-%b-%Y')
|
47
46
|
f_time = time.strftime('%H_%M_%S')
|
@@ -60,10 +59,9 @@ module CreateDirectories
|
|
60
59
|
|
61
60
|
# create absolute paths to the screenshots and test suite summary directories
|
62
61
|
abs_path_screenshot_dir = File.absolute_path(screenshot_dir)
|
63
|
-
abs_path_run_no_dir = File.absolute_path($runNoDir)
|
64
62
|
|
65
63
|
# if any issues then set error message and re-raise the exception
|
66
|
-
rescue
|
64
|
+
rescue StandardError => error
|
67
65
|
# construct the error message from custom text and the actual system error message (converted to a string)
|
68
66
|
error_to_display = 'Error creating the test directory structure or opening the test results file : ' + error.to_s
|
69
67
|
raise error_to_display
|
data/lib/utils/test_engine.rb
CHANGED
@@ -17,22 +17,22 @@ module TestEngine
|
|
17
17
|
|
18
18
|
# loop through all the available test files to execute the tests
|
19
19
|
Parser.test_files.each_with_index do |test_file_name, test_file_index|
|
20
|
-
begin
|
20
|
+
begin
|
21
21
|
# read in the test data
|
22
|
-
|
22
|
+
test_file_type = Parser.read_test_data(test_file_name)
|
23
23
|
# if unable to read the test data, show the error and move onto the
|
24
24
|
# next file (if there is one)
|
25
25
|
rescue StandardError => error
|
26
26
|
MyLog.log.warn 'Terminating the current test case: ' \
|
27
27
|
"#{test_file_name} #{error}"
|
28
28
|
MyLog.log.info '...continuing with the next test case (if there is one)'
|
29
|
-
end
|
29
|
+
end
|
30
30
|
|
31
31
|
# create project folders - these only need creating once per test suite
|
32
32
|
CreateDirectories.construct_projectdirs
|
33
33
|
|
34
34
|
# loop through the test file
|
35
|
-
MyLog.log.info 'Not a valid XLSX File Type' if
|
35
|
+
MyLog.log.info 'Not a valid XLSX File Type' if test_file_type != 'XLSX'
|
36
36
|
|
37
37
|
# get the test case start time
|
38
38
|
$test_case_start_time = Report.current_time
|
@@ -40,12 +40,12 @@ module TestEngine
|
|
40
40
|
$test_case_end_time = Report.current_time
|
41
41
|
|
42
42
|
begin
|
43
|
-
test_steps = Parser.parse_test_step_data(
|
43
|
+
test_steps = Parser.parse_test_step_data(test_file_type)
|
44
44
|
|
45
45
|
test_steps.each_with_index do |test_step, step_index|
|
46
|
-
$
|
47
|
-
$
|
48
|
-
screen_shot
|
46
|
+
$test_step = test_step[:testStep]
|
47
|
+
$test_step_des = test_step[:testdesc]
|
48
|
+
screen_shot = test_step[:screenShotData]
|
49
49
|
|
50
50
|
# process the test step data
|
51
51
|
TestSteps.process_test_steps(test_file_name, step_index, test_step)
|
@@ -77,5 +77,5 @@ module TestEngine
|
|
77
77
|
$testStepFailures = 0
|
78
78
|
$testStepNotrun = 0
|
79
79
|
end
|
80
|
-
end
|
80
|
+
end
|
81
81
|
end
|
data/lib/utils/test_steps.rb
CHANGED
@@ -9,30 +9,29 @@
|
|
9
9
|
# test_steps.rb - process the required test step functions
|
10
10
|
module TestSteps
|
11
11
|
require_relative '../taf_config.rb'
|
12
|
-
|
12
|
+
|
13
13
|
def self.handlers
|
14
14
|
@handlers ||= {}
|
15
15
|
end
|
16
16
|
|
17
17
|
# process the test step data by matching the test step functions and
|
18
18
|
# processing the associated data accordingly
|
19
|
-
def self.process_test_steps(test_file_name,
|
19
|
+
def self.process_test_steps(test_file_name, test_step_index, step_attributes)
|
20
20
|
# print the test step information
|
21
|
-
Report.print_test_step_header(test_file_name,
|
22
|
-
|
21
|
+
Report.print_test_step_header(test_file_name, test_step_index)
|
22
|
+
|
23
23
|
runtest = step_attributes[:skipTestCase]
|
24
24
|
step_function = step_attributes[:testFunction]
|
25
25
|
handler = handlers[step_function.to_s]
|
26
26
|
|
27
27
|
if handler.respond_to?(:perform)
|
28
28
|
func = handler.perform(step_attributes) if runtest == false
|
29
|
-
Report.test_pass_fail(func, test_file_name,
|
30
|
-
Report.check_failure_threshold(test_file_name,
|
29
|
+
Report.test_pass_fail(func, test_file_name, test_step_index)
|
30
|
+
Report.check_failure_threshold(test_file_name, test_step_index)
|
31
31
|
return true
|
32
32
|
else
|
33
33
|
MyLog.log.warn "\nUnable to match function: #{step_function}"
|
34
34
|
raise UnknownTestStep, "Unknown test step: #{step_function}"
|
35
|
-
return false
|
36
35
|
end
|
37
36
|
end
|
38
37
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Perrett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|