testcentricity_web 0.6.5 → 0.6.6
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 +4 -4
- data/README.md +28 -28
- data/lib/testcentricity_web.rb +1 -0
- data/lib/testcentricity_web/elements/button.rb +11 -0
- data/lib/testcentricity_web/elements/checkbox.rb +44 -0
- data/lib/testcentricity_web/elements/file_field.rb +17 -0
- data/lib/testcentricity_web/elements/image.rb +11 -0
- data/lib/testcentricity_web/elements/label.rb +11 -0
- data/lib/testcentricity_web/elements/link.rb +11 -0
- data/lib/testcentricity_web/elements/select_list.rb +82 -0
- data/lib/testcentricity_web/elements/table.rb +264 -0
- data/lib/testcentricity_web/elements/textfield.rb +35 -0
- data/lib/testcentricity_web/page_objects_helper.rb +36 -9
- data/lib/testcentricity_web/page_sections_helper.rb +37 -9
- data/lib/testcentricity_web/siebel_open_ui_helper.rb +3 -3
- data/lib/testcentricity_web/ui_elements_helper.rb +12 -372
- data/lib/testcentricity_web/version.rb +1 -1
- metadata +11 -2
@@ -0,0 +1,35 @@
|
|
1
|
+
module TestCentricity
|
2
|
+
class TextField < UIElement
|
3
|
+
def initialize(parent, locator, context)
|
4
|
+
@parent = parent
|
5
|
+
@locator = locator
|
6
|
+
@context = context
|
7
|
+
@type = :textfield
|
8
|
+
@alt_locator = nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Is text field set to read-only?
|
13
|
+
#
|
14
|
+
# @return [Boolean]
|
15
|
+
# @example
|
16
|
+
# comments_field.read_only?
|
17
|
+
#
|
18
|
+
def read_only?
|
19
|
+
obj, _ = find_element
|
20
|
+
object_not_found_exception(obj, nil)
|
21
|
+
!!obj.native.attribute('readonly')
|
22
|
+
end
|
23
|
+
|
24
|
+
# Return maxlength character count of a text field.
|
25
|
+
#
|
26
|
+
# @return [Integer]
|
27
|
+
# @example
|
28
|
+
# max_num_chars = comments_field.get_max_length
|
29
|
+
#
|
30
|
+
def get_max_length
|
31
|
+
obj, _ = find_element
|
32
|
+
object_not_found_exception(obj, nil)
|
33
|
+
obj.native.attribute('maxlength')
|
34
|
+
end
|
35
|
+
end
|
@@ -28,7 +28,7 @@ module TestCentricity
|
|
28
28
|
# element :siebel_busy, "//html[contains(@class, 'siebui-busy')]"
|
29
29
|
#
|
30
30
|
def self.element(element_name, locator)
|
31
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::UIElement.new(self, "#{locator}", :page
|
31
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::UIElement.new(self, "#{locator}", :page);end))
|
32
32
|
end
|
33
33
|
|
34
34
|
# Declare and instantiate a button UI Element for this page object.
|
@@ -40,7 +40,7 @@ module TestCentricity
|
|
40
40
|
# button :login_button, "//input[@id='submit_button']"
|
41
41
|
#
|
42
42
|
def self.button(element_name, locator)
|
43
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
43
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Button.new(self, "#{locator}", :page);end))
|
44
44
|
end
|
45
45
|
|
46
46
|
# Declare and instantiate a text field UI Element for this page object.
|
@@ -52,7 +52,7 @@ module TestCentricity
|
|
52
52
|
# textfield :password_field, "consumer_password"
|
53
53
|
#
|
54
54
|
def self.textfield(element_name, locator)
|
55
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
55
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::TextField.new(self, "#{locator}", :page);end))
|
56
56
|
end
|
57
57
|
|
58
58
|
# Declare and instantiate a checkbox UI Element for this page object.
|
@@ -64,7 +64,7 @@ module TestCentricity
|
|
64
64
|
# checkbox :accept_terms_checkbox, "accept_terms_conditions"
|
65
65
|
#
|
66
66
|
def self.checkbox(element_name, locator)
|
67
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
67
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::CheckBox.new(self, "#{locator}", :page);end))
|
68
68
|
end
|
69
69
|
|
70
70
|
# Declare and instantiate a label UI Element for this page object.
|
@@ -76,7 +76,7 @@ module TestCentricity
|
|
76
76
|
# label :rollup_price_label, "//div[contains(@id, 'Rollup Item Price')]"
|
77
77
|
#
|
78
78
|
def self.label(element_name, locator)
|
79
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
79
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Label.new(self, "#{locator}", :page);end))
|
80
80
|
end
|
81
81
|
|
82
82
|
# Declare and instantiate a link UI Element for this page object.
|
@@ -88,7 +88,7 @@ module TestCentricity
|
|
88
88
|
# link :shopping_basket_link, "//a[@href='shopping_basket']"
|
89
89
|
#
|
90
90
|
def self.link(element_name, locator)
|
91
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
91
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Link.new(self, "#{locator}", :page);end))
|
92
92
|
end
|
93
93
|
|
94
94
|
# Declare and instantiate a table UI Element for this page object.
|
@@ -99,7 +99,7 @@ module TestCentricity
|
|
99
99
|
# table :payments_table, "//table[@class='payments_table']"
|
100
100
|
#
|
101
101
|
def self.table(element_name, locator)
|
102
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
102
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Table.new(self, "#{locator}", :page);end))
|
103
103
|
end
|
104
104
|
|
105
105
|
# Declare and instantiate a select list UI Element for this page object.
|
@@ -111,7 +111,7 @@ module TestCentricity
|
|
111
111
|
# selectlist :gender_select, "//select[@id='customer_gender']"
|
112
112
|
#
|
113
113
|
def self.selectlist(element_name, locator)
|
114
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
114
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::SelectList.new(self, "#{locator}", :page);end))
|
115
115
|
end
|
116
116
|
|
117
117
|
# Declare and instantiate an image UI Element for this page object.
|
@@ -123,7 +123,18 @@ module TestCentricity
|
|
123
123
|
# image :corporate_logo_image, "//img[@alt='MyCompany_logo']"
|
124
124
|
#
|
125
125
|
def self.image(element_name, locator)
|
126
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
126
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Image.new(self, "#{locator}", :page);end))
|
127
|
+
end
|
128
|
+
|
129
|
+
# Declare and instantiate a File Field UI Element for this page object.
|
130
|
+
#
|
131
|
+
# @param element_name [Symbol] name of file field object (as a symbol)
|
132
|
+
# @param locator [String] css selector or xpath expression that uniquely identifies object
|
133
|
+
# @example
|
134
|
+
# filefield :attach_file, "s_SweFileName"
|
135
|
+
#
|
136
|
+
def self.filefield(element_name, locator)
|
137
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::FileField.new(self, "#{locator}", :page);end))
|
127
138
|
end
|
128
139
|
|
129
140
|
# Instantiate a PageSection object for this page object.
|
@@ -248,6 +259,22 @@ module TestCentricity
|
|
248
259
|
ExceptionQueue.post_exceptions
|
249
260
|
end
|
250
261
|
|
262
|
+
# Populate the specified UI elements on this page with the associated data from a Hash passed as an argument. Data
|
263
|
+
# values must be in the form of a String for textfield and select list controls. For checkbox and radio buttons,
|
264
|
+
# data must either be a Boolean or a String that evaluates to a Boolean value (Yes, No, 1, 0, true, false)
|
265
|
+
#
|
266
|
+
# @param data [Hash] UI element(s) and associated data to be entered
|
267
|
+
# @example
|
268
|
+
# data = { prefix_select => 'Ms',
|
269
|
+
# first_name_field => 'Priscilla',
|
270
|
+
# last_name_field => 'Pumperknickle',
|
271
|
+
# gender_select => 'Female',
|
272
|
+
# dob_field => '11/18/1976',
|
273
|
+
# email_field => 'p.pumperknickle4876@google.com',
|
274
|
+
# mailing_list_check => 'Yes'
|
275
|
+
# }
|
276
|
+
# registration_page.populate_data_fields(data)
|
277
|
+
#
|
251
278
|
def populate_data_fields(data)
|
252
279
|
data.each do | data_field, data_param |
|
253
280
|
unless data_param.blank?
|
@@ -36,7 +36,7 @@ module TestCentricity
|
|
36
36
|
# element :basket_header, "div.basket_header"
|
37
37
|
#
|
38
38
|
def self.element(element_name, locator)
|
39
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::UIElement.new(self, "#{locator}", :section
|
39
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::UIElement.new(self, "#{locator}", :section);end))
|
40
40
|
end
|
41
41
|
|
42
42
|
# Declare and instantiate a button UI Element for this page section.
|
@@ -48,7 +48,7 @@ module TestCentricity
|
|
48
48
|
# button :login_button, "//input[@id='submit_button']"
|
49
49
|
#
|
50
50
|
def self.button(element_name, locator)
|
51
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
51
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Button.new(self, "#{locator}", :section);end))
|
52
52
|
end
|
53
53
|
|
54
54
|
# Declare and instantiate a text field UI Element for this page section.
|
@@ -60,7 +60,7 @@ module TestCentricity
|
|
60
60
|
# textfield :password_field, "consumer_password"
|
61
61
|
#
|
62
62
|
def self.textfield(element_name, locator)
|
63
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
63
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::TextField.new(self, "#{locator}", :section);end))
|
64
64
|
end
|
65
65
|
|
66
66
|
# Declare and instantiate a checkbox UI Element for this page section.
|
@@ -72,7 +72,7 @@ module TestCentricity
|
|
72
72
|
# checkbox :accept_terms_checkbox, "accept_terms_conditions"
|
73
73
|
#
|
74
74
|
def self.checkbox(element_name, locator)
|
75
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
75
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::CheckBox.new(self, "#{locator}", :section);end))
|
76
76
|
end
|
77
77
|
|
78
78
|
# Declare and instantiate a label UI Element for this page section.
|
@@ -84,7 +84,7 @@ module TestCentricity
|
|
84
84
|
# label :rollup_price_label, "//div[contains(@id, 'Rollup Item Price')]"
|
85
85
|
#
|
86
86
|
def self.label(element_name, locator)
|
87
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
87
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Label.new(self, "#{locator}", :section);end))
|
88
88
|
end
|
89
89
|
|
90
90
|
# Declare and instantiate a link UI Element for this page section.
|
@@ -96,7 +96,7 @@ module TestCentricity
|
|
96
96
|
# link :shopping_basket_link, "//a[@href='shopping_basket']"
|
97
97
|
#
|
98
98
|
def self.link(element_name, locator)
|
99
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
99
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Link.new(self, "#{locator}", :section);end))
|
100
100
|
end
|
101
101
|
|
102
102
|
# Declare and instantiate a table UI Element for this page section.
|
@@ -107,7 +107,7 @@ module TestCentricity
|
|
107
107
|
# table :payments_table, "//table[@class='payments_table']"
|
108
108
|
#
|
109
109
|
def self.table(element_name, locator)
|
110
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
110
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Table.new(self, "#{locator}", :section);end))
|
111
111
|
end
|
112
112
|
|
113
113
|
# Declare and instantiate a select list UI Element for this page section.
|
@@ -119,7 +119,7 @@ module TestCentricity
|
|
119
119
|
# selectlist :gender_select, "//select[@id='customer_gender']"
|
120
120
|
#
|
121
121
|
def self.selectlist(element_name, locator)
|
122
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
122
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::SelectList.new(self, "#{locator}", :section);end))
|
123
123
|
end
|
124
124
|
|
125
125
|
# Declare and instantiate an image UI Element for this page section.
|
@@ -131,7 +131,18 @@ module TestCentricity
|
|
131
131
|
# image :corporate_logo_image, "//img[@alt='MyCompany_logo']"
|
132
132
|
#
|
133
133
|
def self.image(element_name, locator)
|
134
|
-
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::
|
134
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::Image.new(self, "#{locator}", :section);end))
|
135
|
+
end
|
136
|
+
|
137
|
+
# Declare and instantiate a File Field UI Element for this page object.
|
138
|
+
#
|
139
|
+
# @param element_name [Symbol] name of file field object (as a symbol)
|
140
|
+
# @param locator [String] css selector or xpath expression that uniquely identifies object
|
141
|
+
# @example
|
142
|
+
# filefield :attach_file, "s_SweFileName"
|
143
|
+
#
|
144
|
+
def self.filefield(element_name, locator)
|
145
|
+
class_eval(%Q(def #{element_name.to_s};@#{element_name.to_s} ||= TestCentricity::FileField.new(self, "#{locator}", :section);end))
|
135
146
|
end
|
136
147
|
|
137
148
|
# Instantiate a PageSection object within this PageSection object.
|
@@ -264,6 +275,23 @@ module TestCentricity
|
|
264
275
|
ExceptionQueue.post_exceptions
|
265
276
|
end
|
266
277
|
|
278
|
+
# Populate the specified UI elements in this Section object with the associated data from a Hash passed as an
|
279
|
+
# argument. Data values must be in the form of a String for textfield and select list controls. For checkbox
|
280
|
+
# and radio buttons, data must either be a Boolean or a String that evaluates to a Boolean value (Yes, No, 1,
|
281
|
+
# 0, true, false)
|
282
|
+
#
|
283
|
+
# @param data [Hash] UI element(s) and associated data to be entered
|
284
|
+
# @example
|
285
|
+
# data = { prefix_select => 'Mr.',
|
286
|
+
# first_name_field => 'Ignatious',
|
287
|
+
# last_name_field => 'Snickelfritz',
|
288
|
+
# gender_select => 'Male',
|
289
|
+
# dob_field => '12/14/1957',
|
290
|
+
# organ_donor_check => 'Yes',
|
291
|
+
# dnr_on_file_check => 'Yes'
|
292
|
+
# }
|
293
|
+
# patient_record_page.personal_info_widget.populate_data_fields(data)
|
294
|
+
#
|
267
295
|
def populate_data_fields(data)
|
268
296
|
data.each do | data_field, data_param |
|
269
297
|
unless data_param.blank?
|
@@ -4,7 +4,7 @@ module TestCentricity
|
|
4
4
|
#
|
5
5
|
# @param state [Boolean] true = checked / false = unchecked
|
6
6
|
# @example
|
7
|
-
# remember_me_checkbox.
|
7
|
+
# remember_me_checkbox.set_siebel_checkbox_state(true)
|
8
8
|
#
|
9
9
|
def set_siebel_checkbox_state(state)
|
10
10
|
obj, _ = find_element
|
@@ -18,7 +18,7 @@ module TestCentricity
|
|
18
18
|
#
|
19
19
|
# @param option [String] text of option to select
|
20
20
|
# @example
|
21
|
-
# country_select.
|
21
|
+
# country_select.choose_siebel_option('Cayman Islands')
|
22
22
|
#
|
23
23
|
def choose_siebel_option(option)
|
24
24
|
Capybara.wait_on_first_by_default = true
|
@@ -30,7 +30,7 @@ module TestCentricity
|
|
30
30
|
#
|
31
31
|
# @return [Array]
|
32
32
|
# @example
|
33
|
-
# all_countries = country_select.
|
33
|
+
# all_countries = country_select.get_siebel_options
|
34
34
|
#
|
35
35
|
def get_siebel_options
|
36
36
|
invoke_siebel_popup
|
@@ -25,11 +25,11 @@ module TestCentricity
|
|
25
25
|
attr_reader :parent, :locator, :context, :type
|
26
26
|
attr_accessor :alt_locator
|
27
27
|
|
28
|
-
def initialize(parent, locator, context
|
28
|
+
def initialize(parent, locator, context)
|
29
29
|
@parent = parent
|
30
30
|
@locator = locator
|
31
31
|
@context = context
|
32
|
-
@type =
|
32
|
+
@type = nil
|
33
33
|
@alt_locator = nil
|
34
34
|
end
|
35
35
|
|
@@ -183,62 +183,6 @@ module TestCentricity
|
|
183
183
|
obj.disabled?
|
184
184
|
end
|
185
185
|
|
186
|
-
# Is text field set to read-only?
|
187
|
-
#
|
188
|
-
# @return [Boolean]
|
189
|
-
# @example
|
190
|
-
# comments_field.read_only?
|
191
|
-
#
|
192
|
-
def read_only?
|
193
|
-
obj, _ = find_element
|
194
|
-
object_not_found_exception(obj, nil)
|
195
|
-
!!obj.native.attribute('readonly')
|
196
|
-
end
|
197
|
-
|
198
|
-
# Return maxlength character count of a text field.
|
199
|
-
#
|
200
|
-
# @return [Integer]
|
201
|
-
# @example
|
202
|
-
# max_num_chars = comments_field.get_max_length
|
203
|
-
#
|
204
|
-
def get_max_length
|
205
|
-
obj, _ = find_element
|
206
|
-
object_not_found_exception(obj, nil)
|
207
|
-
obj.native.attribute('maxlength')
|
208
|
-
end
|
209
|
-
|
210
|
-
# Is checkbox checked?
|
211
|
-
#
|
212
|
-
# @return [Boolean]
|
213
|
-
# @example
|
214
|
-
# remember_me_checkbox.checked?
|
215
|
-
#
|
216
|
-
def checked?
|
217
|
-
obj, _ = find_element
|
218
|
-
object_not_found_exception(obj, 'Checkbox')
|
219
|
-
obj.checked?
|
220
|
-
end
|
221
|
-
|
222
|
-
# Set the check state of a checkbox object.
|
223
|
-
#
|
224
|
-
# @param state [Boolean] true = checked / false = unchecked
|
225
|
-
# @example
|
226
|
-
# remember_me_checkbox.set_checkbox_state(true)
|
227
|
-
#
|
228
|
-
def set_checkbox_state(state)
|
229
|
-
obj, _ = find_element
|
230
|
-
object_not_found_exception(obj, 'Checkbox')
|
231
|
-
invalid_object_type_exception(obj, 'checkbox')
|
232
|
-
obj.set(state)
|
233
|
-
end
|
234
|
-
|
235
|
-
def verify_check_state(state, enqueue = false)
|
236
|
-
actual = checked?
|
237
|
-
enqueue ?
|
238
|
-
ExceptionQueue.enqueue_assert_equal(state, actual, "Expected #{@locator}") :
|
239
|
-
assert_equal(state, actual, "Expected #{@locator} to be #{state} but found #{actual} instead")
|
240
|
-
end
|
241
|
-
|
242
186
|
# Wait until the object exists, or until the specified wait time has expired.
|
243
187
|
#
|
244
188
|
# @param seconds [Integer or Float] wait time in seconds
|
@@ -331,313 +275,6 @@ module TestCentricity
|
|
331
275
|
obj.drag_by(right_offset, down_offset)
|
332
276
|
end
|
333
277
|
|
334
|
-
def attach_file(file_path)
|
335
|
-
Capybara.ignore_hidden_elements = false
|
336
|
-
page.attach_file(@locator, file_path)
|
337
|
-
Capybara.ignore_hidden_elements = true
|
338
|
-
end
|
339
|
-
|
340
|
-
# Select the specified option in a select box object.
|
341
|
-
# Supports standard HTML select objects and Chosen select objects.
|
342
|
-
#
|
343
|
-
# @param option [String] text of option to select
|
344
|
-
# @example
|
345
|
-
# province_select.choose_option('Nova Scotia')
|
346
|
-
#
|
347
|
-
def choose_option(option)
|
348
|
-
obj, _ = find_element
|
349
|
-
object_not_found_exception(obj, nil)
|
350
|
-
obj.click
|
351
|
-
if first(:css, 'li.active-result')
|
352
|
-
if option.is_a?(Array)
|
353
|
-
option.each do |item|
|
354
|
-
page.find(:css, 'li.active-result', text: item.strip).click
|
355
|
-
end
|
356
|
-
else
|
357
|
-
first(:css, 'li.active-result', text: option).click
|
358
|
-
end
|
359
|
-
else
|
360
|
-
if option.is_a?(Array)
|
361
|
-
option.each do |item|
|
362
|
-
obj.select item
|
363
|
-
end
|
364
|
-
else
|
365
|
-
obj.select option
|
366
|
-
end
|
367
|
-
end
|
368
|
-
end
|
369
|
-
|
370
|
-
# Return array of strings of all options in a select box object.
|
371
|
-
# Supports standard HTML select objects and Chosen select objects.
|
372
|
-
#
|
373
|
-
# @return [Array]
|
374
|
-
# @example
|
375
|
-
# all_colors = color_select.get_options
|
376
|
-
#
|
377
|
-
def get_options
|
378
|
-
obj, _ = find_element
|
379
|
-
object_not_found_exception(obj, nil)
|
380
|
-
if first(:css, 'li.active-result')
|
381
|
-
obj.all('li.active-result').collect(&:text)
|
382
|
-
else
|
383
|
-
obj.all('option').collect(&:text)
|
384
|
-
end
|
385
|
-
end
|
386
|
-
|
387
|
-
def verify_options(expected, enqueue = false)
|
388
|
-
actual = get_options
|
389
|
-
enqueue ?
|
390
|
-
ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list of options in list #{@locator}") :
|
391
|
-
assert_equal(expected, actual, "Expected list of options in list #{@locator} to be #{expected} but found #{actual}")
|
392
|
-
end
|
393
|
-
|
394
|
-
# Return text of first selected option in a select box object.
|
395
|
-
# Supports standard HTML select objects and Chosen select objects.
|
396
|
-
#
|
397
|
-
# @return [String]
|
398
|
-
# @example
|
399
|
-
# current_color = color_select.get_selected_option
|
400
|
-
#
|
401
|
-
def get_selected_option
|
402
|
-
obj, _ = find_element
|
403
|
-
object_not_found_exception(obj, nil)
|
404
|
-
if first(:css, 'li.active-result')
|
405
|
-
obj.first("//li[contains(@class, 'result-selected')]").text
|
406
|
-
else
|
407
|
-
obj.first('option[selected]').text
|
408
|
-
end
|
409
|
-
end
|
410
|
-
|
411
|
-
# Return number of rows in a table object.
|
412
|
-
#
|
413
|
-
# @return [Integer]
|
414
|
-
# @example
|
415
|
-
# num_rows = list_table.get_row_count
|
416
|
-
#
|
417
|
-
def get_row_count
|
418
|
-
wait_until_exists(5)
|
419
|
-
row_count = page.all(:xpath, "#{@locator}/tbody/tr", :visible => :all).count
|
420
|
-
row_count
|
421
|
-
end
|
422
|
-
|
423
|
-
# Return number of columns in a table object.
|
424
|
-
#
|
425
|
-
# @return [Integer]
|
426
|
-
# @example
|
427
|
-
# num_columns = list_table.get_column_count
|
428
|
-
#
|
429
|
-
def get_column_count
|
430
|
-
row_count = get_row_count
|
431
|
-
if row_count == 0
|
432
|
-
page.all(:xpath, "#{@locator}/thead/tr/th", :visible => :all).count
|
433
|
-
else
|
434
|
-
(row_count == 1) ?
|
435
|
-
page.all(:xpath, "#{@locator}/tbody/tr/td", :visible => :all).count :
|
436
|
-
page.all(:xpath, "#{@locator}/tbody/tr[2]/td", :visible => :all).count
|
437
|
-
end
|
438
|
-
end
|
439
|
-
|
440
|
-
# Click in the specified cell in a table object.
|
441
|
-
#
|
442
|
-
# @param row [Integer] row number
|
443
|
-
# @param column [Integer] column number
|
444
|
-
# @example
|
445
|
-
# list_table.click_table_cell(3, 5)
|
446
|
-
#
|
447
|
-
def click_table_cell(row, column)
|
448
|
-
row_count = get_row_count
|
449
|
-
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count
|
450
|
-
column_count = get_column_count
|
451
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count
|
452
|
-
set_table_cell_locator(row, column)
|
453
|
-
click
|
454
|
-
clear_alt_locator
|
455
|
-
end
|
456
|
-
|
457
|
-
# Double-click in the specified cell in a table object.
|
458
|
-
#
|
459
|
-
# @param row [Integer] row number
|
460
|
-
# @param column [Integer] column number
|
461
|
-
# @example
|
462
|
-
# list_table.double_click_table_cell(3, 5)
|
463
|
-
#
|
464
|
-
def double_click_table_cell(row, column)
|
465
|
-
row_count = get_row_count
|
466
|
-
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count
|
467
|
-
column_count = get_column_count
|
468
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count
|
469
|
-
set_table_cell_locator(row, column)
|
470
|
-
double_click
|
471
|
-
clear_alt_locator
|
472
|
-
end
|
473
|
-
|
474
|
-
# Click the link object embedded within the specified cell in a table object.
|
475
|
-
#
|
476
|
-
# @param row [Integer] row number
|
477
|
-
# @param column [Integer] column number
|
478
|
-
# @example
|
479
|
-
# list_table.click_table_cell_link(3, 1)
|
480
|
-
#
|
481
|
-
def click_table_cell_link(row, column)
|
482
|
-
row_count = get_row_count
|
483
|
-
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count
|
484
|
-
column_count = get_column_count
|
485
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count
|
486
|
-
set_table_cell_locator(row, column)
|
487
|
-
saved_locator = @alt_locator
|
488
|
-
set_alt_locator("#{@alt_locator}/a")
|
489
|
-
set_alt_locator("#{saved_locator}/span/a") unless exists?
|
490
|
-
# if link not present, check for text entry fields and try to dismiss by tabbing out
|
491
|
-
unless exists?
|
492
|
-
set_alt_locator("#{saved_locator}/input")
|
493
|
-
set_alt_locator("#{saved_locator}/textarea") unless exists?
|
494
|
-
send_keys(:tab) if exists?
|
495
|
-
set_alt_locator("#{saved_locator}/a")
|
496
|
-
set_alt_locator("#{saved_locator}/span/a") unless exists?
|
497
|
-
send_keys(:tab) unless exists?
|
498
|
-
end
|
499
|
-
wait_until_exists(1)
|
500
|
-
click
|
501
|
-
clear_alt_locator
|
502
|
-
end
|
503
|
-
|
504
|
-
def get_table_row(row)
|
505
|
-
columns = []
|
506
|
-
row_count = get_row_count
|
507
|
-
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count
|
508
|
-
column_count = get_column_count
|
509
|
-
(1..column_count).each do |column|
|
510
|
-
value = ''
|
511
|
-
set_table_cell_locator(row, column)
|
512
|
-
saved_locator = @alt_locator
|
513
|
-
set_alt_locator("#{saved_locator}/input")
|
514
|
-
unless exists?
|
515
|
-
set_alt_locator("#{saved_locator}/textarea")
|
516
|
-
unless exists?
|
517
|
-
set_alt_locator(saved_locator)
|
518
|
-
end
|
519
|
-
end
|
520
|
-
value = get_value if exists?
|
521
|
-
columns.push(value)
|
522
|
-
end
|
523
|
-
clear_alt_locator
|
524
|
-
columns
|
525
|
-
end
|
526
|
-
|
527
|
-
def get_row_data(row)
|
528
|
-
row_count = get_row_count
|
529
|
-
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count
|
530
|
-
(row > 1) ?
|
531
|
-
set_alt_locator("#{@locator}/tbody/tr[#{row}]") :
|
532
|
-
set_alt_locator("#{@locator}/tbody/tr")
|
533
|
-
value = get_value if exists?
|
534
|
-
clear_alt_locator
|
535
|
-
value
|
536
|
-
end
|
537
|
-
|
538
|
-
# Return text contained in specified cell of a table object.
|
539
|
-
#
|
540
|
-
# @param row [Integer] row number
|
541
|
-
# @param column [Integer] column number
|
542
|
-
# @return [String] value of table cell
|
543
|
-
# @example
|
544
|
-
# list_table.get_table_cell(4, 5)
|
545
|
-
#
|
546
|
-
def get_table_cell(row, column)
|
547
|
-
row_count = get_row_count
|
548
|
-
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count
|
549
|
-
column_count = get_column_count
|
550
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count
|
551
|
-
set_table_cell_locator(row, column)
|
552
|
-
saved_locator = @alt_locator
|
553
|
-
set_alt_locator("#{saved_locator}/input")
|
554
|
-
unless exists?
|
555
|
-
set_alt_locator("#{saved_locator}/textarea")
|
556
|
-
unless exists?
|
557
|
-
set_alt_locator(saved_locator)
|
558
|
-
end
|
559
|
-
end
|
560
|
-
value = get_value
|
561
|
-
clear_alt_locator
|
562
|
-
value
|
563
|
-
end
|
564
|
-
|
565
|
-
def verify_table_cell(row, column, expected, enqueue = false)
|
566
|
-
actual = get_table_cell(row, column)
|
567
|
-
enqueue ?
|
568
|
-
ExceptionQueue.enqueue_assert_equal(expected.strip, actual.strip, "Expected #{@locator} row #{row}/column #{column}") :
|
569
|
-
assert_equal(expected.strip, actual.strip, "Expected #{@locator} row #{row}/column #{column} to display '#{expected}' but found '#{actual}'")
|
570
|
-
end
|
571
|
-
|
572
|
-
# Set the value of the specified cell in a table object.
|
573
|
-
#
|
574
|
-
# @param row [Integer] row number
|
575
|
-
# @param column [Integer] column number
|
576
|
-
# @param value [String] text to set
|
577
|
-
# @example
|
578
|
-
# list_table.set_table_cell(3, 1, 'Ontario')
|
579
|
-
#
|
580
|
-
def set_table_cell(row, column, value)
|
581
|
-
row_count = get_row_count
|
582
|
-
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count
|
583
|
-
# column_count = get_column_count
|
584
|
-
# raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count
|
585
|
-
set_table_cell_locator(row, column)
|
586
|
-
click if exists?
|
587
|
-
saved_locator = @alt_locator
|
588
|
-
set_alt_locator("#{saved_locator}/input")
|
589
|
-
set_alt_locator("#{saved_locator}/textarea") unless exists?
|
590
|
-
set(value)
|
591
|
-
clear_alt_locator
|
592
|
-
end
|
593
|
-
|
594
|
-
def populate_table_row(row, data)
|
595
|
-
wait_until_exists(2)
|
596
|
-
data.each do | column, data_param |
|
597
|
-
unless data_param.blank?
|
598
|
-
if data_param == '!DELETE'
|
599
|
-
set_table_cell(row, column, '')
|
600
|
-
else
|
601
|
-
set_table_cell(row, column, data_param)
|
602
|
-
end
|
603
|
-
end
|
604
|
-
end
|
605
|
-
end
|
606
|
-
|
607
|
-
def click_header_column(column)
|
608
|
-
column_count = get_column_count
|
609
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{@locator}" if column > column_count
|
610
|
-
(column > 1) ?
|
611
|
-
set_alt_locator("#{@locator}/thead/tr/th[#{column}]") :
|
612
|
-
set_alt_locator("#{@locator}/thead/tr/th")
|
613
|
-
click
|
614
|
-
clear_alt_locator
|
615
|
-
end
|
616
|
-
|
617
|
-
def get_header_column(column)
|
618
|
-
column_count = get_column_count
|
619
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{@locator}" if column > column_count
|
620
|
-
(column > 1) ?
|
621
|
-
set_alt_locator("#{@locator}/thead/tr/th[#{column}]") :
|
622
|
-
set_alt_locator("#{@locator}/thead/tr/th")
|
623
|
-
value = get_value
|
624
|
-
clear_alt_locator
|
625
|
-
value
|
626
|
-
end
|
627
|
-
|
628
|
-
def get_header_columns
|
629
|
-
columns = []
|
630
|
-
column_count = get_column_count
|
631
|
-
(1..column_count).each do |column|
|
632
|
-
(column > 1) ?
|
633
|
-
set_alt_locator("#{@locator}/thead/tr/th[#{column}]") :
|
634
|
-
set_alt_locator("#{@locator}/thead/tr/th")
|
635
|
-
columns.push(get_value)
|
636
|
-
end
|
637
|
-
clear_alt_locator
|
638
|
-
columns
|
639
|
-
end
|
640
|
-
|
641
278
|
def get_list_items(item_locator)
|
642
279
|
obj, _ = find_element
|
643
280
|
object_not_found_exception(obj, nil)
|
@@ -676,12 +313,15 @@ module TestCentricity
|
|
676
313
|
raise "#{locator} is not a #{obj_type} element"
|
677
314
|
end
|
678
315
|
end
|
679
|
-
|
680
|
-
def set_table_cell_locator(row, column)
|
681
|
-
row_spec = "#{@locator}/tbody/tr"
|
682
|
-
row_spec = "#{row_spec}[#{row}]" if row > 1
|
683
|
-
column_spec = "/td[#{column}]"
|
684
|
-
set_alt_locator("#{row_spec}#{column_spec}")
|
685
|
-
end
|
686
316
|
end
|
687
317
|
end
|
318
|
+
|
319
|
+
require 'testcentricity_web/elements/button'
|
320
|
+
require 'testcentricity_web/elements/checkbox'
|
321
|
+
require 'testcentricity_web/elements/file_field'
|
322
|
+
require 'testcentricity_web/elements/image'
|
323
|
+
require 'testcentricity_web/elements/label'
|
324
|
+
require 'testcentricity_web/elements/link'
|
325
|
+
require 'testcentricity_web/elements/select_list'
|
326
|
+
require 'testcentricity_web/elements/table'
|
327
|
+
require 'testcentricity_web/elements/textfield'
|