testcentricity_web 4.3.1 → 4.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -12
- data/LICENSE.md +1 -1
- data/README.md +1794 -697
- data/lib/devices/devices.yml +144 -216
- data/lib/testcentricity_web/browser_helper.rb +33 -4
- data/lib/testcentricity_web/data_objects/environment.rb +96 -13
- data/lib/testcentricity_web/exception_queue_helper.rb +5 -6
- data/lib/testcentricity_web/version.rb +1 -1
- data/lib/testcentricity_web/web_core/page_object.rb +53 -49
- data/lib/testcentricity_web/web_core/page_objects_helper.rb +20 -11
- data/lib/testcentricity_web/web_core/page_section.rb +31 -34
- data/lib/testcentricity_web/web_core/webdriver_helper.rb +379 -252
- data/lib/testcentricity_web/web_elements/audio.rb +6 -4
- data/lib/testcentricity_web/web_elements/button.rb +7 -4
- data/lib/testcentricity_web/web_elements/checkbox.rb +149 -147
- data/lib/testcentricity_web/web_elements/file_field.rb +38 -36
- data/lib/testcentricity_web/web_elements/image.rb +75 -70
- data/lib/testcentricity_web/web_elements/label.rb +6 -4
- data/lib/testcentricity_web/web_elements/link.rb +15 -13
- data/lib/testcentricity_web/web_elements/list.rb +171 -169
- data/lib/testcentricity_web/web_elements/media.rb +384 -379
- data/lib/testcentricity_web/web_elements/radio.rb +135 -133
- data/lib/testcentricity_web/web_elements/range.rb +16 -29
- data/lib/testcentricity_web/web_elements/select_list.rb +247 -245
- data/lib/testcentricity_web/web_elements/table.rb +575 -573
- data/lib/testcentricity_web/web_elements/textfield.rb +143 -139
- data/lib/testcentricity_web/web_elements/ui_element.rb +1171 -0
- data/lib/testcentricity_web/web_elements/video.rb +39 -37
- data/lib/testcentricity_web/world_extensions.rb +37 -4
- data/lib/testcentricity_web.rb +4 -23
- metadata +28 -80
- data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +0 -1148
@@ -1,299 +1,301 @@
|
|
1
1
|
module TestCentricity
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
module Elements
|
3
|
+
class SelectList < UIElement
|
4
|
+
attr_accessor :list_item
|
5
|
+
attr_accessor :selected_item
|
6
|
+
attr_accessor :list_trigger
|
7
|
+
attr_accessor :text_field
|
8
|
+
attr_accessor :options_list
|
9
|
+
attr_accessor :group_item
|
10
|
+
attr_accessor :group_heading
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
def initialize(name, parent, locator, context)
|
13
|
+
super
|
14
|
+
@type = :selectlist
|
15
|
+
list_spec = {
|
16
|
+
selected_item: "li[class*='result-selected']",
|
17
|
+
list_item: "li[class*='active-result']",
|
18
|
+
list_trigger: nil,
|
19
|
+
text_field: nil,
|
20
|
+
options_list: nil,
|
21
|
+
group_item: 'li.group-result',
|
22
|
+
group_heading: 'li.group-result'
|
23
|
+
}
|
24
|
+
define_list_elements(list_spec)
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
27
|
+
def define_list_elements(element_spec)
|
28
|
+
element_spec.each do |element, value|
|
29
|
+
case element
|
30
|
+
when :list_item
|
31
|
+
@list_item = value
|
32
|
+
when :selected_item
|
33
|
+
@selected_item = value
|
34
|
+
when :list_trigger
|
35
|
+
@list_trigger = value
|
36
|
+
when :text_field
|
37
|
+
@text_field = value
|
38
|
+
when :options_list
|
39
|
+
@options_list = value
|
40
|
+
when :group_item
|
41
|
+
@group_item = value
|
42
|
+
when :group_heading
|
43
|
+
@group_heading = value
|
44
|
+
else
|
45
|
+
raise "#{element} is not a recognized selectlist element"
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
|
-
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
50
|
+
# Select the specified option in a select box object. Accepts a String or Hash.
|
51
|
+
# Supports standard HTML select objects and Chosen select objects.
|
52
|
+
#
|
53
|
+
# @param option [String] text of option to select
|
54
|
+
# OR
|
55
|
+
# @param option [Hash] :value, :index, or :text of option to select
|
56
|
+
#
|
57
|
+
# @example
|
58
|
+
# province_select.choose_option('Alberta')
|
59
|
+
# province_select.choose_option(value: 'AB')
|
60
|
+
# state_select.choose_option(index: 24)
|
61
|
+
# state_select.choose_option(text: 'Maryland')
|
62
|
+
#
|
63
|
+
def choose_option(option)
|
64
|
+
@base_object, = find_element
|
65
|
+
object_not_found_exception(@base_object, 'SelectList')
|
65
66
|
|
66
|
-
|
67
|
+
trigger_list
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
69
|
+
unless @options_list.nil?
|
70
|
+
find_component(@options_list, 'drop menu')
|
71
|
+
raise "Could not find option #{option} to choose" unless first(:css, @list_item, minimum: 0, wait: 5)
|
71
72
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
else
|
77
|
-
if option.is_a?(Hash)
|
78
|
-
@base_object.first(:css, "#{@list_item}:nth-of-type(#{option[:index]})").click if option.key?(:index)
|
79
|
-
@base_object.first(:css, "#{@list_item}:nth-of-type(#{option[:value]})").click if option.key?(:value)
|
80
|
-
@base_object.first(:css, "#{@list_item}:nth-of-type(#{option[:text]})").click if option.key?(:text)
|
73
|
+
if option.is_a?(Array)
|
74
|
+
option.each do |item|
|
75
|
+
page.find(:css, @list_item, text: item.strip).click
|
76
|
+
end
|
81
77
|
else
|
82
|
-
|
83
|
-
|
84
|
-
|
78
|
+
if option.is_a?(Hash)
|
79
|
+
@base_object.first(:css, "#{@list_item}:nth-of-type(#{option[:index]})").click if option.key?(:index)
|
80
|
+
@base_object.first(:css, "#{@list_item}:nth-of-type(#{option[:value]})").click if option.key?(:value)
|
81
|
+
@base_object.first(:css, "#{@list_item}:nth-of-type(#{option[:text]})").click if option.key?(:text)
|
82
|
+
else
|
83
|
+
options = @base_object.all(@list_item).collect(&:text)
|
84
|
+
sleep(2) unless options.include?(option)
|
85
|
+
first(:css, @list_item, text: option).click
|
86
|
+
end
|
85
87
|
end
|
88
|
+
return
|
86
89
|
end
|
87
|
-
return
|
88
|
-
end
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
91
|
+
if first(:css, @list_item, minimum: 0, wait: 2)
|
92
|
+
if option.is_a?(Array)
|
93
|
+
option.each do |item|
|
94
|
+
page.find(:css, @list_item, text: item.strip).click
|
95
|
+
end
|
96
|
+
else
|
97
|
+
if option.is_a?(Hash)
|
98
|
+
page.find(:css, "#{@list_item}:nth-of-type(#{option[:index]})").click if option.key?(:index)
|
99
|
+
page.find(:css, "#{@list_item}:nth-of-type(#{option[:value]})").click if option.key?(:value)
|
100
|
+
page.find(:css, "#{@list_item}:nth-of-type(#{option[:text]})").click if option.key?(:text)
|
101
|
+
else
|
102
|
+
options = @base_object.all(@list_item).collect(&:text)
|
103
|
+
sleep(2) unless options.include?(option)
|
104
|
+
first(:css, @list_item, text: option).click
|
105
|
+
end
|
94
106
|
end
|
95
107
|
else
|
96
|
-
if option.is_a?(
|
97
|
-
|
98
|
-
|
99
|
-
|
108
|
+
if option.is_a?(Array)
|
109
|
+
option.each do |item|
|
110
|
+
select_item(@base_object, item)
|
111
|
+
end
|
100
112
|
else
|
101
|
-
|
102
|
-
sleep(2) unless options.include?(option)
|
103
|
-
first(:css, @list_item, text: option).click
|
113
|
+
select_item(@base_object, option)
|
104
114
|
end
|
105
115
|
end
|
106
|
-
else
|
107
|
-
if option.is_a?(Array)
|
108
|
-
option.each do |item|
|
109
|
-
select_item(@base_object, item)
|
110
|
-
end
|
111
|
-
else
|
112
|
-
select_item(@base_object, option)
|
113
|
-
end
|
114
116
|
end
|
115
|
-
end
|
116
117
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
118
|
+
def set(text)
|
119
|
+
raise "A 'text_field' list element must be defined before calling the 'set' method on a selectlist object" if @text_field.nil?
|
120
|
+
@base_object, = find_element
|
121
|
+
object_not_found_exception(@base_object, 'SelectList')
|
122
|
+
trigger_list
|
123
|
+
input = find_component(@text_field, 'text field')
|
124
|
+
input.set("#{text}\n")
|
125
|
+
end
|
125
126
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
127
|
+
# Return array of strings of all options in a select box object.
|
128
|
+
# Supports standard HTML select objects and Chosen select objects.
|
129
|
+
#
|
130
|
+
# @return [Array]
|
131
|
+
# @example
|
132
|
+
# all_colors = color_select.get_options
|
133
|
+
#
|
134
|
+
def get_options
|
135
|
+
@base_object, = find_element
|
136
|
+
object_not_found_exception(@base_object, 'SelectList')
|
137
|
+
if @options_list.nil?
|
138
|
+
if @base_object.first(:css, @list_item, minimum: 0, wait: 2)
|
139
|
+
@base_object.all(@list_item).collect(&:text)
|
140
|
+
else
|
141
|
+
@base_object.all('option', visible: :all).collect(&:text)
|
142
|
+
end
|
139
143
|
else
|
140
|
-
|
144
|
+
trigger_list
|
145
|
+
menu = find_component(@options_list, 'drop menu')
|
146
|
+
options = menu.all(@list_item, visible: true, minimum: 0, wait: 2).collect(&:text)
|
147
|
+
trigger_list
|
148
|
+
options
|
141
149
|
end
|
142
|
-
else
|
143
|
-
trigger_list
|
144
|
-
menu = find_component(@options_list, 'drop menu')
|
145
|
-
options = menu.all(@list_item, visible: true, minimum: 0, wait: 2).collect(&:text)
|
146
|
-
trigger_list
|
147
|
-
options
|
148
150
|
end
|
149
|
-
end
|
150
151
|
|
151
|
-
|
152
|
+
alias get_list_items get_options
|
152
153
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
154
|
+
# Return the number of options in a select box object.
|
155
|
+
# Supports standard HTML select objects and Chosen select objects.
|
156
|
+
#
|
157
|
+
# @return [Integer]
|
158
|
+
# @example
|
159
|
+
# num_colors = color_select.get_option_count
|
160
|
+
#
|
161
|
+
def get_option_count
|
162
|
+
@base_object, = find_element
|
163
|
+
object_not_found_exception(@base_object, 'SelectList')
|
164
|
+
if @options_list.nil?
|
165
|
+
if @base_object.first(:css, @list_item, minimum: 0, wait: 2)
|
166
|
+
@base_object.all(@list_item).count
|
167
|
+
else
|
168
|
+
@base_object.all('option', visible: :all).count
|
169
|
+
end
|
166
170
|
else
|
167
|
-
|
171
|
+
trigger_list
|
172
|
+
menu = find_component(@options_list, 'drop menu')
|
173
|
+
num_items = menu.all(@list_item, visible: true, minimum: 0, wait: 2).count
|
174
|
+
trigger_list
|
175
|
+
num_items
|
168
176
|
end
|
169
|
-
else
|
170
|
-
trigger_list
|
171
|
-
menu = find_component(@options_list, 'drop menu')
|
172
|
-
num_items = menu.all(@list_item, visible: true, minimum: 0, wait: 2).count
|
173
|
-
trigger_list
|
174
|
-
num_items
|
175
177
|
end
|
176
|
-
end
|
177
178
|
|
178
|
-
|
179
|
+
alias get_item_count get_option_count
|
179
180
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
181
|
+
# Return array of strings of all group headings in a select box object.
|
182
|
+
# Supports React and Chosen select objects.
|
183
|
+
#
|
184
|
+
# @return [Array]
|
185
|
+
# @example
|
186
|
+
# regions = team_select.get_group_headings
|
187
|
+
#
|
188
|
+
def get_group_headings
|
189
|
+
@base_object, = find_element
|
190
|
+
object_not_found_exception(@base_object, 'SelectList')
|
191
|
+
if @options_list.nil?
|
192
|
+
if @base_object.first(:css, @group_heading, minimum: 0, wait: 2)
|
193
|
+
@base_object.all(@group_heading).collect(&:text)
|
194
|
+
else
|
195
|
+
nil
|
196
|
+
end
|
193
197
|
else
|
194
|
-
|
198
|
+
trigger_list
|
199
|
+
menu = find_component(@options_list, 'drop menu')
|
200
|
+
groups = menu.all(@group_heading, visible: true, minimum: 0, wait: 2).collect(&:text)
|
201
|
+
trigger_list
|
202
|
+
groups
|
195
203
|
end
|
196
|
-
else
|
197
|
-
trigger_list
|
198
|
-
menu = find_component(@options_list, 'drop menu')
|
199
|
-
groups = menu.all(@group_heading, visible: true, minimum: 0, wait: 2).collect(&:text)
|
200
|
-
trigger_list
|
201
|
-
groups
|
202
204
|
end
|
203
|
-
end
|
204
205
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
206
|
+
# Return the number of groups in a select box object.
|
207
|
+
# Supports React and Chosen select objects.
|
208
|
+
#
|
209
|
+
# @return [Integer]
|
210
|
+
# @example
|
211
|
+
# num_regions = team_select.get_group_count
|
212
|
+
#
|
213
|
+
def get_group_count
|
214
|
+
@base_object, = find_element
|
215
|
+
object_not_found_exception(@base_object, 'SelectList')
|
216
|
+
if @options_list.nil?
|
217
|
+
if @base_object.first(:css, @group_item, minimum: 0, wait: 2)
|
218
|
+
@base_object.all(@group_item).count
|
219
|
+
else
|
220
|
+
0
|
221
|
+
end
|
218
222
|
else
|
219
|
-
|
223
|
+
trigger_list
|
224
|
+
menu = find_component(@options_list, 'drop menu')
|
225
|
+
num_items = menu.all(@group_item, visible: true, minimum: 0, wait: 2).count
|
226
|
+
trigger_list
|
227
|
+
num_items
|
220
228
|
end
|
221
|
-
else
|
222
|
-
trigger_list
|
223
|
-
menu = find_component(@options_list, 'drop menu')
|
224
|
-
num_items = menu.all(@group_item, visible: true, minimum: 0, wait: 2).count
|
225
|
-
trigger_list
|
226
|
-
num_items
|
227
229
|
end
|
228
|
-
end
|
229
230
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
231
|
+
def verify_options(expected, enqueue = false)
|
232
|
+
actual = get_options
|
233
|
+
if enqueue
|
234
|
+
ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list of options in list #{object_ref_message}")
|
235
|
+
else
|
236
|
+
assert_equal(expected, actual, "Expected list of options in list #{object_ref_message} to be #{expected} but found #{actual}")
|
237
|
+
end
|
236
238
|
end
|
237
|
-
end
|
238
239
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
else
|
257
|
-
index = get_attribute(:selectedIndex).to_i
|
258
|
-
if index >= 0
|
259
|
-
options = get_options
|
260
|
-
options[index]
|
240
|
+
# Return text of first selected option in a select box object.
|
241
|
+
# Supports standard HTML select objects and Chosen select objects.
|
242
|
+
#
|
243
|
+
# @return [String]
|
244
|
+
# @example
|
245
|
+
# current_color = color_select.get_selected_option
|
246
|
+
#
|
247
|
+
def get_selected_option
|
248
|
+
@base_object, = find_element
|
249
|
+
object_not_found_exception(@base_object, 'SelectList')
|
250
|
+
trigger_list unless @options_list.nil?
|
251
|
+
selection = if @base_object.first(:css, @list_item, minimum: 0, wait: 1, visible: :all)
|
252
|
+
@base_object.first(:css, @selected_item, wait: 1, visible: :all).text
|
253
|
+
elsif @base_object.first(:css, @selected_item, minimum: 0, wait: 1, visible: :all)
|
254
|
+
@base_object.first(:css, @selected_item, visible: :all).text
|
255
|
+
elsif @base_object.first('option[selected]', minimum: 0, wait: 1, visible: :all)
|
256
|
+
@base_object.first('option[selected]', wait: 1, visible: :all).text
|
261
257
|
else
|
262
|
-
|
258
|
+
index = get_attribute(:selectedIndex).to_i
|
259
|
+
if index >= 0
|
260
|
+
options = get_options
|
261
|
+
options[index]
|
262
|
+
else
|
263
|
+
''
|
264
|
+
end
|
263
265
|
end
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
end
|
266
|
+
trigger_list unless @options_list.nil?
|
267
|
+
selection
|
268
|
+
end
|
268
269
|
|
269
|
-
|
270
|
+
alias selected? get_selected_option
|
270
271
|
|
271
|
-
|
272
|
+
private
|
272
273
|
|
273
|
-
|
274
|
-
|
275
|
-
|
274
|
+
def select_item(obj, option)
|
275
|
+
if option.is_a?(Hash)
|
276
|
+
obj.find("option[value='#{option[:value]}']").click if option.key?(:value)
|
276
277
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
278
|
+
if option.key?(:index)
|
279
|
+
if @locator_type == :xpath
|
280
|
+
obj.find(:xpath, "option[#{option[:index]}]").select_option
|
281
|
+
else
|
282
|
+
obj.find(:css, "option:nth-child(#{option[:index]})").select_option
|
283
|
+
end
|
282
284
|
end
|
283
|
-
end
|
284
285
|
|
285
|
-
|
286
|
-
|
287
|
-
|
286
|
+
obj.select option[:text] if option.key?(:text)
|
287
|
+
else
|
288
|
+
obj.select(option, visible: :all)
|
289
|
+
end
|
288
290
|
end
|
289
|
-
end
|
290
291
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
292
|
+
def trigger_list
|
293
|
+
if @list_trigger.nil?
|
294
|
+
@base_object.click
|
295
|
+
else
|
296
|
+
trigger = find_component(@list_trigger, 'trigger')
|
297
|
+
trigger.click
|
298
|
+
end
|
297
299
|
end
|
298
300
|
end
|
299
301
|
end
|