Class: TestCentricity::ScreenSection
Instance Attribute Summary collapse
Class Method Summary
collapse
-
.alert(element_name, locator) ⇒ Object
-
.button(element_name, locator) ⇒ Object
-
.buttons(element_hash) ⇒ Object
-
.checkbox(element_name, locator) ⇒ Object
-
.checkboxes(element_hash) ⇒ Object
-
.element(element_name, locator) ⇒ Object
-
.elements(element_hash) ⇒ Object
-
.image(element_name, locator) ⇒ Object
-
.images(element_hash) ⇒ Object
-
.label(element_name, locator) ⇒ Object
-
.labels(element_hash) ⇒ Object
-
.list(element_name, locator) ⇒ Object
-
.lists(element_hash) ⇒ Object
-
.section(section_name, obj, locator = 0) ⇒ Object
-
.sections(section_hash) ⇒ Object
-
.selectlist(element_name, locator) ⇒ Object
-
.selectlists(element_hash) ⇒ Object
-
.switch(element_name, locator) ⇒ Object
-
.switches(element_hash) ⇒ Object
-
.textfield(element_name, locator) ⇒ Object
-
.textfields(element_hash) ⇒ Object
-
.trait(trait_name, &block) ⇒ Object
Instance Method Summary
collapse
#populate_data_fields, #verify_ui_states
Constructor Details
#initialize(name, parent, locator, context) ⇒ ScreenSection
Returns a new instance of ScreenSection.
13
14
15
16
17
18
19
20
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 13
def initialize(name, parent, locator, context)
@name = name
@parent = parent
@locator = locator
@context = context
@parent_list = nil
@list_index = nil
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
7
8
9
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 7
def context
@context
end
|
#list_index ⇒ Object
Returns the value of attribute list_index.
11
12
13
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 11
def list_index
@list_index
end
|
#locator ⇒ Object
Returns the value of attribute locator.
8
9
10
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 8
def locator
@locator
end
|
#name ⇒ Object
Returns the value of attribute name.
7
8
9
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 7
def name
@name
end
|
#parent ⇒ Object
Returns the value of attribute parent.
9
10
11
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 9
def parent
@parent
end
|
#parent_list ⇒ Object
Returns the value of attribute parent_list.
10
11
12
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 10
def parent_list
@parent_list
end
|
Class Method Details
.alert(element_name, locator) ⇒ Object
173
174
175
176
177
178
179
180
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 173
def self.alert(element_name, locator)
define_method(element_name) do
ivar_name = "@#{element_name}"
ivar = instance_variable_get(ivar_name)
return ivar if ivar
instance_variable_set(ivar_name, TestCentricity::AppAlert.new(element_name, self, locator, :page))
end
end
|
93
94
95
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 93
def self.button(element_name, locator)
define_section_element(element_name, TestCentricity::AppButton, locator)
end
|
97
98
99
100
101
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 97
def self.buttons(element_hash)
element_hash.each do |element_name, locator|
button(element_name, locator)
end
end
|
.checkbox(element_name, locator) ⇒ Object
123
124
125
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 123
def self.checkbox(element_name, locator)
define_section_element(element_name, TestCentricity::AppCheckBox, locator)
end
|
.checkboxes(element_hash) ⇒ Object
127
128
129
130
131
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 127
def self.checkboxes(element_hash)
element_hash.each do |element_name, locator|
checkbox(element_name, locator)
end
end
|
.element(element_name, locator) ⇒ Object
83
84
85
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 83
def self.element(element_name, locator)
define_section_element(element_name, TestCentricity::AppUIElement, locator)
end
|
.elements(element_hash) ⇒ Object
87
88
89
90
91
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 87
def self.elements(element_hash)
element_hash.each do |element_name, locator|
element(element_name, locator)
end
end
|
.image(element_name, locator) ⇒ Object
163
164
165
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 163
def self.image(element_name, locator)
define_section_element(element_name, TestCentricity::AppImage, locator)
end
|
.images(element_hash) ⇒ Object
167
168
169
170
171
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 167
def self.images(element_hash)
element_hash.each do |element_name, locator|
image(element_name, locator)
end
end
|
.label(element_name, locator) ⇒ Object
133
134
135
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 133
def self.label(element_name, locator)
define_section_element(element_name, TestCentricity::AppLabel, locator)
end
|
.labels(element_hash) ⇒ Object
137
138
139
140
141
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 137
def self.labels(element_hash)
element_hash.each do |element_name, locator|
label(element_name, locator)
end
end
|
.list(element_name, locator) ⇒ Object
143
144
145
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 143
def self.list(element_name, locator)
define_section_element(element_name, TestCentricity::AppList, locator)
end
|
.lists(element_hash) ⇒ Object
147
148
149
150
151
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 147
def self.lists(element_hash)
element_hash.each do |element_name, locator|
list(element_name, locator)
end
end
|
.section(section_name, obj, locator = 0) ⇒ Object
182
183
184
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 182
def self.section(section_name, obj, locator = 0)
define_section_element(section_name, obj, locator)
end
|
.sections(section_hash) ⇒ Object
186
187
188
189
190
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 186
def self.sections(section_hash)
section_hash.each do |section_name, class_name|
section(section_name, class_name)
end
end
|
.selectlist(element_name, locator) ⇒ Object
153
154
155
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 153
def self.selectlist(element_name, locator)
define_section_element(element_name, TestCentricity::AppSelectList, locator)
end
|
.selectlists(element_hash) ⇒ Object
157
158
159
160
161
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 157
def self.selectlists(element_hash)
element_hash.each do |element_name, locator|
selectlist(element_name, locator)
end
end
|
.switch(element_name, locator) ⇒ Object
113
114
115
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 113
def self.switch(element_name, locator)
define_section_element(element_name, TestCentricity::AppSwitch, locator)
end
|
.switches(element_hash) ⇒ Object
117
118
119
120
121
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 117
def self.switches(element_hash)
element_hash.each do |element_name, locator|
switch(element_name, locator)
end
end
|
.textfield(element_name, locator) ⇒ Object
103
104
105
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 103
def self.textfield(element_name, locator)
define_section_element(element_name, TestCentricity::AppTextField, locator)
end
|
.textfields(element_hash) ⇒ Object
107
108
109
110
111
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 107
def self.textfields(element_hash)
element_hash.each do |element_name, locator|
textfield(element_name, locator)
end
end
|
.trait(trait_name, &block) ⇒ Object
79
80
81
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 79
def self.trait(trait_name, &block)
define_method(trait_name.to_s, &block)
end
|
Instance Method Details
#click ⇒ Object
192
193
194
195
196
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 192
def click
section = find_section
section_not_found_exception(section)
section.click
end
|
#disabled? ⇒ Boolean
227
228
229
230
231
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 227
def disabled?
section = find_section
section_not_found_exception(section)
section.enabled?
end
|
#double_tap ⇒ Object
207
208
209
210
211
212
213
214
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 207
def double_tap
section = find_section
section_not_found_exception(section)
x = section.location.x
y = section.location.y
tap_action = Appium::TouchAction.new.double_tap(element: section, x: x, y: y)
tap_action.perform
end
|
#enabled? ⇒ Boolean
221
222
223
224
225
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 221
def enabled?
section = find_section
section_not_found_exception(section)
section.enabled?
end
|
#exists? ⇒ Boolean
216
217
218
219
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 216
def exists?
section = find_section
section != nil
end
|
#get_item_count ⇒ Object
53
54
55
56
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 53
def get_item_count
raise 'No parent list defined' if @parent_list.nil?
@parent_list.get_item_count
end
|
#get_list_items ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 58
def get_list_items
items = []
(1..get_item_count).each do |item|
set_list_index(nil, item)
items.push(get_value)
end
items
end
|
#get_locator ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 22
def get_locator
if @locator.zero? && defined?(section_locator)
my_locator = section_locator
else
my_locator = @locator
end
locators = []
if @context == :section && !@parent.nil?
locators.push(@parent.get_locator)
end
if @parent_list.nil?
locators.push(my_locator)
else
locators.push(@parent_list.get_locator)
if @list_index.nil?
locators.push(my_locator)
else
list_key = my_locator.keys[0]
list_value = "#{my_locator.values[0]}[#{@list_index}]"
locators.push( { list_key => list_value } )
end
end
locators
end
|
#get_name ⇒ Object
71
72
73
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 71
def get_name
@name
end
|
#get_object_type ⇒ Object
67
68
69
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 67
def get_object_type
:section
end
|
#height ⇒ Object
299
300
301
302
303
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 299
def height
section = find_section
section_not_found_exception(section)
section.size.height
end
|
#hidden? ⇒ Boolean
240
241
242
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 240
def hidden?
!visible?
end
|
#set_list_index(list, index = 1) ⇒ Object
48
49
50
51
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 48
def set_list_index(list, index = 1)
@parent_list = list unless list.nil?
@list_index = index
end
|
#set_parent(parent) ⇒ Object
75
76
77
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 75
def set_parent(parent)
@parent = parent
end
|
#tap ⇒ Object
198
199
200
201
202
203
204
205
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 198
def tap
section = find_section
section_not_found_exception(section)
x = section.location.x
y = section.location.y
tap_action = Appium::TouchAction.new.tap(element: section, x: x, y: y)
tap_action.perform
end
|
#visible? ⇒ Boolean
233
234
235
236
237
238
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 233
def visible?
section = find_section
return false if section.nil?
section.displayed?
end
|
#wait_until_exists(seconds = nil, post_exception = true) ⇒ Object
244
245
246
247
248
249
250
251
252
253
254
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 244
def wait_until_exists(seconds = nil, post_exception = true)
timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
wait.until { exists? }
rescue
if post_exception
raise "Could not find Section object '#{get_name}' (#{get_locator}) after #{timeout} seconds" unless exists?
else
exists?
end
end
|
#wait_until_gone(seconds = nil, post_exception = true) ⇒ Object
256
257
258
259
260
261
262
263
264
265
266
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 256
def wait_until_gone(seconds = nil, post_exception = true)
timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
wait.until { !exists? }
rescue
if post_exception
raise "Section object '#{get_name}' (#{get_locator}) remained visible after #{timeout} seconds" if exists?
else
exists?
end
end
|
#wait_until_hidden(seconds = nil, post_exception = true) ⇒ Object
280
281
282
283
284
285
286
287
288
289
290
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 280
def wait_until_hidden(seconds = nil, post_exception = true)
timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
wait.until { hidden? }
rescue
if post_exception
raise "Section object '#{get_name}' (#{get_locator}) remained visible after #{timeout} seconds" if visible?
else
visible?
end
end
|
#wait_until_visible(seconds = nil, post_exception = true) ⇒ Object
268
269
270
271
272
273
274
275
276
277
278
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 268
def wait_until_visible(seconds = nil, post_exception = true)
timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
wait.until { visible? }
rescue
if post_exception
raise "Could not find Section object '#{get_name}' (#{get_locator}) after #{timeout} seconds" unless visible?
else
visible?
end
end
|
#width ⇒ Object
293
294
295
296
297
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 293
def width
section = find_section
section_not_found_exception(section)
section.size.width
end
|
#x_loc ⇒ Object
305
306
307
308
309
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 305
def x_loc
section = find_section
section_not_found_exception(section)
section.location.x
end
|
#y_loc ⇒ Object
311
312
313
314
315
|
# File 'lib/testcentricity/app_core/screen_section.rb', line 311
def y_loc
section = find_section
section_not_found_exception(section)
section.location.y
end
|