testcentricity_web 4.3.0 → 4.4.0
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/CHANGELOG.md +46 -11
- data/LICENSE.md +1 -1
- data/README.md +1931 -801
- 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 -15
- 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 +416 -288
- 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 +27 -79
- data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +0 -1148
@@ -1,341 +1,378 @@
|
|
1
1
|
module TestCentricity
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
case @locator_type
|
30
|
-
when :xpath
|
31
|
-
table_spec[:tree_expand] = "div/div[contains(@class, 'tree-plus treeclick')]"
|
32
|
-
table_spec[:tree_collapse] = "div/div[contains(@class, 'tree-minus treeclick')]"
|
33
|
-
when :css
|
34
|
-
table_spec[:tree_expand] = "div > div[class*='tree-plus treeclick']"
|
35
|
-
table_spec[:tree_collapse] = "div > div[class*='tree-minus treeclick']"
|
36
|
-
end
|
37
|
-
define_table_elements(table_spec)
|
38
|
-
end
|
2
|
+
module Elements
|
3
|
+
class Table < UIElement
|
4
|
+
attr_accessor :table_body
|
5
|
+
attr_accessor :table_section
|
6
|
+
attr_accessor :table_row
|
7
|
+
attr_accessor :table_column
|
8
|
+
attr_accessor :table_header
|
9
|
+
attr_accessor :header_row
|
10
|
+
attr_accessor :header_column
|
11
|
+
attr_accessor :row_header
|
12
|
+
attr_accessor :tree_expand
|
13
|
+
attr_accessor :tree_collapse
|
14
|
+
|
15
|
+
def initialize(name, parent, locator, context)
|
16
|
+
super
|
17
|
+
@type = :table
|
18
|
+
|
19
|
+
table_spec = {
|
20
|
+
table_body: 'tbody',
|
21
|
+
table_section: nil,
|
22
|
+
table_row: 'tr',
|
23
|
+
table_column: 'td',
|
24
|
+
table_header: 'thead',
|
25
|
+
header_row: 'tr',
|
26
|
+
header_column: 'th',
|
27
|
+
row_header: nil
|
28
|
+
}
|
39
29
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
when :table_row
|
48
|
-
@table_row = value
|
49
|
-
when :table_column
|
50
|
-
@table_column = value
|
51
|
-
when :table_header
|
52
|
-
@table_header = value
|
53
|
-
when :header_row
|
54
|
-
@header_row = value
|
55
|
-
when :header_column
|
56
|
-
@header_column = value
|
57
|
-
when :row_header
|
58
|
-
@row_header = value
|
59
|
-
when :tree_expand
|
60
|
-
@tree_expand = value
|
61
|
-
when :tree_collapse
|
62
|
-
@tree_collapse = value
|
63
|
-
else
|
64
|
-
raise "#{element} is not a recognized table element"
|
30
|
+
case @locator_type
|
31
|
+
when :xpath
|
32
|
+
table_spec[:tree_expand] = "div/div[contains(@class, 'tree-plus treeclick')]"
|
33
|
+
table_spec[:tree_collapse] = "div/div[contains(@class, 'tree-minus treeclick')]"
|
34
|
+
when :css
|
35
|
+
table_spec[:tree_expand] = "div > div[class*='tree-plus treeclick']"
|
36
|
+
table_spec[:tree_collapse] = "div > div[class*='tree-minus treeclick']"
|
65
37
|
end
|
38
|
+
define_table_elements(table_spec)
|
66
39
|
end
|
67
|
-
end
|
68
40
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
41
|
+
def define_table_elements(element_spec)
|
42
|
+
element_spec.each do |element, value|
|
43
|
+
case element
|
44
|
+
when :table_body
|
45
|
+
@table_body = value
|
46
|
+
when :table_section
|
47
|
+
@table_section = value
|
48
|
+
when :table_row
|
49
|
+
@table_row = value
|
50
|
+
when :table_column
|
51
|
+
@table_column = value
|
52
|
+
when :table_header
|
53
|
+
@table_header = value
|
54
|
+
when :header_row
|
55
|
+
@header_row = value
|
56
|
+
when :header_column
|
57
|
+
@header_column = value
|
58
|
+
when :row_header
|
59
|
+
@row_header = value
|
60
|
+
when :tree_expand
|
61
|
+
@tree_expand = value
|
62
|
+
when :tree_collapse
|
63
|
+
@tree_collapse = value
|
64
|
+
else
|
65
|
+
raise "#{element} is not a recognized table element"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
90
69
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
70
|
+
# Return number of rows in a table object.
|
71
|
+
#
|
72
|
+
# @return [Integer]
|
73
|
+
# @example
|
74
|
+
# num_rows = list_table.get_row_count
|
75
|
+
#
|
76
|
+
def get_row_count
|
77
|
+
wait_until_exists(5)
|
78
|
+
delimiter = case @locator_type
|
79
|
+
when :xpath
|
80
|
+
"/"
|
81
|
+
when :css
|
82
|
+
" > "
|
83
|
+
end
|
84
|
+
path = if @table_section.nil?
|
85
|
+
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_row}"
|
86
|
+
else
|
87
|
+
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_section}"
|
88
|
+
end
|
89
|
+
page.all(@locator_type, path, visible: :all).count
|
110
90
|
end
|
111
|
-
end
|
112
91
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
92
|
+
# Wait until the table's row count equals the specified value, or until the specified wait time has expired. If the wait
|
93
|
+
# time is nil, then the wait time will be Capybara.default_max_wait_time.
|
94
|
+
#
|
95
|
+
# @param value [Integer or Hash] value expected or comparison hash
|
96
|
+
# @param seconds [Integer or Float] wait time in seconds
|
97
|
+
# @example
|
98
|
+
# list_table.wait_until_row_count_is(10, 15)
|
99
|
+
# or
|
100
|
+
# list_table.wait_until_row_count_is({ greater_than_or_equal: 1 }, 5)
|
101
|
+
#
|
102
|
+
def wait_until_row_count_is(value, seconds = nil, post_exception = true)
|
103
|
+
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
104
|
+
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
105
|
+
wait.until { compare(value, get_row_count) }
|
106
|
+
rescue
|
107
|
+
if post_exception
|
108
|
+
raise "Value of Table #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_row_count == value
|
109
|
+
else
|
110
|
+
get_row_count == value
|
111
|
+
end
|
130
112
|
end
|
131
|
-
end
|
132
113
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
114
|
+
# Wait until the table's row count changes to a different value, or until the specified wait time has expired. If the
|
115
|
+
# wait time is nil, then the wait time will be Capybara.default_max_wait_time.
|
116
|
+
#
|
117
|
+
# @param seconds [Integer or Float] wait time in seconds
|
118
|
+
# @example
|
119
|
+
# list_table.wait_until_row_count_changes(5)
|
120
|
+
#
|
121
|
+
def wait_until_row_count_changes(seconds = nil, post_exception = true)
|
122
|
+
value = get_row_count
|
123
|
+
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
124
|
+
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
125
|
+
wait.until { get_row_count != value }
|
126
|
+
rescue
|
127
|
+
if post_exception
|
128
|
+
raise "Value of Table #{object_ref_message} failed to change from '#{value}' after #{timeout} seconds" if get_row_count == value
|
129
|
+
else
|
130
|
+
get_row_count == value
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# Return number of columns in a table object.
|
135
|
+
#
|
136
|
+
# @return [Integer]
|
137
|
+
# @example
|
138
|
+
# num_columns = list_table.get_column_count
|
139
|
+
#
|
140
|
+
def get_column_count
|
141
|
+
row_count = get_row_count
|
142
|
+
case @locator_type
|
143
|
+
when :xpath
|
144
|
+
delimiter = "/"
|
145
|
+
index = "[2]"
|
146
|
+
when :css
|
147
|
+
delimiter = " > "
|
148
|
+
index = ":nth-of-type(2)"
|
149
|
+
end
|
150
|
+
path = if row_count.zero?
|
151
|
+
"#{@locator}#{delimiter}#{@table_header}#{delimiter}#{@header_row}#{delimiter}#{@header_column}"
|
158
152
|
else
|
159
|
-
if
|
160
|
-
|
153
|
+
if @table_section.nil?
|
154
|
+
if row_count == 1
|
155
|
+
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_row}#{delimiter}#{@table_column}"
|
156
|
+
else
|
157
|
+
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_row}#{index}#{delimiter}#{@table_column}"
|
158
|
+
end
|
161
159
|
else
|
162
|
-
|
160
|
+
if row_count == 1
|
161
|
+
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_section}#{delimiter}#{@table_row}#{delimiter}#{@table_column}"
|
162
|
+
else
|
163
|
+
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_section}#{index}#{delimiter}#{@table_row}#{delimiter}#{@table_column}"
|
164
|
+
end
|
163
165
|
end
|
164
166
|
end
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
end
|
177
|
-
else
|
178
|
-
if row_count == 1
|
179
|
-
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_section}#{delimiter}#{@table_row}#{delimiter}#{@row_header}"
|
167
|
+
if @row_header.nil?
|
168
|
+
page.all(@locator_type, path, visible: :all).count
|
169
|
+
else
|
170
|
+
cols = page.all(@locator_type, path, visible: :all).count
|
171
|
+
|
172
|
+
path = if @table_section.nil?
|
173
|
+
if row_count == 1
|
174
|
+
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_row}#{delimiter}#{@row_header}"
|
175
|
+
else
|
176
|
+
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_row}#{index}#{delimiter}#{@row_header}"
|
177
|
+
end
|
180
178
|
else
|
181
|
-
|
179
|
+
if row_count == 1
|
180
|
+
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_section}#{delimiter}#{@table_row}#{delimiter}#{@row_header}"
|
181
|
+
else
|
182
|
+
"#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_section}#{index}#{delimiter}#{@table_row}#{delimiter}#{@row_header}"
|
183
|
+
end
|
182
184
|
end
|
183
|
-
|
184
|
-
|
185
|
+
cols + page.all(@locator_type, path, visible: :all).count
|
186
|
+
end
|
185
187
|
end
|
186
|
-
end
|
187
188
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
# Click in the specified cell in a table object.
|
206
|
-
#
|
207
|
-
# @param row [Integer] row number
|
208
|
-
# @param column [Integer] column number
|
209
|
-
# @example
|
210
|
-
# list_table.click_table_cell(3, 5)
|
211
|
-
#
|
212
|
-
def click_table_cell(row, column)
|
213
|
-
row_count = get_row_count
|
214
|
-
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
215
|
-
column_count = get_column_count
|
216
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
217
|
-
set_table_cell_locator(row, column)
|
218
|
-
click
|
219
|
-
clear_alt_locator
|
220
|
-
end
|
189
|
+
# Hover over the specified cell in a table object.
|
190
|
+
#
|
191
|
+
# @param row [Integer] row number
|
192
|
+
# @param column [Integer] column number
|
193
|
+
# @example
|
194
|
+
# list_table.hover_table_cell(2, 6)
|
195
|
+
#
|
196
|
+
def hover_table_cell(row, column)
|
197
|
+
row_count = get_row_count
|
198
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
199
|
+
column_count = get_column_count
|
200
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
201
|
+
set_table_cell_locator(row, column)
|
202
|
+
hover
|
203
|
+
clear_alt_locator
|
204
|
+
end
|
221
205
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
206
|
+
# Click in the specified cell in a table object.
|
207
|
+
#
|
208
|
+
# @param row [Integer] row number
|
209
|
+
# @param column [Integer] column number
|
210
|
+
# @example
|
211
|
+
# list_table.click_table_cell(3, 5)
|
212
|
+
#
|
213
|
+
def click_table_cell(row, column)
|
214
|
+
row_count = get_row_count
|
215
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
216
|
+
column_count = get_column_count
|
217
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
218
|
+
set_table_cell_locator(row, column)
|
219
|
+
click
|
220
|
+
clear_alt_locator
|
221
|
+
end
|
238
222
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
when :xpath
|
255
|
-
set_alt_locator("#{@alt_locator}//a")
|
256
|
-
set_alt_locator("#{saved_locator}//span/a") unless exists?
|
257
|
-
# if link not present, check for text entry fields and try to dismiss by tabbing out
|
258
|
-
unless exists?
|
259
|
-
set_alt_locator("#{saved_locator}//input")
|
260
|
-
set_alt_locator("#{saved_locator}//textarea") unless exists?
|
261
|
-
send_keys(:tab) if exists?
|
262
|
-
set_alt_locator("#{saved_locator}//a")
|
263
|
-
set_alt_locator("#{saved_locator}//span/a") unless exists?
|
264
|
-
send_keys(:tab) unless exists?
|
265
|
-
end
|
266
|
-
when :css
|
267
|
-
set_alt_locator("#{@alt_locator} a")
|
268
|
-
set_alt_locator("#{saved_locator} span > a") unless exists?
|
269
|
-
# if link not present, check for text entry fields and try to dismiss by tabbing out
|
270
|
-
unless exists?
|
271
|
-
set_alt_locator("#{saved_locator} input")
|
272
|
-
set_alt_locator("#{saved_locator} textarea") unless exists?
|
273
|
-
send_keys(:tab) if exists?
|
274
|
-
set_alt_locator("#{saved_locator} a")
|
275
|
-
set_alt_locator("#{saved_locator} span > a") unless exists?
|
276
|
-
send_keys(:tab) unless exists?
|
277
|
-
end
|
223
|
+
# Double-click in the specified cell in a table object.
|
224
|
+
#
|
225
|
+
# @param row [Integer] row number
|
226
|
+
# @param column [Integer] column number
|
227
|
+
# @example
|
228
|
+
# list_table.double_click_table_cell(3, 5)
|
229
|
+
#
|
230
|
+
def double_click_table_cell(row, column)
|
231
|
+
row_count = get_row_count
|
232
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
233
|
+
column_count = get_column_count
|
234
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
235
|
+
set_table_cell_locator(row, column)
|
236
|
+
double_click
|
237
|
+
clear_alt_locator
|
278
238
|
end
|
279
|
-
wait_until_exists(1)
|
280
|
-
click
|
281
|
-
clear_alt_locator
|
282
|
-
end
|
283
239
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
(1
|
290
|
-
|
240
|
+
# Click the link object embedded within the specified cell in a table object.
|
241
|
+
#
|
242
|
+
# @param row [Integer] row number
|
243
|
+
# @param column [Integer] column number
|
244
|
+
# @example
|
245
|
+
# list_table.click_table_cell_link(3, 1)
|
246
|
+
#
|
247
|
+
def click_table_cell_link(row, column)
|
248
|
+
row_count = get_row_count
|
249
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
250
|
+
column_count = get_column_count
|
251
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
291
252
|
set_table_cell_locator(row, column)
|
292
253
|
saved_locator = @alt_locator
|
293
254
|
case @locator_type
|
294
255
|
when :xpath
|
295
|
-
set_alt_locator("#{
|
256
|
+
set_alt_locator("#{@alt_locator}//a")
|
257
|
+
set_alt_locator("#{saved_locator}//span/a") unless exists?
|
258
|
+
# if link not present, check for text entry fields and try to dismiss by tabbing out
|
296
259
|
unless exists?
|
297
|
-
set_alt_locator("#{saved_locator}//
|
298
|
-
set_alt_locator(saved_locator) unless exists?
|
260
|
+
set_alt_locator("#{saved_locator}//input")
|
261
|
+
set_alt_locator("#{saved_locator}//textarea") unless exists?
|
262
|
+
send_keys(:tab) if exists?
|
263
|
+
set_alt_locator("#{saved_locator}//a")
|
264
|
+
set_alt_locator("#{saved_locator}//span/a") unless exists?
|
265
|
+
send_keys(:tab) unless exists?
|
299
266
|
end
|
300
267
|
when :css
|
301
|
-
set_alt_locator("#{
|
268
|
+
set_alt_locator("#{@alt_locator} a")
|
269
|
+
set_alt_locator("#{saved_locator} span > a") unless exists?
|
270
|
+
# if link not present, check for text entry fields and try to dismiss by tabbing out
|
302
271
|
unless exists?
|
303
|
-
set_alt_locator("#{saved_locator}
|
304
|
-
set_alt_locator(saved_locator) unless exists?
|
272
|
+
set_alt_locator("#{saved_locator} input")
|
273
|
+
set_alt_locator("#{saved_locator} textarea") unless exists?
|
274
|
+
send_keys(:tab) if exists?
|
275
|
+
set_alt_locator("#{saved_locator} a")
|
276
|
+
set_alt_locator("#{saved_locator} span > a") unless exists?
|
277
|
+
send_keys(:tab) unless exists?
|
305
278
|
end
|
306
279
|
end
|
307
|
-
|
308
|
-
|
280
|
+
wait_until_exists(1)
|
281
|
+
click
|
282
|
+
clear_alt_locator
|
283
|
+
end
|
284
|
+
|
285
|
+
def get_table_row(row)
|
286
|
+
columns = []
|
287
|
+
row_count = get_row_count
|
288
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
289
|
+
column_count = get_column_count
|
290
|
+
(1..column_count).each do |column|
|
291
|
+
value = ''
|
292
|
+
set_table_cell_locator(row, column)
|
293
|
+
saved_locator = @alt_locator
|
294
|
+
case @locator_type
|
295
|
+
when :xpath
|
296
|
+
set_alt_locator("#{saved_locator}//input")
|
297
|
+
unless exists?
|
298
|
+
set_alt_locator("#{saved_locator}//textarea")
|
299
|
+
set_alt_locator(saved_locator) unless exists?
|
300
|
+
end
|
301
|
+
when :css
|
302
|
+
set_alt_locator("#{saved_locator} input")
|
303
|
+
unless exists?
|
304
|
+
set_alt_locator("#{saved_locator} textarea")
|
305
|
+
set_alt_locator(saved_locator) unless exists?
|
306
|
+
end
|
307
|
+
end
|
308
|
+
value = get_value if exists?
|
309
|
+
columns.push(value)
|
310
|
+
end
|
311
|
+
clear_alt_locator
|
312
|
+
columns
|
309
313
|
end
|
310
|
-
clear_alt_locator
|
311
|
-
columns
|
312
|
-
end
|
313
314
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
315
|
+
def get_row_data(row)
|
316
|
+
row_count = get_row_count
|
317
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
318
|
+
case @locator_type
|
319
|
+
when :xpath
|
320
|
+
row > 1 ?
|
320
321
|
set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}[#{row}]") :
|
321
322
|
set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}")
|
322
|
-
|
323
|
-
|
323
|
+
when :css
|
324
|
+
row > 1 ?
|
324
325
|
set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}:nth-of-type(#{row})") :
|
325
326
|
set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}")
|
327
|
+
end
|
328
|
+
value = get_value if exists?
|
329
|
+
clear_alt_locator
|
330
|
+
value
|
326
331
|
end
|
327
|
-
value = get_value if exists?
|
328
|
-
clear_alt_locator
|
329
|
-
value
|
330
|
-
end
|
331
332
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
333
|
+
def get_table_column(column)
|
334
|
+
rows = []
|
335
|
+
column_count = get_column_count
|
336
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
337
|
+
row_count = get_row_count
|
338
|
+
(1..row_count).each do |row|
|
339
|
+
value = ''
|
340
|
+
set_table_cell_locator(row, column)
|
341
|
+
saved_locator = @alt_locator
|
342
|
+
case @locator_type
|
343
|
+
when :xpath
|
344
|
+
set_alt_locator("#{saved_locator}//input")
|
345
|
+
unless exists?
|
346
|
+
set_alt_locator("#{saved_locator}//textarea")
|
347
|
+
set_alt_locator(saved_locator) unless exists?
|
348
|
+
end
|
349
|
+
when :css
|
350
|
+
set_alt_locator("#{saved_locator} input")
|
351
|
+
unless exists?
|
352
|
+
set_alt_locator("#{saved_locator} textarea")
|
353
|
+
set_alt_locator(saved_locator) unless exists?
|
354
|
+
end
|
355
|
+
end
|
356
|
+
value = get_value if exists?
|
357
|
+
rows.push(value)
|
358
|
+
end
|
359
|
+
clear_alt_locator
|
360
|
+
rows
|
361
|
+
end
|
362
|
+
|
363
|
+
# Return text contained in specified cell of a table object.
|
364
|
+
#
|
365
|
+
# @param row [Integer] row number
|
366
|
+
# @param column [Integer] column number
|
367
|
+
# @return [String] value of table cell
|
368
|
+
# @example
|
369
|
+
# list_table.get_table_cell(4, 5)
|
370
|
+
#
|
371
|
+
def get_table_cell(row, column)
|
372
|
+
row_count = get_row_count
|
373
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
374
|
+
column_count = get_column_count
|
375
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
339
376
|
set_table_cell_locator(row, column)
|
340
377
|
saved_locator = @alt_locator
|
341
378
|
case @locator_type
|
@@ -352,338 +389,303 @@ module TestCentricity
|
|
352
389
|
set_alt_locator(saved_locator) unless exists?
|
353
390
|
end
|
354
391
|
end
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
end
|
361
|
-
|
362
|
-
# Return text contained in specified cell of a table object.
|
363
|
-
#
|
364
|
-
# @param row [Integer] row number
|
365
|
-
# @param column [Integer] column number
|
366
|
-
# @return [String] value of table cell
|
367
|
-
# @example
|
368
|
-
# list_table.get_table_cell(4, 5)
|
369
|
-
#
|
370
|
-
def get_table_cell(row, column)
|
371
|
-
row_count = get_row_count
|
372
|
-
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
373
|
-
column_count = get_column_count
|
374
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
375
|
-
set_table_cell_locator(row, column)
|
376
|
-
saved_locator = @alt_locator
|
377
|
-
case @locator_type
|
378
|
-
when :xpath
|
379
|
-
set_alt_locator("#{saved_locator}//input")
|
380
|
-
unless exists?
|
381
|
-
set_alt_locator("#{saved_locator}//textarea")
|
382
|
-
set_alt_locator(saved_locator) unless exists?
|
383
|
-
end
|
384
|
-
when :css
|
385
|
-
set_alt_locator("#{saved_locator} input")
|
386
|
-
unless exists?
|
387
|
-
set_alt_locator("#{saved_locator} textarea")
|
388
|
-
set_alt_locator(saved_locator) unless exists?
|
392
|
+
if exists?
|
393
|
+
value = get_value
|
394
|
+
else
|
395
|
+
puts "Could not find table cell at #{@alt_locator}"
|
396
|
+
value = ''
|
389
397
|
end
|
398
|
+
clear_alt_locator
|
399
|
+
value
|
390
400
|
end
|
391
|
-
if exists?
|
392
|
-
value = get_value
|
393
|
-
else
|
394
|
-
puts "Could not find table cell at #{@alt_locator}"
|
395
|
-
value = ''
|
396
|
-
end
|
397
|
-
clear_alt_locator
|
398
|
-
value
|
399
|
-
end
|
400
401
|
|
401
|
-
|
402
|
-
|
403
|
-
|
402
|
+
def verify_table_cell(row, column, expected, enqueue = false)
|
403
|
+
actual = get_table_cell(row, column)
|
404
|
+
enqueue ?
|
404
405
|
ExceptionQueue.enqueue_assert_equal(expected.strip, actual.strip, "Expected table #{object_ref_message} row #{row}/column #{column}") :
|
405
406
|
assert_equal(expected.strip, actual.strip, "Expected table #{object_ref_message} row #{row}/column #{column} to display '#{expected}' but found '#{actual}'")
|
406
|
-
|
407
|
+
end
|
407
408
|
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
409
|
+
# Set the value of the specified cell in a table object.
|
410
|
+
#
|
411
|
+
# @param row [Integer] row number
|
412
|
+
# @param column [Integer] column number
|
413
|
+
# @param value [String] text to set
|
414
|
+
# @example
|
415
|
+
# list_table.set_table_cell(3, 1, 'Ontario')
|
416
|
+
#
|
417
|
+
def set_table_cell(row, column, value)
|
418
|
+
row_count = get_row_count
|
419
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
420
|
+
find_table_cell(row, column)
|
421
|
+
find_table_cell(row, column) unless exists?
|
422
|
+
set(value)
|
423
|
+
clear_alt_locator
|
424
|
+
end
|
424
425
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
426
|
+
def get_cell_attribute(row, column, attrib)
|
427
|
+
row_count = get_row_count
|
428
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
429
|
+
column_count = get_column_count
|
430
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
431
|
+
set_table_cell_locator(row, column)
|
432
|
+
result = get_native_attribute(attrib)
|
433
|
+
clear_alt_locator
|
434
|
+
result
|
435
|
+
end
|
435
436
|
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
437
|
+
def get_row_attribute(row, attrib)
|
438
|
+
row_count = get_row_count
|
439
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
440
|
+
case @locator_type
|
441
|
+
when :xpath
|
442
|
+
row > 1 ?
|
442
443
|
set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}[#{row}]") :
|
443
444
|
set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}")
|
444
|
-
|
445
|
-
|
445
|
+
when :css
|
446
|
+
row > 1 ?
|
446
447
|
set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}:nth-of-type(#{row})") :
|
447
448
|
set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}")
|
449
|
+
end
|
450
|
+
result = get_native_attribute(attrib)
|
451
|
+
clear_alt_locator
|
452
|
+
result
|
448
453
|
end
|
449
|
-
result = get_native_attribute(attrib)
|
450
|
-
clear_alt_locator
|
451
|
-
result
|
452
|
-
end
|
453
454
|
|
454
|
-
|
455
|
-
|
456
|
-
|
455
|
+
def find_row_attribute(attrib, search_value)
|
456
|
+
(1..get_row_count).each do |row|
|
457
|
+
return row if get_row_attribute(row, attrib) == search_value
|
458
|
+
end
|
459
|
+
nil
|
457
460
|
end
|
458
|
-
nil
|
459
|
-
end
|
460
461
|
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
462
|
+
# Search for the specified text value in the specified row of the table object.
|
463
|
+
# Returns the number of the first column that contains the search value.
|
464
|
+
#
|
465
|
+
# @param row [Integer] row nummber
|
466
|
+
# @param search_value [String] value to be searched for
|
467
|
+
# @return [Integer] column number of table cell that contains search value
|
468
|
+
# @example
|
469
|
+
# bom_table.find_in_table_row(4, 'High-speed Framus bolts')
|
470
|
+
#
|
471
|
+
def find_in_table_row(row, search_value)
|
472
|
+
(1..get_column_count).each do |column|
|
473
|
+
return column if get_table_cell(row, column) == search_value
|
474
|
+
end
|
475
|
+
nil
|
476
|
+
end
|
476
477
|
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
478
|
+
# Search for the specified text value in the specified column of the table object.
|
479
|
+
# Returns the number of the first row that contains the search value.
|
480
|
+
#
|
481
|
+
# @param column [Integer] column nummber
|
482
|
+
# @param search_value [String] value to be searched for
|
483
|
+
# @return [Integer] row number of table cell that contains search value
|
484
|
+
# @example
|
485
|
+
# playlist_table.find_in_table_column(1, 'Ashes to Ashes')
|
486
|
+
#
|
487
|
+
def find_in_table_column(column, search_value)
|
488
|
+
(1..get_row_count).each do |row|
|
489
|
+
return row if get_table_cell(row, column) == search_value
|
490
|
+
end
|
491
|
+
nil
|
492
|
+
end
|
492
493
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
494
|
+
# Populate the specified row of this table object with the associated data from a Hash passed as an
|
495
|
+
# argument. Data values must be in the form of a String for textfield and select list controls. For checkbox
|
496
|
+
# and radio buttons, data must either be a Boolean or a String that evaluates to a Boolean value (Yes, No, 1,
|
497
|
+
# 0, true, false)
|
498
|
+
#
|
499
|
+
# @param data [Hash] column numbers and associated data to be entered
|
500
|
+
# @example
|
501
|
+
# data = { 1 => 'Dr.',
|
502
|
+
# 2 => 'Evangeline',
|
503
|
+
# 3 => 'Devereaux',
|
504
|
+
# 4 => 'MD',
|
505
|
+
# 5 => 'Family Practice'
|
506
|
+
# }
|
507
|
+
# clinicians_table.populate_table_row(3, data)
|
508
|
+
#
|
509
|
+
def populate_table_row(row, data)
|
510
|
+
wait_until_exists(2)
|
511
|
+
data.each do |column, data_param|
|
512
|
+
unless data_param.blank?
|
513
|
+
if data_param == '!DELETE'
|
514
|
+
set_table_cell(row, column, '')
|
515
|
+
else
|
516
|
+
set_table_cell(row, column, data_param)
|
517
|
+
end
|
516
518
|
end
|
517
519
|
end
|
518
520
|
end
|
519
|
-
end
|
520
|
-
|
521
|
-
# Click in the specified column header in a table object.
|
522
|
-
#
|
523
|
-
# @param column [Integer] column number
|
524
|
-
# @example
|
525
|
-
# list_table.click_header_column(3)
|
526
|
-
#
|
527
|
-
def click_header_column(column)
|
528
|
-
column_count = get_column_count
|
529
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{object_ref_message}" if column > column_count
|
530
|
-
case @locator_type
|
531
|
-
when :xpath
|
532
|
-
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
533
|
-
when :css
|
534
|
-
set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
|
535
|
-
end
|
536
|
-
click if exists?
|
537
|
-
clear_alt_locator
|
538
|
-
end
|
539
|
-
|
540
|
-
def get_header_column(column)
|
541
|
-
column_count = get_column_count
|
542
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{object_ref_message}" if column > column_count
|
543
|
-
case @locator_type
|
544
|
-
when :xpath
|
545
|
-
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
546
|
-
when :css
|
547
|
-
set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
|
548
|
-
end
|
549
|
-
value = get_value(:all) if exists?(:all)
|
550
|
-
clear_alt_locator
|
551
|
-
value
|
552
|
-
end
|
553
521
|
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
522
|
+
# Click in the specified column header in a table object.
|
523
|
+
#
|
524
|
+
# @param column [Integer] column number
|
525
|
+
# @example
|
526
|
+
# list_table.click_header_column(3)
|
527
|
+
#
|
528
|
+
def click_header_column(column)
|
529
|
+
column_count = get_column_count
|
530
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{object_ref_message}" if column > column_count
|
558
531
|
case @locator_type
|
559
532
|
when :xpath
|
560
533
|
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
561
534
|
when :css
|
562
535
|
set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
|
563
536
|
end
|
564
|
-
|
537
|
+
click if exists?
|
538
|
+
clear_alt_locator
|
565
539
|
end
|
566
|
-
clear_alt_locator
|
567
|
-
columns
|
568
|
-
end
|
569
540
|
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
column_count = get_column_count
|
574
|
-
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
575
|
-
set_table_cell_locator(row, column)
|
576
|
-
case @locator_type
|
577
|
-
when :xpath
|
578
|
-
set_alt_locator("#{@alt_locator}/#{@tree_expand}")
|
579
|
-
when :css
|
580
|
-
set_alt_locator("#{@alt_locator} > #{@tree_expand}")
|
581
|
-
end
|
582
|
-
expanded = true
|
583
|
-
expanded = false if exists?
|
584
|
-
clear_alt_locator
|
585
|
-
expanded
|
586
|
-
end
|
587
|
-
|
588
|
-
def expand_table_row(row, column)
|
589
|
-
unless is_table_row_expanded?(row, column)
|
590
|
-
set_table_cell_locator(row, column)
|
541
|
+
def get_header_column(column)
|
542
|
+
column_count = get_column_count
|
543
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{object_ref_message}" if column > column_count
|
591
544
|
case @locator_type
|
592
545
|
when :xpath
|
593
|
-
set_alt_locator("#{@
|
546
|
+
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
594
547
|
when :css
|
595
|
-
set_alt_locator("#{@
|
548
|
+
set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
|
596
549
|
end
|
597
|
-
|
550
|
+
value = get_value(:all) if exists?(:all)
|
598
551
|
clear_alt_locator
|
552
|
+
value
|
553
|
+
end
|
554
|
+
|
555
|
+
def get_header_columns
|
556
|
+
columns = []
|
557
|
+
column_count = get_column_count
|
558
|
+
(1..column_count).each do |column|
|
559
|
+
case @locator_type
|
560
|
+
when :xpath
|
561
|
+
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
562
|
+
when :css
|
563
|
+
set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
|
564
|
+
end
|
565
|
+
columns.push(get_value(:all)) if exists?(:all)
|
566
|
+
end
|
567
|
+
clear_alt_locator
|
568
|
+
columns
|
599
569
|
end
|
600
|
-
end
|
601
570
|
|
602
|
-
|
603
|
-
|
571
|
+
def is_table_row_expanded?(row, column)
|
572
|
+
row_count = get_row_count
|
573
|
+
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
574
|
+
column_count = get_column_count
|
575
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
604
576
|
set_table_cell_locator(row, column)
|
605
577
|
case @locator_type
|
606
578
|
when :xpath
|
607
|
-
set_alt_locator("#{@alt_locator}/#{@
|
579
|
+
set_alt_locator("#{@alt_locator}/#{@tree_expand}")
|
608
580
|
when :css
|
609
|
-
set_alt_locator("#{@alt_locator} > #{@
|
581
|
+
set_alt_locator("#{@alt_locator} > #{@tree_expand}")
|
610
582
|
end
|
611
|
-
|
583
|
+
expanded = true
|
584
|
+
expanded = false if exists?
|
612
585
|
clear_alt_locator
|
586
|
+
expanded
|
613
587
|
end
|
614
|
-
end
|
615
588
|
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
589
|
+
def expand_table_row(row, column)
|
590
|
+
unless is_table_row_expanded?(row, column)
|
591
|
+
set_table_cell_locator(row, column)
|
592
|
+
case @locator_type
|
593
|
+
when :xpath
|
594
|
+
set_alt_locator("#{@alt_locator}/#{@tree_expand}")
|
595
|
+
when :css
|
596
|
+
set_alt_locator("#{@alt_locator} > #{@tree_expand}")
|
597
|
+
end
|
598
|
+
click if exists?
|
599
|
+
clear_alt_locator
|
600
|
+
end
|
622
601
|
end
|
623
|
-
end
|
624
602
|
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
603
|
+
def collapse_table_row(row, column)
|
604
|
+
if is_table_row_expanded?(row, column)
|
605
|
+
set_table_cell_locator(row, column)
|
606
|
+
case @locator_type
|
607
|
+
when :xpath
|
608
|
+
set_alt_locator("#{@alt_locator}/#{@tree_collapse}")
|
609
|
+
when :css
|
610
|
+
set_alt_locator("#{@alt_locator} > #{@tree_collapse}")
|
611
|
+
end
|
612
|
+
click if exists?
|
613
|
+
clear_alt_locator
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
def expand_all_table_rows(column)
|
618
|
+
row_count = get_row_count
|
619
|
+
column_count = get_column_count
|
620
|
+
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
621
|
+
row_count.downto(1) do |row|
|
622
|
+
expand_table_row(row, column)
|
634
623
|
end
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
624
|
+
end
|
625
|
+
|
626
|
+
def get_table_cell_locator(row, column)
|
627
|
+
case @locator_type
|
628
|
+
when :xpath
|
629
|
+
if @table_section.nil?
|
630
|
+
row_spec = "#{@locator}/#{@table_body}/#{@table_row}"
|
631
|
+
row_spec = "#{row_spec}[#{row}]"
|
632
|
+
else
|
633
|
+
row_spec = "#{@locator}/#{@table_body}/#{@table_section}"
|
634
|
+
row_spec = "#{row_spec}[#{row}]/#{@table_row}[1]"
|
635
|
+
end
|
636
|
+
column_spec = if @row_header.nil?
|
637
|
+
"/#{@table_column}[#{column}]"
|
640
638
|
else
|
641
|
-
|
639
|
+
if column == 1
|
640
|
+
"/#{@row_header}"
|
641
|
+
else
|
642
|
+
"/#{@table_column}[#{column - 1}]"
|
643
|
+
end
|
642
644
|
end
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
end
|
645
|
+
when :css
|
646
|
+
if @table_section.nil?
|
647
|
+
row_spec = "#{@locator} > #{@table_body} > #{@table_row}"
|
648
|
+
row_spec = "#{row_spec}:nth-of-type(#{row})"
|
649
|
+
else
|
650
|
+
row_spec = "#{@locator} > #{@table_body} > #{@table_section}"
|
651
|
+
row_spec = "#{row_spec}:nth-of-type(#{row}) > #{@table_row}:nth-of-type(1)"
|
652
|
+
end
|
652
653
|
|
653
|
-
|
654
|
-
|
655
|
-
else
|
656
|
-
if column == 1
|
657
|
-
" > #{@row_header}"
|
654
|
+
column_spec = if @row_header.nil?
|
655
|
+
" > #{@table_column}:nth-of-type(#{column})"
|
658
656
|
else
|
659
|
-
|
657
|
+
if column == 1
|
658
|
+
" > #{@row_header}"
|
659
|
+
else
|
660
|
+
" > #{@table_column}:nth-of-type(#{column - 1})"
|
661
|
+
end
|
660
662
|
end
|
661
|
-
|
663
|
+
end
|
664
|
+
"#{row_spec}#{column_spec}"
|
662
665
|
end
|
663
|
-
"#{row_spec}#{column_spec}"
|
664
|
-
end
|
665
666
|
|
666
|
-
|
667
|
+
private
|
667
668
|
|
668
|
-
|
669
|
-
|
670
|
-
|
669
|
+
def set_table_cell_locator(row, column)
|
670
|
+
set_alt_locator(get_table_cell_locator(row, column))
|
671
|
+
end
|
671
672
|
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
673
|
+
def find_table_cell(row, column)
|
674
|
+
set_table_cell_locator(row, column)
|
675
|
+
if exists?
|
676
|
+
click
|
677
|
+
else
|
678
|
+
puts "Could not find table cell at #{@alt_locator}"
|
679
|
+
end
|
680
|
+
saved_locator = @alt_locator
|
681
|
+
case @locator_type
|
682
|
+
when :xpath
|
683
|
+
set_alt_locator("#{saved_locator}//input")
|
684
|
+
set_alt_locator("#{saved_locator}//textarea") unless exists?
|
685
|
+
when :css
|
686
|
+
set_alt_locator("#{saved_locator} input")
|
687
|
+
set_alt_locator("#{saved_locator} textarea") unless exists?
|
688
|
+
end
|
687
689
|
end
|
688
690
|
end
|
689
691
|
end
|