taf 0.1.1
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/bin/taf +4 -0
- data/lib/functions/handlers.rb +4 -0
- data/lib/functions/handlers/base_handler.rb +89 -0
- data/lib/functions/handlers/browser_back.rb +19 -0
- data/lib/functions/handlers/browser_forward.rb +19 -0
- data/lib/functions/handlers/browser_quit.rb +19 -0
- data/lib/functions/handlers/browser_refresh.rb +19 -0
- data/lib/functions/handlers/capture_alert.rb +20 -0
- data/lib/functions/handlers/check_box.rb +22 -0
- data/lib/functions/handlers/check_boxdata.rb +40 -0
- data/lib/functions/handlers/check_browser_title.rb +23 -0
- data/lib/functions/handlers/check_logs.rb +24 -0
- data/lib/functions/handlers/check_screendata.rb +23 -0
- data/lib/functions/handlers/check_url.rb +22 -0
- data/lib/functions/handlers/click_button.rb +53 -0
- data/lib/functions/handlers/execute_system_command.rb +23 -0
- data/lib/functions/handlers/handle_browser_window.rb +23 -0
- data/lib/functions/handlers/insert_value_config.rb +28 -0
- data/lib/functions/handlers/ipause.rb +21 -0
- data/lib/functions/handlers/list_all_dropdowns_values.rb +24 -0
- data/lib/functions/handlers/login.rb +25 -0
- data/lib/functions/handlers/open_portal_url.rb +25 -0
- data/lib/functions/handlers/open_url.rb +26 -0
- data/lib/functions/handlers/ping_test.rb +28 -0
- data/lib/functions/handlers/radio_button.rb +25 -0
- data/lib/functions/handlers/select_dropdown.rb +28 -0
- data/lib/functions/handlers/send_special_keys.rb +22 -0
- data/lib/functions/handlers/write_box_data.rb +40 -0
- data/lib/functions/handlers/write_to_editor.rb +27 -0
- data/lib/main.rb +74 -0
- data/lib/parser/parser.rb +87 -0
- data/lib/parser/xlsx_parser.rb +126 -0
- data/lib/report/junit_report.rb +68 -0
- data/lib/report/report.rb +155 -0
- data/lib/report/report_summary.rb +78 -0
- data/lib/taf_config.rb +37 -0
- data/lib/utils/browser.rb +140 -0
- data/lib/utils/create_directories.rb +94 -0
- data/lib/utils/exceptions.rb +7 -0
- data/lib/utils/test_engine.rb +164 -0
- data/lib/utils/test_steps.rb +39 -0
- data/lib/utils/zap.rb +131 -0
- data/lib/version.rb +21 -0
- metadata +301 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a4391d1172765039ec0976ef78b1f36203038b4119c3f0071d787e4e03e68496
|
4
|
+
data.tar.gz: 9d2562c28ade922ff855c2ba238d2597823e696730e24ff758d0a46c48927ff0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '0856c37e75feea7d1914bed383730f9cb92e5185a2236fb0695b2fe2c4d45c7f27906b085564e390ce7d53189baf0252237b74a3cfa027741116b623b2e9042a'
|
7
|
+
data.tar.gz: '04758ad5198d8dd495c50c6fcf9c071e3014afc1da5595f5bf0b20eee9a31a8f8e7de1b1f6e9fb00c66c7114aa40925e49f52f1852b9ab8ebdfc2f7583fd76ef'
|
data/bin/taf
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require_relative '../../taf_config.rb'
|
2
|
+
module TestSteps
|
3
|
+
module Handlers
|
4
|
+
class Base
|
5
|
+
def self.register(name)
|
6
|
+
TestSteps.handlers[name.to_s] = self
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.perform(*args)
|
10
|
+
new.perform(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def open_url_process(url)
|
14
|
+
Browser.open_browser
|
15
|
+
Browser.b.goto(url)
|
16
|
+
end
|
17
|
+
|
18
|
+
def login_process(b_title, user_elm, pass_elm, user, pass)
|
19
|
+
if Browser.b.title.eql?(b_title)
|
20
|
+
Browser.b.text_field(id: user_elm).wait_until_present.set user
|
21
|
+
Browser.b.text_field(id: pass_elm).wait_until_present.set pass
|
22
|
+
login_button
|
23
|
+
sleep 3
|
24
|
+
else
|
25
|
+
Report.results.puts("User: #{user} has failed to log in.")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def login_button
|
30
|
+
if Browser.b.button(value: 'Sign in').exist?
|
31
|
+
Browser.b.button(value: 'Sign in').wait_until_present.click
|
32
|
+
elsif Browser.b.button(value: 'Log in').exist?
|
33
|
+
Browser.b.button(value: 'Log in').wait_until_present.click
|
34
|
+
else
|
35
|
+
Report.results.puts("User: #{user} has failed to log in.")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def login_check(b_title_sucess, user)
|
40
|
+
if Browser.b.title.eql?(b_title_sucess)
|
41
|
+
Report.results.puts("User: #{user} has logged in successful.")
|
42
|
+
true
|
43
|
+
else
|
44
|
+
Report.results.puts("User: #{user} has failed to log in.")
|
45
|
+
false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def mem_word_check(user, b_title_sucess)
|
50
|
+
if Browser.b.title.eql?('Memorable word - UKCloud Portal')
|
51
|
+
portal_mem_word(user, b_title_sucess)
|
52
|
+
elsif Browser.b.title.eql?(b_title_sucess)
|
53
|
+
Report.results.puts("User: #{user} has logged in successful.")
|
54
|
+
true
|
55
|
+
else
|
56
|
+
Report.results.puts("User: #{user} has failed to log in.")
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def portal_mem_word(user, b_title_sucess)
|
62
|
+
password = ENV['PORTAL_MEM']
|
63
|
+
nums = (1..256).to_a
|
64
|
+
found_mem_nums = nums.each_with_object([]) do |num_val, mem_word|
|
65
|
+
elm_id = "user_memorable_parts_#{num_val}"
|
66
|
+
mem_word.push(num_val) if Browser.b.select(:id => elm_id).exist?
|
67
|
+
end.compact
|
68
|
+
|
69
|
+
array_password = password.split('')
|
70
|
+
array_password.map!(&:upcase)
|
71
|
+
|
72
|
+
found_mem_nums.each { |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}").select
|
76
|
+
}
|
77
|
+
|
78
|
+
Browser.b.button(value: 'Sign in').wait_until_present.click
|
79
|
+
if Browser.b.title.eql?(b_title_sucess)
|
80
|
+
Report.results.puts("User: #{user} has logged in successful.")
|
81
|
+
return true
|
82
|
+
else
|
83
|
+
Report.results.puts("User: #{user} has failed to log in.")
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class BrowserBack < Base
|
7
|
+
register :browser_back
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
Browser.b.back
|
11
|
+
Report.results.puts('Browser navigated back')
|
12
|
+
true
|
13
|
+
rescue StandardError
|
14
|
+
Report.results.puts('Browser failed to navigate back')
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class BrowserForward < Base
|
7
|
+
register :browser_forward
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
Browser.b.forward
|
11
|
+
Report.results.puts('Browser navigated forward')
|
12
|
+
true
|
13
|
+
rescue StandardError
|
14
|
+
Report.results.puts('Browser failed to navigate forward')
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class BrowserQuit < Base
|
7
|
+
register :browser_quit
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
Browser.b.quit
|
11
|
+
Report.results.puts('Browser has closed successfully')
|
12
|
+
true
|
13
|
+
rescue StandardError
|
14
|
+
Report.results.puts('Browser has failed to close')
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class BrowserRefresh < Base
|
7
|
+
register :browser_refresh
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
Browser.b.refresh
|
11
|
+
Report.results.puts('The Browser has been refreshed')
|
12
|
+
true
|
13
|
+
rescue StandardError
|
14
|
+
Report.results.puts('The Browser failed to refresh')
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class CaptureAlert < Base
|
7
|
+
register :capture_alert
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
Browser.b.div(class: 'alert').exist?
|
11
|
+
alertmsg = Browser.b.div(class: 'alert').text
|
12
|
+
Report.results.puts("Alert shown: #{alertmsg}")
|
13
|
+
true
|
14
|
+
rescue StandardError
|
15
|
+
Report.results.puts('No Alert Found')
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class CheckBox < Base
|
7
|
+
register :check_box
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
checkbox = step_attributes[:testvalue]
|
11
|
+
locate = step_attributes[:locate]
|
12
|
+
|
13
|
+
Browser.b.checkbox(:"#{locate}" => checkbox).wait_until_present.click
|
14
|
+
Report.results.puts("Check box: #{checkbox} has been selected")
|
15
|
+
true
|
16
|
+
rescue StandardError
|
17
|
+
Report.results.puts("Check box: #{checkbox} does not exist")
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class CheckBoxdata < Base
|
7
|
+
register :check_box_data
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
box = step_attributes[:testvalue]
|
11
|
+
value = step_attributes[:testvalue2]
|
12
|
+
locate = step_attributes[:locate]
|
13
|
+
|
14
|
+
found_box = [
|
15
|
+
Browser.b.textarea(:"#{locate}" => box).exist?,
|
16
|
+
Browser.b.text_field(:"#{locate}" => box).exist?
|
17
|
+
]
|
18
|
+
|
19
|
+
raise 'Multiple matches' if found_box.select { |i| i }.empty?
|
20
|
+
index = found_box.index(true)
|
21
|
+
return unless index
|
22
|
+
if index.zero?
|
23
|
+
Browser.b.textarea(:"#{locate}" => box).wait_until_present
|
24
|
+
(Browser.b.textarea(:"#{locate}" => box).value == value)
|
25
|
+
elsif index == 1
|
26
|
+
Browser.b.text_field(:"#{locate}" => box).wait_until_present
|
27
|
+
(Browser.b.text_field(:"#{locate}" => box).value == value)
|
28
|
+
end
|
29
|
+
Report.results.puts("Textbox: #{box} has the correct value: #{value}")
|
30
|
+
true
|
31
|
+
rescue StandardError
|
32
|
+
Report.results.puts("Textbox: #{box} has the incorrect value: #{value}")
|
33
|
+
false
|
34
|
+
rescue StandardError
|
35
|
+
Report.results.puts("Textbox: #{box} does not exist")
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class CheckTitle < Base
|
7
|
+
register :check_browser_title
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
text_check = step_attributes[:testvalue]
|
11
|
+
|
12
|
+
sleep 2
|
13
|
+
if Browser.b.title.eql?(text_check)
|
14
|
+
Report.results.puts("Browser title: #{text_check}")
|
15
|
+
return true
|
16
|
+
else
|
17
|
+
Report.results.puts("Title not found: #{text_check}")
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class CheckLogs < Base
|
7
|
+
register :check_log_file
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
text = step_attributes[:testvalue]
|
11
|
+
file = step_attributes[:testvalue2]
|
12
|
+
|
13
|
+
blog_result = system 'egrep -i ' + text + ' ' + file + ' > ' + output
|
14
|
+
if blog_result == true
|
15
|
+
Report.results.puts("Data has matched: #{text} in LogFile: #{file}")
|
16
|
+
return true
|
17
|
+
else
|
18
|
+
Report.results.puts("Problem finding: #{text} in LogFile: #{file}")
|
19
|
+
return false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class CheckScreendata < Base
|
7
|
+
register :check_screen_data
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
text_check = step_attributes[:testvalue]
|
11
|
+
|
12
|
+
sleep 5
|
13
|
+
if Browser.b.text.include?(text_check)
|
14
|
+
Report.results.puts("Found text: #{text_check}")
|
15
|
+
return true
|
16
|
+
else
|
17
|
+
Report.results.puts("NOT found text: #{text_check}")
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class CheckUrl < Base
|
7
|
+
register :check_url
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
url = step_attributes[:testvalue]
|
11
|
+
|
12
|
+
if Browser.b.url == url
|
13
|
+
Report.results.puts("URL: #{url} is correct")
|
14
|
+
true
|
15
|
+
else
|
16
|
+
Report.results.puts("URL: #{url} is incorrect")
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class ClickButton < Base
|
7
|
+
register :click_button
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
button = step_attributes[:testvalue]
|
11
|
+
locate = step_attributes[:locate]
|
12
|
+
|
13
|
+
elms = %i{button span a div link image h1 h2 h3 h4}
|
14
|
+
|
15
|
+
found_button = elms.map do |elm|
|
16
|
+
Browser.b.send(elm, :"#{locate}" => button).exist?
|
17
|
+
end.compact
|
18
|
+
|
19
|
+
raise 'Multiple matches' if found_button.select { |i| i }.empty?
|
20
|
+
index = found_button.index(true)
|
21
|
+
return unless index
|
22
|
+
|
23
|
+
case index
|
24
|
+
when 0
|
25
|
+
Browser.b.button(:"#{locate}" => button).wait_until_present.click
|
26
|
+
when 1
|
27
|
+
Browser.b.span(:"#{locate}" => button).wait_until_present.click
|
28
|
+
when 2
|
29
|
+
Browser.b.a(:"#{locate}" => button).wait_until_present.click
|
30
|
+
when 3
|
31
|
+
Browser.b.div(:"#{locate}" => button).wait_until_present.click
|
32
|
+
when 4
|
33
|
+
Browser.b.link(:"#{locate}" => button).wait_until_present.click
|
34
|
+
when 5
|
35
|
+
Browser.b.image(:"#{locate}" => button).wait_until_present.click
|
36
|
+
when 6
|
37
|
+
Browser.b.h1(:"#{locate}" => button).wait_until_present.click
|
38
|
+
when 7
|
39
|
+
Browser.b.h2(:"#{locate}" => button).wait_until_present.click
|
40
|
+
when 8
|
41
|
+
Browser.b.h3(:"#{locate}" => button).wait_until_present.click
|
42
|
+
when 9
|
43
|
+
Browser.b.h4(:"#{locate}" => button).wait_until_present.click
|
44
|
+
end
|
45
|
+
Report.results.puts("Button: #{button} has been selected")
|
46
|
+
true
|
47
|
+
rescue StandardError
|
48
|
+
Report.results.puts("Button: #{button} does not exist")
|
49
|
+
false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'base_handler'
|
2
|
+
# require './taf_config.rb'
|
3
|
+
|
4
|
+
module TestSteps
|
5
|
+
module Handlers
|
6
|
+
class ExecuteSystemCommand < Base
|
7
|
+
register :execute_system_command
|
8
|
+
|
9
|
+
def perform(step_attributes)
|
10
|
+
syst_cmd = step_attributes[:testvalue]
|
11
|
+
|
12
|
+
b_result = system syst_cmd
|
13
|
+
if b_result == true
|
14
|
+
Report.results.puts("Cmd has been executed sucessfully #{syst_cmd}")
|
15
|
+
return true
|
16
|
+
else
|
17
|
+
Report.results.puts("Theres a problem executing command #{syst_cmd}")
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|