taft 0.1.0 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/examples/ruby/rs/framework/red_sky.rb +11 -0
- data/examples/ruby/rs/framework/red_sky/api_helpers/general.rb +140 -0
- data/examples/ruby/rs/framework/red_sky/api_helpers/rest.rb +249 -0
- data/examples/ruby/rs/framework/red_sky/ui_helpers/ui_general.rb +36 -0
- data/examples/ruby/rs/framework/red_sky/watir/custom/all.rb +4 -0
- data/examples/ruby/rs/framework/red_sky/watir/custom/rs_custom.rb +32 -0
- data/examples/ruby/rs/framework/red_sky/watir/pages/page_objects.rb +166 -0
- data/examples/ruby/rs/framework/red_sky/watir/pages/rs_pages.rb +68 -0
- data/examples/ruby/rs/lib/config/red_sky_config.rb +27 -0
- data/examples/ruby/rs/lib/config/runtime_constants.rb +20 -0
- data/examples/ruby/rs/lib/red_sky_test_case.rb +218 -0
- data/examples/ruby/rs/tests/v1/tc_r001_01_an_example_test.rb +112 -0
- data/examples/ruby/rs/tests/v1/tc_r001_01_google_search.rb +64 -0
- data/lib/taft.rb +2 -0
- data/lib/taft_files/framework/zznamezz.rb +3 -0
- data/lib/taft_files/framework/zznamezz/api_helpers/general.rb +13 -13
- data/lib/taft_files/framework/zznamezz/ui_helpers/ui_general.rb +26 -0
- data/lib/taft_files/framework/zznamezz/watir/custom/all.rb +4 -0
- data/lib/taft_files/framework/zznamezz/watir/custom/xxabbrevxx_custom.rb +32 -0
- data/lib/taft_files/framework/zznamezz/watir/pages/page_objects.rb +166 -0
- data/lib/taft_files/framework/zznamezz/watir/pages/xxabbrevxx_pages.rb +101 -0
- data/lib/taft_files/lib/config/runtime_constants.rb +5 -1
- data/lib/taft_files/lib/config/zznamezz_config.rb +7 -2
- data/lib/taft_files/lib/zznamezz_test_case.rb +43 -42
- data/lib/taft_files/tests/v1/tc_r001_01_an_example_test.rb +1 -1
- data/taft.gemspec +5 -5
- metadata +23 -6
@@ -0,0 +1,101 @@
|
|
1
|
+
# Class that holds definitions for all of the pages in ZZnamezz
|
2
|
+
# These can be used to determine if the browser is currently displaying that page
|
3
|
+
#
|
4
|
+
# Field types :
|
5
|
+
# Use :text_field instead of :input if it's a text-field
|
6
|
+
# Use :button instead of :input if it's a button
|
7
|
+
# Otherwise, use the actual HTML element type
|
8
|
+
|
9
|
+
require_relative 'page_objects'
|
10
|
+
|
11
|
+
class XXabbrevupperxxPages
|
12
|
+
|
13
|
+
@@browser = nil
|
14
|
+
@@pages = [] # an array of Page objects
|
15
|
+
@@page_names = []
|
16
|
+
|
17
|
+
def self.make_pages(browser)
|
18
|
+
@@browser = browser
|
19
|
+
|
20
|
+
# Nav bar
|
21
|
+
# Not a real page, but is a panel common to many pages
|
22
|
+
# Don't add_page(nav_bar); do page.add_page(nav_bar)
|
23
|
+
nav_bar = Page.new("xxabbrevxxNavBar", "page_title", "Welcome to ZZnamezz")
|
24
|
+
|
25
|
+
nav_bar.add_field("goto_homepage", :link, :id, "xxabbrevxx_home_header_link")
|
26
|
+
nav_bar.add_field("page_title", :h1, :id, "page_title")
|
27
|
+
|
28
|
+
# Homepage
|
29
|
+
page = Page.new("xxabbrevxxHomepage", "page_title", "Welcome to ZZnamezz")
|
30
|
+
|
31
|
+
page.add_field("all_users", :link, :id, "users_header_link")
|
32
|
+
page.add_page(nav_bar)
|
33
|
+
|
34
|
+
self.add_page(page)
|
35
|
+
|
36
|
+
|
37
|
+
# Users
|
38
|
+
page = Page.new("xxabbrevxxUsers", "page_title", "Listing users")
|
39
|
+
|
40
|
+
page.add_field("users", :table, :id, "view_users_table")
|
41
|
+
page.add_field("new_user", :link, :id, "new_user_link")
|
42
|
+
page.add_page(nav_bar)
|
43
|
+
|
44
|
+
self.add_page(page)
|
45
|
+
|
46
|
+
# Create User
|
47
|
+
page = Page.new("xxabbrevxxCreateUser", "page_title", "New user")
|
48
|
+
|
49
|
+
page.add_field("user_name", :text_field, :id, "user_name")
|
50
|
+
page.add_field("role", :list, :id, "user_role")
|
51
|
+
page.add_field("save", :button, :id, "save")
|
52
|
+
page.add_field("back", :link, :id, "back_link")
|
53
|
+
page.add_page(nav_bar)
|
54
|
+
|
55
|
+
self.add_page(page)
|
56
|
+
|
57
|
+
# View User
|
58
|
+
page = Page.new("xxabbrevxxViewUser", "page_title", /^User/)
|
59
|
+
|
60
|
+
page.add_field("project", :div, :id, "name")
|
61
|
+
page.add_field("version", :div, :id, "roles")
|
62
|
+
page.add_field("edit", :link, :id, "edit_link")
|
63
|
+
page.add_field("back", :link, :id, "back_link")
|
64
|
+
page.add_page(nav_bar)
|
65
|
+
|
66
|
+
self.add_page(page)
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
##################################################################################################
|
71
|
+
|
72
|
+
|
73
|
+
def self.add_page(page)
|
74
|
+
page.browser = @@browser # set the browser object for each page
|
75
|
+
# TODO have only one browser object (here in XXabbrevupperxxPages), and have each page know how to find it, instead of taking
|
76
|
+
# their own copy of the object
|
77
|
+
@@pages << page
|
78
|
+
@@page_names << page.name
|
79
|
+
end
|
80
|
+
|
81
|
+
# Outputs info on the pages currently stored
|
82
|
+
def self.info
|
83
|
+
s = ""
|
84
|
+
s += "#{@@pages.size} pages defined. Names :"
|
85
|
+
@@page_names.each {|f| s += "\n#{f}" }
|
86
|
+
s
|
87
|
+
end
|
88
|
+
|
89
|
+
# Will convert name to a string
|
90
|
+
def self.page_known?(name)
|
91
|
+
@@page_names.include?(name.to_s)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Retrieves the specific page; raises if it cannot be found
|
95
|
+
# Will convert name to a string
|
96
|
+
def self.find(name)
|
97
|
+
raise "Could not locate page '#{name}'" unless self.page_known?(name)
|
98
|
+
@@pages[@@page_names.index(name.to_s)]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
# This class holds parameters that may frequently change between test runs, e.g the test environment
|
3
|
-
|
3
|
+
module RuntimeConstants
|
4
4
|
|
5
5
|
$TEST_ENV = :test_1
|
6
6
|
|
@@ -10,6 +10,10 @@ class RuntimeConstants
|
|
10
10
|
MAKE_ERROR_SCREENSHOTS = true
|
11
11
|
ERROR_SCREENSHOT_LOCATION = "screenshots"
|
12
12
|
|
13
|
+
WRITE_CI_REPORTS = false
|
14
|
+
|
15
|
+
BROWSER = :chrome
|
16
|
+
|
13
17
|
RESULTS_CSV = "results.csv"
|
14
18
|
|
15
19
|
end
|
@@ -6,12 +6,13 @@ class ZZnamezzConfig
|
|
6
6
|
include RuntimeConstants
|
7
7
|
|
8
8
|
CERTIFICATE_DIR = "certs"
|
9
|
+
CERTIFICATE_POPUP_TIMEOUT = 15
|
9
10
|
|
10
11
|
API_VERSION = "latest"
|
11
12
|
|
12
13
|
SERVERS = {
|
13
|
-
:test_1 => {:zznamezz_url
|
14
|
-
:ref_1 => {:zznamezz_url
|
14
|
+
:test_1 => {:zznamezz_url => "https://"},
|
15
|
+
:ref_1 => {:zznamezz_url => "https://"},
|
15
16
|
}
|
16
17
|
|
17
18
|
SERVER = SERVERS[$TEST_ENV]
|
@@ -19,4 +20,8 @@ class ZZnamezzConfig
|
|
19
20
|
|
20
21
|
PASSED = "Passed"
|
21
22
|
FAILED = "Failed"
|
23
|
+
|
24
|
+
DISALLOWED_FIELD_NAMES = ["name"]
|
25
|
+
|
26
|
+
ALL_USER_ROLES = ["all"]
|
22
27
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# should implement their own methods and call super within them to trigger these common
|
6
6
|
# setup/teardown methods at the right time.
|
7
7
|
|
8
|
-
$LOAD_PATH.unshift
|
8
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/.."))
|
9
9
|
|
10
10
|
gem 'test-unit'
|
11
11
|
require 'test/unit'
|
@@ -13,9 +13,10 @@ require 'tmpdir'
|
|
13
13
|
require 'time'
|
14
14
|
require 'fileutils'
|
15
15
|
require 'timeout'
|
16
|
+
require 'watir'
|
16
17
|
|
17
18
|
# Config
|
18
|
-
require 'config/zznamezz_config'
|
19
|
+
require 'config/zznamezz_config.rb'
|
19
20
|
|
20
21
|
# Helpers
|
21
22
|
require 'framework/zznamezz.rb'
|
@@ -33,8 +34,6 @@ end
|
|
33
34
|
|
34
35
|
module ZZnamezzTestCase
|
35
36
|
|
36
|
-
include ZZnamezz
|
37
|
-
|
38
37
|
attr_accessor :browser_has_been_opened
|
39
38
|
|
40
39
|
# optional field
|
@@ -44,86 +43,87 @@ module ZZnamezzTestCase
|
|
44
43
|
# method (if they have any relevent failure notes).
|
45
44
|
attr_accessor :failure_notes
|
46
45
|
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
# E.g. calling homepage.displayed? from a test script :
|
47
|
+
# Test cannot see homepage so its call is routed through method_missing
|
48
|
+
# If method_missing returns an instance of the class, .displayed? can be called on it (seamlessly)
|
49
|
+
# At present this will happen for every call to a page from a test script
|
50
|
+
def method_missing(name, *args, &block)
|
51
|
+
#puts "ZZnamezzTestCase method_missing called; name = #{name.inspect}; #{name.class}"
|
52
|
+
|
53
|
+
case name.to_s
|
54
|
+
when /^browser$/
|
55
|
+
browser
|
56
|
+
when /^xxabbrevxx/i
|
57
|
+
XXabbrevupperxxPages.find(name.to_s) # return the page so that the test can use it
|
56
58
|
else
|
57
59
|
super
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
|
-
|
62
63
|
if $WRITE_RESULTS # supplied from invokation
|
63
64
|
WRITE_RESULTS = true
|
64
65
|
else
|
65
66
|
WRITE_RESULTS = false
|
66
67
|
end
|
67
68
|
|
68
|
-
# Close the current browser and log in again
|
69
|
-
def re_login
|
70
|
-
browser.close
|
71
|
-
|
72
|
-
new_browser_on_login_page
|
73
|
-
# Reinitialise the contexd and @help
|
74
|
-
reinitialisexxabbrevupperxxContext(browser)
|
75
|
-
end
|
76
|
-
|
77
69
|
# Connect to yyrawnameyy and reinitialise the context, etc.
|
78
70
|
def xxabbrevxx_login(url = ZZnamezzConfig::SERVER[:zznamezz_url])
|
79
|
-
|
80
|
-
|
81
|
-
reinitialisexxabbrevupperxxContext(browser)
|
82
|
-
end
|
83
|
-
|
84
|
-
# Reinitialise xxabbrevupperxx context only
|
85
|
-
def reinitialisexxabbrevupperxxContext(new_browser)
|
86
|
-
@xxabbrevxx_context = ZZnamezz::Context.new(new_browser)
|
87
|
-
@help = xxabbrevupperxxHelper.new(@xxabbrevxx_context)
|
71
|
+
browser = @help.new_browser_at_url(url)
|
72
|
+
load_pages(browser)
|
88
73
|
end
|
89
74
|
|
90
|
-
|
91
|
-
|
92
|
-
|
75
|
+
def load_pages(browser)
|
76
|
+
@browser_has_been_opened = true
|
77
|
+
xxabbrevupperxxPages.make_pages(browser) # cannot have pages without a browser object
|
78
|
+
$browsers << browser
|
93
79
|
end
|
94
80
|
|
95
81
|
# Close the current browser
|
96
82
|
def close_browser
|
97
|
-
|
83
|
+
browser.close
|
98
84
|
end
|
99
85
|
|
100
86
|
def close(browser)
|
101
87
|
if browser.exists? && ((ZZnamezzConfig::CLOSE_BROWSER_AFTER_TEST && passed?) || ZZnamezzConfig::FORCE_CLOSE_BROWSER_AFTER_TEST)
|
102
88
|
browser.close
|
103
89
|
$browsers.delete_at($current_browser_position - 1) # array indexing
|
104
|
-
|
90
|
+
browser = $browsers[-1] # set browser to the last one that is still in the array
|
105
91
|
end
|
106
92
|
end
|
107
93
|
|
108
94
|
def close_all_browsers
|
109
95
|
if (ZZnamezzConfig::CLOSE_BROWSER_AFTER_TEST && passed?) || ZZnamezzConfig::FORCE_CLOSE_BROWSER_AFTER_TEST
|
110
96
|
until $browsers.empty?
|
111
|
-
|
97
|
+
browser = $browsers.shift
|
112
98
|
browser.close
|
113
99
|
end
|
114
100
|
end
|
115
101
|
end
|
116
102
|
|
103
|
+
|
104
|
+
@@browser = nil
|
105
|
+
|
106
|
+
def browser
|
107
|
+
@@browser
|
108
|
+
end
|
109
|
+
|
110
|
+
def browser=(b)
|
111
|
+
@@browser = b
|
112
|
+
end
|
113
|
+
alias set_browser browser= # note : calls of "browser = " do not work, calls of "browser=" do
|
114
|
+
|
117
115
|
# Ensure that every test (that wants one) has a browser that is already logged in to the system
|
118
116
|
def setup
|
119
117
|
|
118
|
+
@help = xxabbrevupperxxHelper.new
|
119
|
+
|
120
120
|
Watir.always_locate = true # default is true; setting to false speeds up Watir to a degree
|
121
121
|
|
122
122
|
# Get start time for later output in results
|
123
123
|
@test_start_time = Time.now
|
124
124
|
|
125
125
|
# Get the directory that the specific test lives in, so that it can be included in the results file
|
126
|
-
@test_file_dir = @test_file.split(File::SEPARATOR)[-2]
|
126
|
+
@test_file_dir = @test_file.split(File::SEPARATOR)[-2] if @test_file
|
127
127
|
|
128
128
|
# Select default certificate if none is configured
|
129
129
|
@certificate ||= :regular
|
@@ -138,7 +138,6 @@ module ZZnamezzTestCase
|
|
138
138
|
xxabbrevxx_login
|
139
139
|
elsif (@initialBrowser == :none || @initialBrowser == nil)
|
140
140
|
browser = nil
|
141
|
-
reinitialisexxabbrevupperxxContext(browser)
|
142
141
|
end
|
143
142
|
|
144
143
|
end # end setup
|
@@ -179,8 +178,7 @@ module ZZnamezzTestCase
|
|
179
178
|
puts "Notes : #{notes}"
|
180
179
|
end # end unless passed?
|
181
180
|
|
182
|
-
|
183
|
-
|
181
|
+
|
184
182
|
# Write to the results file
|
185
183
|
begin
|
186
184
|
File.open(ZZnamezzConfig::RESULTS_CSV, "a") do |f|
|
@@ -192,6 +190,9 @@ module ZZnamezzTestCase
|
|
192
190
|
puts "Had to rescue from writing results to file #{ZZnamezzConfig::RESULTS_CSV}"
|
193
191
|
end
|
194
192
|
end # end if WRITE_RESULTS
|
193
|
+
|
194
|
+
close_all_browsers
|
195
|
+
|
195
196
|
rescue Timeout::Error => t_error
|
196
197
|
puts "Timeout::Error :"
|
197
198
|
puts t_error
|
data/taft.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'taft'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.2.4'
|
4
4
|
s.licenses = ['MIT']
|
5
|
-
s.summary = "Test Automation Framework Template"
|
6
|
-
s.description = "
|
5
|
+
s.summary = "Test Automation Framework Template (TAFT)"
|
6
|
+
s.description = "TAFT will deploy/install a skeleton code framework for the automated testing of applications with APIs and/or web-UIs"
|
7
7
|
s.authors = ["Richard Morrisby"]
|
8
8
|
s.email = 'rmorrisby@gmail.com'
|
9
9
|
s.files = ["lib/taft.rb"]
|
10
|
-
s.homepage = 'https://
|
11
|
-
s.required_ruby_version = '>=
|
10
|
+
s.homepage = 'https://github.com/RMorrisby/class_from_son'
|
11
|
+
s.required_ruby_version = '>=2.6'
|
12
12
|
s.files = Dir['**/**']
|
13
13
|
s.test_files = Dir["test/test*.rb"]
|
14
14
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Morrisby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: TAFT will deploy/install a skeleton code framework for the automated
|
14
14
|
testing of applications with APIs and/or web-UIs
|
15
15
|
email: rmorrisby@gmail.com
|
16
16
|
executables: []
|
@@ -20,18 +20,35 @@ files:
|
|
20
20
|
- LICENCE.txt
|
21
21
|
- README.md
|
22
22
|
- build.rb
|
23
|
+
- examples/ruby/rs/framework/red_sky.rb
|
24
|
+
- examples/ruby/rs/framework/red_sky/api_helpers/general.rb
|
25
|
+
- examples/ruby/rs/framework/red_sky/api_helpers/rest.rb
|
26
|
+
- examples/ruby/rs/framework/red_sky/ui_helpers/ui_general.rb
|
27
|
+
- examples/ruby/rs/framework/red_sky/watir/custom/all.rb
|
28
|
+
- examples/ruby/rs/framework/red_sky/watir/custom/rs_custom.rb
|
29
|
+
- examples/ruby/rs/framework/red_sky/watir/pages/page_objects.rb
|
30
|
+
- examples/ruby/rs/framework/red_sky/watir/pages/rs_pages.rb
|
31
|
+
- examples/ruby/rs/lib/config/red_sky_config.rb
|
32
|
+
- examples/ruby/rs/lib/config/runtime_constants.rb
|
33
|
+
- examples/ruby/rs/lib/red_sky_test_case.rb
|
34
|
+
- examples/ruby/rs/tests/v1/tc_r001_01_an_example_test.rb
|
35
|
+
- examples/ruby/rs/tests/v1/tc_r001_01_google_search.rb
|
23
36
|
- lib/taft.rb
|
24
37
|
- lib/taft_files/framework/zznamezz.rb
|
25
38
|
- lib/taft_files/framework/zznamezz/api_helpers/general.rb
|
26
39
|
- lib/taft_files/framework/zznamezz/api_helpers/rest.rb
|
27
40
|
- lib/taft_files/framework/zznamezz/ui_helpers/ui_general.rb
|
41
|
+
- lib/taft_files/framework/zznamezz/watir/custom/all.rb
|
42
|
+
- lib/taft_files/framework/zznamezz/watir/custom/xxabbrevxx_custom.rb
|
43
|
+
- lib/taft_files/framework/zznamezz/watir/pages/page_objects.rb
|
44
|
+
- lib/taft_files/framework/zznamezz/watir/pages/xxabbrevxx_pages.rb
|
28
45
|
- lib/taft_files/lib/config/runtime_constants.rb
|
29
46
|
- lib/taft_files/lib/config/zznamezz_config.rb
|
30
47
|
- lib/taft_files/lib/zznamezz_test_case.rb
|
31
48
|
- lib/taft_files/tests/v1/tc_r001_01_an_example_test.rb
|
32
49
|
- taft.gemspec
|
33
50
|
- test/test_example.rb
|
34
|
-
homepage: https://
|
51
|
+
homepage: https://github.com/RMorrisby/class_from_son
|
35
52
|
licenses:
|
36
53
|
- MIT
|
37
54
|
metadata: {}
|
@@ -43,7 +60,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
60
|
requirements:
|
44
61
|
- - ">="
|
45
62
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
63
|
+
version: '2.6'
|
47
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
65
|
requirements:
|
49
66
|
- - ">="
|
@@ -53,6 +70,6 @@ requirements: []
|
|
53
70
|
rubygems_version: 3.0.3
|
54
71
|
signing_key:
|
55
72
|
specification_version: 4
|
56
|
-
summary: Test Automation Framework Template
|
73
|
+
summary: Test Automation Framework Template (TAFT)
|
57
74
|
test_files:
|
58
75
|
- test/test_example.rb
|