taf 0.2.1 → 0.2.2
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/ping_test.rb +1 -1
- data/lib/functions/handlers/switch_iframe.rb +23 -0
- data/lib/main.rb +19 -6
- data/lib/parser/xlsx_parser.rb +23 -30
- data/lib/report/junit_report.rb +22 -14
- data/lib/report/report_summary.rb +8 -6
- data/lib/taf_config.rb +3 -0
- data/lib/utils/create_directories.rb +31 -35
- data/lib/version.rb +2 -2
- metadata +3 -3
- data/lib/functions/handlers/open_portal_url.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec014d38b9b9f9dbe35fe3bc6a2c924a3434ab0eab2a9976bda8741763ee59d
|
4
|
+
data.tar.gz: bab944778a1ccf2eb1363de7751a8e2d95fb33a0ac69e2eeb80cbdfecca3c214
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2278f72d06eb0fa27a49f3038b5f22ec9ace610cfc73c41b55282f93af1a6212a8c51e110bb27346559e5152b03a7cb4f91e56206d7384917535429fbfd2270b
|
7
|
+
data.tar.gz: a01563a120ea0c2f49228c62a2a90423ef41238780425d4430704ee44969fe6c43863edc50847095fb2c6fdae18a4b21813b4a0d2e3edb6ee649487bc216e181
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
|
3
|
+
module TestSteps
|
4
|
+
module Handlers
|
5
|
+
class SwitchIframe < Base
|
6
|
+
register :switch_iframe
|
7
|
+
|
8
|
+
def perform(step_attributes)
|
9
|
+
frame = step_attributes[:testvalue]
|
10
|
+
locate = step_attributes[:locate]
|
11
|
+
|
12
|
+
Browser.b.iframe(:"#{locate}" => frame).exists?
|
13
|
+
# Browser.b.wait_until { iframe(:"#{locate}" => frame).exists? }
|
14
|
+
# Browser.b.switch_to(:"#{locate}" => iframe)
|
15
|
+
MyLog.log.info("iframe found: #{frame} is correct")
|
16
|
+
true
|
17
|
+
rescue StandardError
|
18
|
+
MyLog.log.warn("iframe not found: #{frame}")
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/main.rb
CHANGED
@@ -20,16 +20,27 @@ module Main
|
|
20
20
|
# Whenever we see -b, -t or --browser, or --tests with an
|
21
21
|
# argument, save the argument.
|
22
22
|
parser.banner = 'Usage: taf [options]'
|
23
|
-
parser.on(
|
23
|
+
parser.on(
|
24
|
+
'-h',
|
25
|
+
'--help',
|
26
|
+
"2 arguments are required: {Browser} {Testcase folder}'"
|
27
|
+
) do
|
24
28
|
puts parser
|
25
29
|
Process.exit
|
26
30
|
end
|
27
31
|
|
28
|
-
parser.on(
|
32
|
+
parser.on(
|
33
|
+
'-b',
|
34
|
+
'--browser browser',
|
35
|
+
'Supported Browsers: chrome,' \
|
36
|
+
' chrome-headless, firefox, firefox-headless.'
|
37
|
+
) do |b|
|
29
38
|
options[:browser] = b
|
30
39
|
$browserType = options[:browser]
|
31
|
-
unless ['chrome', 'chrome-headless', 'firefox', 'firefox-headless']
|
32
|
-
|
40
|
+
unless ['chrome', 'chrome-headless', 'firefox', 'firefox-headless']
|
41
|
+
.include?($browserType)
|
42
|
+
MyLog.log.warn 'A valid Browser has not been supplied as a' \
|
43
|
+
' command-line parameter as expected'
|
33
44
|
Process.exit
|
34
45
|
end
|
35
46
|
end
|
@@ -38,10 +49,12 @@ module Main
|
|
38
49
|
options[:testfolder] = t
|
39
50
|
$testcasesFolder = options[:testfolder]
|
40
51
|
if Parser.test_files.size.positive?
|
41
|
-
MyLog.log.info "There are: #{Parser.test_files.size}
|
52
|
+
MyLog.log.info "There are: #{Parser.test_files.size}" \
|
53
|
+
' test files to process'
|
42
54
|
MyLog.log.info "List of Tests files: #{Parser.test_files} \n"
|
43
55
|
else
|
44
|
-
MyLog.log.warn 'A valid Test case location has not been supplied
|
56
|
+
MyLog.log.warn 'A valid Test case location has not been supplied' \
|
57
|
+
' as a command-line parameter as expected'
|
45
58
|
Process.exit
|
46
59
|
end
|
47
60
|
end
|
data/lib/parser/xlsx_parser.rb
CHANGED
@@ -10,23 +10,21 @@ module XlsxParser
|
|
10
10
|
|
11
11
|
def self.parse_xlxs_test_header_data
|
12
12
|
# get the number of test steps in the file
|
13
|
-
$numberOfTestSteps =
|
13
|
+
$numberOfTestSteps = $xlsxDoc[0].sheet_data.size - 4
|
14
14
|
worksheet = $xlsxDoc[0]
|
15
15
|
# get the remaining test data
|
16
|
-
$testId
|
16
|
+
$testId = worksheet.sheet_data[1][0].value
|
17
17
|
$projectId = worksheet.sheet_data[1][1].value
|
18
18
|
$testDes = worksheet.sheet_data[1][2].value
|
19
19
|
MyLog.log.info "Number of test steps: #{$numberOfTestSteps}"
|
20
20
|
MyLog.log.info "Test Description: #{$testDes}"
|
21
21
|
MyLog.log.info "TestID: #{$testId} \n"
|
22
|
-
|
23
22
|
end
|
24
23
|
|
25
24
|
# parseTestStepData
|
26
|
-
def self.parse_test_step_data(
|
27
|
-
begin
|
25
|
+
def self.parse_test_step_data(_test_file_type)
|
28
26
|
worksheet = $xlsxDoc[0]
|
29
|
-
worksheet[4..$numberOfTestSteps+4].map do |row|
|
27
|
+
worksheet[4..$numberOfTestSteps + 4].map do |row|
|
30
28
|
test = {
|
31
29
|
testStep: row[0].value,
|
32
30
|
testdesc: row[1].value,
|
@@ -36,7 +34,7 @@ module XlsxParser
|
|
36
34
|
testvalue2: row[5].value,
|
37
35
|
locate2: row[6].value,
|
38
36
|
screenShotData: row[7].value,
|
39
|
-
skipTestCase: row[8].value
|
37
|
+
skipTestCase: row[8].value
|
40
38
|
}
|
41
39
|
|
42
40
|
# convert test step, screenshot and skip test case functions to lowercase.
|
@@ -44,36 +42,31 @@ module XlsxParser
|
|
44
42
|
|
45
43
|
# get screenshot request, check for a null value and default to 'N'
|
46
44
|
|
47
|
-
if
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
test[:screenShotData] = if test[:screenShotData] == 'Y'
|
46
|
+
true
|
47
|
+
elsif test[:screenShotData] == 'N'
|
48
|
+
false
|
49
|
+
else
|
50
|
+
false
|
51
|
+
end
|
54
52
|
|
55
|
-
if
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
test[:skipTestCase] = if test[:skipTestCase] == 'Y'
|
54
|
+
true
|
55
|
+
elsif test[:skipTestCase] == 'N'
|
56
|
+
false
|
57
|
+
else
|
58
|
+
false
|
59
|
+
end
|
62
60
|
|
63
61
|
# if there is an element locator then use it, otherwise use an ID
|
64
|
-
if
|
65
|
-
test[:locate] = 'id'
|
66
|
-
end
|
62
|
+
test[:locate] = 'id' if test[:locate].to_s == ''
|
67
63
|
|
68
|
-
if
|
69
|
-
test[:locate2] = 'id'
|
70
|
-
end
|
64
|
+
test[:locate2] = 'id' if test[:locate2].to_s == ''
|
71
65
|
|
72
66
|
test
|
73
|
-
|
67
|
+
# if an error reading the test step data then re-raise the exception
|
74
68
|
rescue StandardError => error
|
75
|
-
raise
|
69
|
+
raise error
|
76
70
|
end
|
77
71
|
end
|
78
72
|
end
|
79
|
-
end
|
data/lib/report/junit_report.rb
CHANGED
@@ -10,17 +10,19 @@
|
|
10
10
|
module JunitReport
|
11
11
|
require_relative '../taf_config.rb'
|
12
12
|
# holds printable test report summary for all the executed tests
|
13
|
-
@
|
13
|
+
@test_step_report_summary2 = []
|
14
14
|
# construct the test suite header for junit
|
15
15
|
def self.test_step_summary_xml(test_file_name, test_file_name_index)
|
16
|
-
@
|
16
|
+
@test_step_report_summary2[test_file_name_index] = {
|
17
17
|
'classname' => test_file_name,
|
18
18
|
'name' => test_file_name,
|
19
19
|
'assertions' => $numberOfTestSteps,
|
20
20
|
'failures' => $testStepFailures,
|
21
21
|
'tests' => $testStepPasses,
|
22
22
|
'skipped' => $testStepNotrun,
|
23
|
-
'time' => TimeDifference.between(
|
23
|
+
'time' => TimeDifference.between(
|
24
|
+
$test_case_end_time, $test_case_start_time
|
25
|
+
).in_seconds
|
24
26
|
}
|
25
27
|
end
|
26
28
|
|
@@ -34,15 +36,19 @@ module JunitReport
|
|
34
36
|
'failures' => $totalTestFailures.to_s,
|
35
37
|
'timestamp' => $test_start_time.to_s,
|
36
38
|
'skipped' => $totalTestNotrun.to_s,
|
37
|
-
'time' => TimeDifference.between($test_end_time, $test_start_time)
|
39
|
+
'time' => TimeDifference.between($test_end_time, $test_start_time)
|
40
|
+
.in_seconds
|
38
41
|
}
|
39
42
|
xml.testsuites(testsuite_attrs) do |testsuites|
|
40
|
-
@
|
41
|
-
testsuites.testsuite(
|
42
|
-
$testStep_xml[
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
@test_step_report_summary2.each do |test_step_report_summary2|
|
44
|
+
testsuites.testsuite(test_step_report_summary2) do |testsuite|
|
45
|
+
$testStep_xml[test_step_report_summary2['name']]
|
46
|
+
.each do |test_step_index, test_step_xml|
|
47
|
+
testsuite.testcase(test_step_xml) do |testcase|
|
48
|
+
failure = $failtestStep_xml
|
49
|
+
&.[](test_step_report_summary2['name'])&.[](test_step_index)
|
50
|
+
skipped = $skiptestStep_xml
|
51
|
+
&.[](test_step_report_summary2['name'])&.[](test_step_index)
|
46
52
|
testcase.failure(failure) if failure
|
47
53
|
testcase.skipped(skipped) if skipped
|
48
54
|
end
|
@@ -57,12 +63,14 @@ module JunitReport
|
|
57
63
|
|
58
64
|
# open the suite summary file for writing if not already open
|
59
65
|
if !File.exist?($TestSuiteSummaryXML) || $TestSuiteSummaryXML.closed?
|
60
|
-
|
61
|
-
|
62
|
-
|
66
|
+
testSuiteSummaryFile_xml = File.open($TestSuiteSummaryXML, 'w+')
|
67
|
+
testSuiteSummaryFile_xml.write builder.to_xml
|
68
|
+
else
|
69
|
+
MyLog.log.warn 'test suite summary file xml name:' \
|
70
|
+
" #{$TestSuiteSummaryXML} is already open"
|
63
71
|
end
|
64
72
|
|
65
73
|
# if the file is open then close it
|
66
|
-
|
74
|
+
testSuiteSummaryFile_xml.close unless testSuiteSummaryFile_xml.closed?
|
67
75
|
end
|
68
76
|
end
|
@@ -10,10 +10,10 @@
|
|
10
10
|
module ReportSummary
|
11
11
|
require_relative '../taf_config.rb'
|
12
12
|
# holds printable test report summary for all the executed tests
|
13
|
-
@
|
13
|
+
@test_step_report_summary = []
|
14
14
|
# output the test results summary for the current test case
|
15
15
|
def self.test_step_summary(test_file_name, test_file_name_index)
|
16
|
-
@
|
16
|
+
@test_step_report_summary[test_file_name_index] = <<~TEXT
|
17
17
|
Test file executed: #{test_file_name}
|
18
18
|
Browser type used: #{$browserType}
|
19
19
|
Browser version: #{Browser.browser_version}
|
@@ -29,17 +29,19 @@ module ReportSummary
|
|
29
29
|
def self.print_overall_test_summary
|
30
30
|
# output to the console
|
31
31
|
|
32
|
-
MyLog.log.info
|
32
|
+
MyLog.log.info 'Finished processing all test files -' \
|
33
|
+
"executed via test suite: #{$testcasesFolder}"
|
33
34
|
MyLog.log.info "Overall Test Summary: \n"
|
34
|
-
@
|
35
|
-
|
35
|
+
@test_step_report_summary.each do |test_step_report_summary|
|
36
|
+
test_step_report_summary.each_line do |line|
|
36
37
|
MyLog.log.info(line.strip)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
MyLog.log.info "Total Tests started at: #{$test_start_time}"
|
41
42
|
MyLog.log.info "Total Tests finished at: #{$test_end_time}"
|
42
|
-
MyLog.log.info
|
43
|
+
MyLog.log.info 'Total Tests duration: ' \
|
44
|
+
+ TimeDifference.between($test_end_time, $test_start_time).humanize
|
43
45
|
MyLog.log.info "Total Tests Passed: #{$totalTestPasses}".green
|
44
46
|
MyLog.log.info "Total Tests Failed: #{$totalTestFailures}".red
|
45
47
|
MyLog.log.info "Total Tests Skipped: #{$totalTestNotrun}".blue
|
data/lib/taf_config.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
2
|
# Created on 20 Sept 2017
|
4
3
|
# @author: Andy Perrett
|
5
4
|
#
|
@@ -16,54 +15,51 @@ module CreateDirectories
|
|
16
15
|
#
|
17
16
|
# ----> Project directory (working directory)
|
18
17
|
#
|
19
|
-
# ------->directory named after the test run
|
18
|
+
# ------->directory named after the test run ID UUID
|
20
19
|
#
|
21
|
-
# ---------->directory named after test_id
|
20
|
+
# ---------->directory named after test_id
|
22
21
|
#
|
23
22
|
# ------------->directory named 'Screenshots'
|
24
23
|
|
25
|
-
def self.
|
26
|
-
|
27
|
-
|
28
|
-
Dir.mkdir(result_home) unless File.directory? result_home
|
24
|
+
def self.time_now
|
25
|
+
Time.new.strftime('%d-%b-%Y_%H_%M')
|
26
|
+
end
|
29
27
|
|
30
|
-
|
28
|
+
def self.construct_projectdirs
|
29
|
+
# create top-level directory if it doesn't already exist:
|
30
|
+
# Results/Project_id
|
31
31
|
project_id = $projectId.delete(' ')
|
32
|
-
$project_iddir =
|
33
|
-
|
32
|
+
$project_iddir = File.join('Results', project_id
|
33
|
+
)
|
34
34
|
|
35
|
-
|
36
|
-
time = Time.new
|
37
|
-
f_date = time.strftime('%d-%b-%Y')
|
38
|
-
f_time = time.strftime('%H_%M_%S')
|
35
|
+
FileUtils.mkdir_p($project_iddir)
|
39
36
|
|
40
|
-
|
37
|
+
# Generate UUID
|
38
|
+
$run_uuid = SecureRandom.uuid
|
39
|
+
|
40
|
+
# the test suite summary is a XML report generated will be called
|
41
|
+
# 'suite_summary.xml'
|
42
|
+
$TestSuiteSummaryXML = "Results/#{project_id}/#{time_now}" \
|
43
|
+
'_test_result.xml'
|
41
44
|
end
|
42
45
|
|
43
46
|
def self.construct_testspecdirs
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
# create directories for each test spec
|
51
|
-
# create a sub-directory named from the 'testId' (with any spaces taken out)
|
52
|
-
# if it doesn't already exist plus the browser type
|
53
|
-
testid_dir = $runNoDir + '/' + $testId.delete(' ') + '_' + $browserType.capitalize
|
54
|
-
Dir.mkdir(testid_dir) unless File.directory? testid_dir
|
47
|
+
# create directories for each test spec for screenshots:
|
48
|
+
# Results/Project_id/Run_ID_UUID/Test_ID/Screenshots
|
49
|
+
screenshot_dir = File.join(
|
50
|
+
$project_iddir, "Run_ID_#{$run_uuid}", "#{$testId.delete(' ')}",
|
51
|
+
'Screenshots'
|
52
|
+
)
|
55
53
|
|
56
|
-
# create a screenshot directory under the 'testId' directory - it will always need creating
|
57
|
-
screenshot_dir = testid_dir + '/' + 'Screenshots' + '/'
|
58
|
-
Dir.mkdir(screenshot_dir)
|
59
|
-
|
60
|
-
# create absolute paths to the screenshots and test suite summary directories
|
61
54
|
abs_path_screenshot_dir = File.absolute_path(screenshot_dir)
|
62
|
-
|
63
|
-
|
55
|
+
# abs_path_run_no_dir = File.absolute_path(runNoDir)
|
56
|
+
FileUtils.mkdir_p(abs_path_screenshot_dir)
|
57
|
+
# if any issues then set error message and re-raise the exception
|
64
58
|
rescue StandardError => error
|
65
|
-
# construct the error message from custom text and the actual system error
|
66
|
-
|
59
|
+
# construct the error message from custom text and the actual system error
|
60
|
+
# message (converted to a string)
|
61
|
+
error_to_display = 'Error creating the test directory structure or' \
|
62
|
+
' opening the test results file : ' + error.to_s
|
67
63
|
raise error_to_display
|
68
64
|
else
|
69
65
|
# if no exception then return the screenshot file directory path
|
data/lib/version.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
module Taf
|
4
4
|
# This module holds the TAF version information.
|
5
5
|
module Version
|
6
|
-
STRING = '0.2.
|
6
|
+
STRING = '0.2.2'
|
7
7
|
|
8
8
|
MSG = '%<version>s (using Parser %<parser_version>s, running on ' \
|
9
|
-
'%<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'
|
9
|
+
'%<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'
|
10
10
|
|
11
11
|
def self.version(debug = false)
|
12
12
|
if debug
|
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.2
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -192,13 +192,13 @@ files:
|
|
192
192
|
- lib/functions/handlers/insert_value_config.rb
|
193
193
|
- lib/functions/handlers/ipause.rb
|
194
194
|
- lib/functions/handlers/list_all_dropdowns_values.rb
|
195
|
-
- lib/functions/handlers/open_portal_url.rb
|
196
195
|
- lib/functions/handlers/open_url.rb
|
197
196
|
- lib/functions/handlers/ping_test.rb
|
198
197
|
- lib/functions/handlers/portal_login.rb
|
199
198
|
- lib/functions/handlers/radio_button.rb
|
200
199
|
- lib/functions/handlers/select_dropdown.rb
|
201
200
|
- lib/functions/handlers/send_special_keys.rb
|
201
|
+
- lib/functions/handlers/switch_iframe.rb
|
202
202
|
- lib/functions/handlers/write_box_data.rb
|
203
203
|
- lib/functions/handlers/write_to_editor.rb
|
204
204
|
- lib/main.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative 'base_handler'
|
2
|
-
|
3
|
-
module TestSteps
|
4
|
-
module Handlers
|
5
|
-
class OpenPortalUrl < Base
|
6
|
-
register :open_portal_url
|
7
|
-
|
8
|
-
def perform(step_attributes)
|
9
|
-
value = step_attributes[:testvalue]
|
10
|
-
url = ENV[value.to_s]
|
11
|
-
Browser.open_browser
|
12
|
-
Browser.b.goto(url)
|
13
|
-
url_nme = Browser.b.url
|
14
|
-
if url_nme == url
|
15
|
-
MyLog.log.info("opened URL: #{url}")
|
16
|
-
return true
|
17
|
-
else
|
18
|
-
MyLog.log.warn("URL not open: #{url} - opened #{url_nme} instead")
|
19
|
-
return false
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|