testcentricity 2.4.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +29 -0
- data/.rspec +2 -1
- data/.rubocop.yml +38 -0
- data/.ruby-version +1 -1
- data/.simplecov +9 -0
- data/.yardopts +3 -0
- data/CHANGELOG.md +275 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/{LICENSE.txt → LICENSE.md} +3 -4
- data/README.md +938 -1378
- data/Rakefile +63 -1
- data/config/cucumber.yml +145 -0
- data/config/locales/en-US.yml +56 -0
- data/config/test_data/LOCAL_data.yml +11 -0
- data/config/test_data/data.yml +10 -0
- data/features/deep_links.feature +26 -0
- data/features/login.feature +30 -0
- data/features/navigation.feature +31 -0
- data/features/step_definitions/generic_steps.rb +72 -0
- data/features/support/android/screens/about_screen.rb +11 -0
- data/features/support/android/screens/base_app_screen.rb +29 -0
- data/features/support/android/screens/checkout_address_screen.rb +17 -0
- data/features/support/android/screens/checkout_payment_screen.rb +22 -0
- data/features/support/android/screens/login_screen.rb +18 -0
- data/features/support/android/screens/products_screen.rb +13 -0
- data/features/support/android/screens/saucebot_screen.rb +16 -0
- data/features/support/android/screens/webview_screen.rb +13 -0
- data/features/support/android/sections/nav_widgets/nav_menu.rb +39 -0
- data/features/support/env.rb +61 -0
- data/features/support/hooks.rb +135 -0
- data/features/support/ios/screens/about_screen.rb +11 -0
- data/features/support/ios/screens/base_app_screen.rb +19 -0
- data/features/support/ios/screens/checkout_address_screen.rb +17 -0
- data/features/support/ios/screens/checkout_payment_screen.rb +22 -0
- data/features/support/ios/screens/login_screen.rb +18 -0
- data/features/support/ios/screens/products_screen.rb +13 -0
- data/features/support/ios/screens/saucebot_screen.rb +16 -0
- data/features/support/ios/screens/webview_screen.rb +13 -0
- data/features/support/ios/sections/list_items/product_cell_item.rb +13 -0
- data/features/support/ios/sections/modals/base_modal.rb +23 -0
- data/features/support/ios/sections/modals/logout_modal.rb +6 -0
- data/features/support/ios/sections/modals/reset_app_state_modal.rb +6 -0
- data/features/support/ios/sections/nav_widgets/nav_bar.rb +31 -0
- data/features/support/ios/sections/nav_widgets/nav_menu.rb +41 -0
- data/features/support/shared_components/screens/base_app_screen.rb +31 -0
- data/features/support/shared_components/screens/checkout_address_screen.rb +17 -0
- data/features/support/shared_components/screens/checkout_payment_screen.rb +22 -0
- data/features/support/shared_components/screens/login_screen.rb +39 -0
- data/features/support/shared_components/screens/saucebot_screen.rb +17 -0
- data/features/support/shared_components/screens/webview_screen.rb +12 -0
- data/features/support/shared_components/sections/nav_menu.rb +58 -0
- data/features/support/world_data.rb +12 -0
- data/features/support/world_pages.rb +26 -0
- data/lib/testcentricity/app_core/appium_connect_helper.rb +355 -111
- data/lib/testcentricity/app_core/screen_object.rb +252 -0
- data/lib/testcentricity/app_core/screen_objects_helper.rb +29 -280
- data/lib/testcentricity/app_core/screen_section.rb +350 -0
- data/lib/testcentricity/app_elements/app_element_helper.rb +17 -8
- data/lib/testcentricity/app_elements/checkbox.rb +3 -3
- data/lib/testcentricity/data_objects/environment.rb +133 -39
- data/lib/testcentricity/version.rb +1 -1
- data/lib/testcentricity.rb +4 -129
- data/reports/.keep +1 -0
- data/spec/fixtures/page_object.rb +22 -0
- data/spec/fixtures/page_section_object.rb +21 -0
- data/spec/fixtures/screen_object.rb +16 -0
- data/spec/fixtures/screen_section_object.rb +16 -0
- data/spec/spec_helper.rb +28 -9
- data/spec/testcentricity/elements/button_spec.rb +18 -0
- data/spec/testcentricity/elements/checkbox_spec.rb +28 -0
- data/spec/testcentricity/elements/image_spec.rb +13 -0
- data/spec/testcentricity/elements/label_spec.rb +18 -0
- data/spec/testcentricity/elements/list_spec.rb +13 -0
- data/spec/testcentricity/elements/ui_element_spec.rb +72 -0
- data/spec/testcentricity/mobile/appium_connect_spec.rb +117 -0
- data/spec/testcentricity/mobile/screen_object_spec.rb +63 -0
- data/spec/testcentricity/mobile/screen_section_object_spec.rb +56 -0
- data/spec/testcentricity/version_spec.rb +7 -0
- data/spec/testcentricity/web/browser_spec.rb +41 -0
- data/spec/testcentricity/web/local_webdriver_spec.rb +86 -0
- data/spec/testcentricity/web/mobile_webdriver_spec.rb +123 -0
- data/spec/testcentricity/web/page_object_spec.rb +85 -0
- data/spec/testcentricity/web/page_section_object_spec.rb +72 -0
- data/testcentricity.gemspec +28 -27
- metadata +196 -127
- data/.ruby-gemset +0 -1
- data/Gemfile.lock +0 -93
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/devices/devices.yml +0 -352
- data/lib/testcentricity/app_core/appium_server.rb +0 -69
- data/lib/testcentricity/app_core/screen_sections_helper.rb +0 -491
- data/lib/testcentricity/browser_helper.rb +0 -174
- data/lib/testcentricity/data_objects/data_objects_helper.rb +0 -78
- data/lib/testcentricity/data_objects/excel_helper.rb +0 -242
- data/lib/testcentricity/exception_queue_helper.rb +0 -111
- data/lib/testcentricity/utility_helpers.rb +0 -28
- data/lib/testcentricity/web_core/drag_drop_helper.rb +0 -15
- data/lib/testcentricity/web_core/page_objects_helper.rb +0 -711
- data/lib/testcentricity/web_core/page_sections_helper.rb +0 -932
- data/lib/testcentricity/web_core/webdriver_helper.rb +0 -588
- data/lib/testcentricity/web_elements/button.rb +0 -8
- data/lib/testcentricity/web_elements/cell_button.rb +0 -8
- data/lib/testcentricity/web_elements/cell_checkbox.rb +0 -38
- data/lib/testcentricity/web_elements/cell_element.rb +0 -69
- data/lib/testcentricity/web_elements/cell_image.rb +0 -8
- data/lib/testcentricity/web_elements/cell_radio.rb +0 -31
- data/lib/testcentricity/web_elements/checkbox.rb +0 -100
- data/lib/testcentricity/web_elements/file_field.rb +0 -45
- data/lib/testcentricity/web_elements/image.rb +0 -34
- data/lib/testcentricity/web_elements/label.rb +0 -8
- data/lib/testcentricity/web_elements/link.rb +0 -8
- data/lib/testcentricity/web_elements/list.rb +0 -100
- data/lib/testcentricity/web_elements/list_button.rb +0 -8
- data/lib/testcentricity/web_elements/list_checkbox.rb +0 -38
- data/lib/testcentricity/web_elements/list_element.rb +0 -61
- data/lib/testcentricity/web_elements/list_radio.rb +0 -31
- data/lib/testcentricity/web_elements/radio.rb +0 -74
- data/lib/testcentricity/web_elements/select_list.rb +0 -208
- data/lib/testcentricity/web_elements/siebel_open_ui_helper.rb +0 -15
- data/lib/testcentricity/web_elements/table.rb +0 -612
- data/lib/testcentricity/web_elements/textfield.rb +0 -114
- data/lib/testcentricity/web_elements/ui_elements_helper.rb +0 -532
- data/lib/testcentricity/world_extensions.rb +0 -26
- data/my_templates/default/method_details/setup.rb +0 -3
- data/spec/testcentricity_spec.rb +0 -9
@@ -0,0 +1,252 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
module TestCentricity
|
4
|
+
class ScreenObject < BaseScreenSectionObject
|
5
|
+
include Test::Unit::Assertions
|
6
|
+
|
7
|
+
attr_reader :locator
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
raise "Screen object #{self.class.name} does not have a page_name trait defined" unless defined?(page_name)
|
11
|
+
@locator = page_locator if defined?(page_locator)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.trait(trait_name, &block)
|
15
|
+
define_method(trait_name.to_s, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.element(element_name, locator)
|
19
|
+
define_screen_element(element_name, TestCentricity::AppUIElement, locator)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.elements(element_hash)
|
23
|
+
element_hash.each do |element_name, locator|
|
24
|
+
element(element_name, locator)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.button(element_name, locator)
|
29
|
+
define_screen_element(element_name, TestCentricity::AppButton, locator)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.buttons(element_hash)
|
33
|
+
element_hash.each do |element_name, locator|
|
34
|
+
button(element_name, locator)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.textfield(element_name, locator)
|
39
|
+
define_screen_element(element_name, TestCentricity::AppTextField, locator)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.textfields(element_hash)
|
43
|
+
element_hash.each do |element_name, locator|
|
44
|
+
textfield(element_name, locator)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.switch(element_name, locator)
|
49
|
+
define_screen_element(element_name, TestCentricity::AppSwitch, locator)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.switches(element_hash)
|
53
|
+
element_hash.each do |element_name, locator|
|
54
|
+
switch(element_name, locator)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.checkbox(element_name, locator)
|
59
|
+
define_screen_element(element_name, TestCentricity::AppCheckBox, locator)
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.checkboxes(element_hash)
|
63
|
+
element_hash.each do |element_name, locator|
|
64
|
+
checkbox(element_name, locator)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.label(element_name, locator)
|
69
|
+
define_screen_element(element_name, TestCentricity::AppLabel, locator)
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.labels(element_hash)
|
73
|
+
element_hash.each do |element_name, locator|
|
74
|
+
label(element_name, locator)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.list(element_name, locator)
|
79
|
+
define_screen_element(element_name, TestCentricity::AppList, locator)
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.lists(element_hash)
|
83
|
+
element_hash.each do |element_name, locator|
|
84
|
+
list(element_name, locator)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.selectlist(element_name, locator)
|
89
|
+
define_screen_element(element_name, TestCentricity::AppSelectList, locator)
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.selectlists(element_hash)
|
93
|
+
element_hash.each do |element_name, locator|
|
94
|
+
selectlist(element_name, locator)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.image(element_name, locator)
|
99
|
+
define_screen_element(element_name, TestCentricity::AppImage, locator)
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.images(element_hash)
|
103
|
+
element_hash.each do |element_name, locator|
|
104
|
+
image(element_name, locator)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.alert(element_name, locator)
|
109
|
+
define_screen_element(element_name, TestCentricity::AppAlert, locator)
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.alerts(element_hash)
|
113
|
+
element_hash.each do |element_name, locator|
|
114
|
+
alert(element_name, locator)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.section(section_name, obj, locator = 0)
|
119
|
+
define_screen_element(section_name, obj, locator)
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.sections(section_hash)
|
123
|
+
section_hash.each do |section_name, class_name|
|
124
|
+
section(section_name, class_name)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def open_portal
|
129
|
+
environment = Environ.current
|
130
|
+
|
131
|
+
Environ.portal_state = :open
|
132
|
+
end
|
133
|
+
|
134
|
+
def verify_page_exists
|
135
|
+
wait = Selenium::WebDriver::Wait.new(timeout: Environ.default_max_wait_time)
|
136
|
+
wait.until { exists? }
|
137
|
+
PageManager.current_page = self
|
138
|
+
rescue
|
139
|
+
raise "Could not find page_locator for screen object '#{self.class.name}' (#{@locator}) after #{Environ.default_max_wait_time} seconds"
|
140
|
+
end
|
141
|
+
|
142
|
+
def exists?
|
143
|
+
@locator.is_a?(Array) ? tries ||= 2 : tries ||= 1
|
144
|
+
if @locator.is_a?(Array)
|
145
|
+
loc = @locator[tries - 1]
|
146
|
+
find_element(loc.keys[0], loc.values[0])
|
147
|
+
else
|
148
|
+
find_element(@locator.keys[0], @locator.values[0])
|
149
|
+
end
|
150
|
+
true
|
151
|
+
rescue
|
152
|
+
retry if (tries -= 1) > 0
|
153
|
+
false
|
154
|
+
end
|
155
|
+
|
156
|
+
def wait_until_exists(seconds = nil, post_exception = true)
|
157
|
+
timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
|
158
|
+
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
159
|
+
wait.until { exists? }
|
160
|
+
rescue
|
161
|
+
if post_exception
|
162
|
+
raise "Screen object #{self.class.name} not found after #{timeout} seconds" unless exists?
|
163
|
+
else
|
164
|
+
exists?
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def wait_until_gone(seconds = nil, post_exception = true)
|
169
|
+
timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
|
170
|
+
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
171
|
+
wait.until { !exists? }
|
172
|
+
rescue
|
173
|
+
if post_exception
|
174
|
+
raise "Screen object #{self.class.name} remained visible after #{timeout} seconds" if exists?
|
175
|
+
else
|
176
|
+
exists?
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def navigate_to; end
|
181
|
+
|
182
|
+
def verify_page_ui; end
|
183
|
+
|
184
|
+
def load_page
|
185
|
+
if exists?
|
186
|
+
verify_page_exists
|
187
|
+
return
|
188
|
+
end
|
189
|
+
|
190
|
+
url = if page_url.include?("://")
|
191
|
+
page_url
|
192
|
+
elsif !Environ.current.deep_link_prefix.blank?
|
193
|
+
link_url = "#{Environ.current.deep_link_prefix}://#{page_url}"
|
194
|
+
if Environ.is_android?
|
195
|
+
$driver.execute_script(
|
196
|
+
'mobile:deepLink',
|
197
|
+
{
|
198
|
+
url: link_url,
|
199
|
+
package: Environ.current.android_app_id
|
200
|
+
}
|
201
|
+
)
|
202
|
+
verify_page_exists
|
203
|
+
return
|
204
|
+
else
|
205
|
+
link_url
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
if Environ.is_ios? && Environ.is_device?
|
210
|
+
# launch Safari browser on iOS real device
|
211
|
+
$driver.execute_script('mobile: launchApp', { bundleId: 'com.apple.mobilesafari' })
|
212
|
+
unless $driver.is_keyboard_shown
|
213
|
+
begin
|
214
|
+
# attempt to find and click URL button on iOS 15 Safari browser
|
215
|
+
find_element(:accessibility_id, 'TabBarItemTitle').click
|
216
|
+
rescue
|
217
|
+
# fall back to URL button on iOS 14 Safari browser
|
218
|
+
find_element(:xpath, '//XCUIElementTypeButton[@name="URL"]').click
|
219
|
+
end
|
220
|
+
end
|
221
|
+
# enter deep-link URL
|
222
|
+
wait_for_object(:xpath, '//XCUIElementTypeTextField[@name="URL"]', 5).send_keys("#{url}\uE007")
|
223
|
+
# wait for and accept the popup modal
|
224
|
+
wait_for_object(:xpath, '//XCUIElementTypeButton[@name="Open"]', 10).click
|
225
|
+
else
|
226
|
+
$driver.get(url)
|
227
|
+
end
|
228
|
+
verify_page_exists
|
229
|
+
end
|
230
|
+
|
231
|
+
private
|
232
|
+
|
233
|
+
def self.define_screen_element(element_name, obj, locator)
|
234
|
+
define_method(element_name) do
|
235
|
+
ivar_name = "@#{element_name}"
|
236
|
+
ivar = instance_variable_get(ivar_name)
|
237
|
+
return ivar if ivar
|
238
|
+
instance_variable_set(ivar_name, obj.new(element_name, self, locator, :page))
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def wait_for_object(find_method, locator, seconds)
|
243
|
+
wait = Selenium::WebDriver::Wait.new(timeout: seconds)
|
244
|
+
obj = nil
|
245
|
+
wait.until do
|
246
|
+
obj = find_element(find_method, locator)
|
247
|
+
obj.displayed?
|
248
|
+
end
|
249
|
+
obj
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
@@ -1,271 +1,41 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
|
3
3
|
module TestCentricity
|
4
|
-
class
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
class BaseScreenSectionObject
|
5
|
+
# Define a trait for this screen or section object.
|
6
|
+
#
|
7
|
+
# @param trait_name [Symbol] name of trait (as a symbol)
|
8
|
+
# @param block [&block] trait value
|
9
|
+
# @example
|
10
|
+
# trait(:page_name) { 'Shopping Basket' }
|
11
|
+
# trait(:page_locator) { { accessibility_id: 'My Contacts View' } }
|
12
|
+
# trait(:section_locator) { { id: 'activity_feed_tabs' } }
|
13
|
+
#
|
14
14
|
def self.trait(trait_name, &block)
|
15
15
|
define_method(trait_name.to_s, &block)
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# def self.button(element_name, locator)
|
38
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppButton.new("#{element_name}", self, #{locator}, :page);end))
|
39
|
-
# end
|
40
|
-
|
41
|
-
def self.button(element_name, locator)
|
42
|
-
define_method(element_name) do
|
43
|
-
ivar_name = "@#{element_name}"
|
44
|
-
ivar = instance_variable_get(ivar_name)
|
45
|
-
return ivar if ivar
|
46
|
-
instance_variable_set(ivar_name, TestCentricity::AppButton.new(element_name, self, locator, :page))
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.buttons(element_hash)
|
51
|
-
element_hash.each do |element_name, locator|
|
52
|
-
button(element_name, locator)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# def self.textfield(element_name, locator)
|
57
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppTextField.new("#{element_name}", self, #{locator}, :page);end))
|
58
|
-
# end
|
59
|
-
|
60
|
-
def self.textfield(element_name, locator)
|
61
|
-
define_method(element_name) do
|
62
|
-
ivar_name = "@#{element_name}"
|
63
|
-
ivar = instance_variable_get(ivar_name)
|
64
|
-
return ivar if ivar
|
65
|
-
instance_variable_set(ivar_name, TestCentricity::AppTextField.new(element_name, self, locator, :page))
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.textfields(element_hash)
|
70
|
-
element_hash.each do |element_name, locator|
|
71
|
-
textfield(element_name, locator)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# def self.switch(element_name, locator)
|
76
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSwitch.new("#{element_name}", self, #{locator}, :page);end))
|
77
|
-
# end
|
78
|
-
|
79
|
-
def self.switch(element_name, locator)
|
80
|
-
define_method(element_name) do
|
81
|
-
ivar_name = "@#{element_name}"
|
82
|
-
ivar = instance_variable_get(ivar_name)
|
83
|
-
return ivar if ivar
|
84
|
-
instance_variable_set(ivar_name, TestCentricity::AppSwitch.new(element_name, self, locator, :page))
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def self.switches(element_hash)
|
89
|
-
element_hash.each do |element_name, locator|
|
90
|
-
switch(element_name, locator)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# def self.checkbox(element_name, locator)
|
95
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppCheckBox.new("#{element_name}", self, #{locator}, :page);end))
|
96
|
-
# end
|
97
|
-
|
98
|
-
def self.checkbox(element_name, locator)
|
99
|
-
define_method(element_name) do
|
100
|
-
ivar_name = "@#{element_name}"
|
101
|
-
ivar = instance_variable_get(ivar_name)
|
102
|
-
return ivar if ivar
|
103
|
-
instance_variable_set(ivar_name, TestCentricity::AppCheckBox.new(element_name, self, locator, :page))
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def self.checkboxes(element_hash)
|
108
|
-
element_hash.each do |element_name, locator|
|
109
|
-
checkbox(element_name, locator)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
# def self.label(element_name, locator)
|
114
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppLabel.new("#{element_name}", self, #{locator}, :page);end))
|
115
|
-
# end
|
116
|
-
|
117
|
-
def self.label(element_name, locator)
|
118
|
-
define_method(element_name) do
|
119
|
-
ivar_name = "@#{element_name}"
|
120
|
-
ivar = instance_variable_get(ivar_name)
|
121
|
-
return ivar if ivar
|
122
|
-
instance_variable_set(ivar_name, TestCentricity::AppLabel.new(element_name, self, locator, :page))
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def self.labels(element_hash)
|
127
|
-
element_hash.each do |element_name, locator|
|
128
|
-
label(element_name, locator)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
# def self.list(element_name, locator)
|
133
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppList.new("#{element_name}", self, #{locator}, :page);end))
|
134
|
-
# end
|
135
|
-
|
136
|
-
def self.list(element_name, locator)
|
137
|
-
define_method(element_name) do
|
138
|
-
ivar_name = "@#{element_name}"
|
139
|
-
ivar = instance_variable_get(ivar_name)
|
140
|
-
return ivar if ivar
|
141
|
-
instance_variable_set(ivar_name, TestCentricity::AppList.new(element_name, self, locator, :page))
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def self.lists(element_hash)
|
146
|
-
element_hash.each do |element_name, locator|
|
147
|
-
list(element_name, locator)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
# def self.selectlist(element_name, locator)
|
152
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSelectList.new("#{element_name}", self, #{locator}, :page);end))
|
153
|
-
# end
|
154
|
-
|
155
|
-
def self.selectlist(element_name, locator)
|
156
|
-
define_method(element_name) do
|
157
|
-
ivar_name = "@#{element_name}"
|
158
|
-
ivar = instance_variable_get(ivar_name)
|
159
|
-
return ivar if ivar
|
160
|
-
instance_variable_set(ivar_name, TestCentricity::AppSelectList.new(element_name, self, locator, :page))
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def self.selectlists(element_hash)
|
165
|
-
element_hash.each do |element_name, locator|
|
166
|
-
selectlist(element_name, locator)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
# def self.image(element_name, locator)
|
171
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppImage.new("#{element_name}", self, #{locator}, :page);end))
|
172
|
-
# end
|
173
|
-
|
174
|
-
def self.image(element_name, locator)
|
175
|
-
define_method(element_name) do
|
176
|
-
ivar_name = "@#{element_name}"
|
177
|
-
ivar = instance_variable_get(ivar_name)
|
178
|
-
return ivar if ivar
|
179
|
-
instance_variable_set(ivar_name, TestCentricity::AppImage.new(element_name, self, locator, :page))
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def self.images(element_hash)
|
184
|
-
element_hash.each do |element_name, locator|
|
185
|
-
image(element_name, locator)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
# def self.alert(element_name, locator)
|
190
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppAlert.new("#{element_name}", self, #{locator}, :page);end))
|
191
|
-
# end
|
192
|
-
|
193
|
-
def self.alert(element_name, locator)
|
194
|
-
define_method(element_name) do
|
195
|
-
ivar_name = "@#{element_name}"
|
196
|
-
ivar = instance_variable_get(ivar_name)
|
197
|
-
return ivar if ivar
|
198
|
-
instance_variable_set(ivar_name, TestCentricity::AppAlert.new(element_name, self, locator, :page))
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
def self.section(section_name, class_name, locator = 0)
|
203
|
-
class_eval(%(def #{section_name};@#{section_name} ||= #{class_name}.new("#{section_name}", self, #{locator}, :page);end))
|
204
|
-
end
|
205
|
-
|
206
|
-
def self.sections(section_hash)
|
207
|
-
section_hash.each do |section_name, class_name|
|
208
|
-
section(section_name, class_name)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
|
213
|
-
def open_portal
|
214
|
-
environment = Environ.current
|
215
|
-
|
216
|
-
Environ.portal_state = :open
|
217
|
-
end
|
218
|
-
|
219
|
-
def verify_page_exists
|
220
|
-
wait = Selenium::WebDriver::Wait.new(timeout: Environ.default_max_wait_time)
|
221
|
-
wait.until { exists? }
|
222
|
-
PageManager.current_page = self
|
223
|
-
rescue
|
224
|
-
raise "Could not find page_locator for screen object '#{self.class.name}' (#{@locator}) after #{Environ.default_max_wait_time} seconds"
|
225
|
-
end
|
226
|
-
|
227
|
-
def exists?
|
228
|
-
@locator.is_a?(Array) ? tries ||= 2 : tries ||= 1
|
229
|
-
if @locator.is_a?(Array)
|
230
|
-
loc = @locator[tries - 1]
|
231
|
-
find_element(loc.keys[0], loc.values[0])
|
232
|
-
else
|
233
|
-
find_element(@locator.keys[0], @locator.values[0])
|
18
|
+
def populate_data_fields(data, wait_time = nil)
|
19
|
+
timeout = wait_time.nil? ? 5 : wait_time
|
20
|
+
data.each do |data_field, data_param|
|
21
|
+
unless data_param.blank?
|
22
|
+
# make sure the intended UI target element is visible before trying to set its value
|
23
|
+
data_field.wait_until_visible(timeout)
|
24
|
+
if data_param == '!DELETE'
|
25
|
+
data_field.clear
|
26
|
+
else
|
27
|
+
case data_field.get_object_type
|
28
|
+
when :checkbox
|
29
|
+
data_field.set_checkbox_state(data_param.to_bool)
|
30
|
+
when :textfield
|
31
|
+
data_field.clear
|
32
|
+
data_field.set(data_param)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
234
36
|
end
|
235
|
-
true
|
236
|
-
rescue
|
237
|
-
retry if (tries -= 1) > 0
|
238
|
-
false
|
239
|
-
end
|
240
|
-
|
241
|
-
def wait_until_exists(seconds = nil)
|
242
|
-
timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
|
243
|
-
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
244
|
-
wait.until { exists? }
|
245
|
-
rescue
|
246
|
-
raise "Screen object #{self.class.name} not found after #{timeout} seconds" unless exists?
|
247
|
-
end
|
248
|
-
|
249
|
-
def wait_until_gone(seconds = nil)
|
250
|
-
timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
|
251
|
-
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
252
|
-
wait.until { !exists? }
|
253
|
-
rescue
|
254
|
-
raise "Screen object #{self.class.name} remained visible after #{timeout} seconds" if exists?
|
255
|
-
end
|
256
|
-
|
257
|
-
def navigate_to; end
|
258
|
-
|
259
|
-
def verify_page_ui; end
|
260
|
-
|
261
|
-
def load_page
|
262
|
-
navigate_to unless exists?
|
263
|
-
verify_page_exists
|
264
|
-
PageManager.current_page = self
|
265
37
|
end
|
266
38
|
|
267
|
-
|
268
|
-
|
269
39
|
def verify_ui_states(ui_states)
|
270
40
|
ui_states.each do |ui_object, object_states|
|
271
41
|
object_states.each do |property, state|
|
@@ -315,7 +85,7 @@ module TestCentricity
|
|
315
85
|
actual = ui_object.y_loc
|
316
86
|
end
|
317
87
|
error_msg = "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
|
318
|
-
ExceptionQueue.enqueue_comparison(state, actual, error_msg)
|
88
|
+
ExceptionQueue.enqueue_comparison(ui_object, state, actual, error_msg)
|
319
89
|
end
|
320
90
|
end
|
321
91
|
rescue ObjectNotFoundError => e
|
@@ -323,26 +93,5 @@ module TestCentricity
|
|
323
93
|
ensure
|
324
94
|
ExceptionQueue.post_exceptions
|
325
95
|
end
|
326
|
-
|
327
|
-
def populate_data_fields(data, wait_time = nil)
|
328
|
-
timeout = wait_time.nil? ? 5 : wait_time
|
329
|
-
data.each do |data_field, data_param|
|
330
|
-
unless data_param.blank?
|
331
|
-
# make sure the intended UI target element is visible before trying to set its value
|
332
|
-
data_field.wait_until_visible(timeout)
|
333
|
-
if data_param == '!DELETE'
|
334
|
-
data_field.clear
|
335
|
-
else
|
336
|
-
case data_field.get_object_type
|
337
|
-
when :checkbox
|
338
|
-
data_field.set_checkbox_state(data_param.to_bool)
|
339
|
-
when :textfield
|
340
|
-
data_field.clear
|
341
|
-
data_field.set("#{data_param}\t")
|
342
|
-
end
|
343
|
-
end
|
344
|
-
end
|
345
|
-
end
|
346
|
-
end
|
347
96
|
end
|
348
97
|
end
|