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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -12
  3. data/LICENSE.md +1 -1
  4. data/README.md +1794 -697
  5. data/lib/devices/devices.yml +144 -216
  6. data/lib/testcentricity_web/browser_helper.rb +33 -4
  7. data/lib/testcentricity_web/data_objects/environment.rb +96 -13
  8. data/lib/testcentricity_web/exception_queue_helper.rb +5 -6
  9. data/lib/testcentricity_web/version.rb +1 -1
  10. data/lib/testcentricity_web/web_core/page_object.rb +53 -49
  11. data/lib/testcentricity_web/web_core/page_objects_helper.rb +20 -11
  12. data/lib/testcentricity_web/web_core/page_section.rb +31 -34
  13. data/lib/testcentricity_web/web_core/webdriver_helper.rb +379 -252
  14. data/lib/testcentricity_web/web_elements/audio.rb +6 -4
  15. data/lib/testcentricity_web/web_elements/button.rb +7 -4
  16. data/lib/testcentricity_web/web_elements/checkbox.rb +149 -147
  17. data/lib/testcentricity_web/web_elements/file_field.rb +38 -36
  18. data/lib/testcentricity_web/web_elements/image.rb +75 -70
  19. data/lib/testcentricity_web/web_elements/label.rb +6 -4
  20. data/lib/testcentricity_web/web_elements/link.rb +15 -13
  21. data/lib/testcentricity_web/web_elements/list.rb +171 -169
  22. data/lib/testcentricity_web/web_elements/media.rb +384 -379
  23. data/lib/testcentricity_web/web_elements/radio.rb +135 -133
  24. data/lib/testcentricity_web/web_elements/range.rb +16 -29
  25. data/lib/testcentricity_web/web_elements/select_list.rb +247 -245
  26. data/lib/testcentricity_web/web_elements/table.rb +575 -573
  27. data/lib/testcentricity_web/web_elements/textfield.rb +143 -139
  28. data/lib/testcentricity_web/web_elements/ui_element.rb +1171 -0
  29. data/lib/testcentricity_web/web_elements/video.rb +39 -37
  30. data/lib/testcentricity_web/world_extensions.rb +37 -4
  31. data/lib/testcentricity_web.rb +4 -23
  32. metadata +28 -80
  33. data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +0 -1148
@@ -1,341 +1,378 @@
1
1
  module TestCentricity
2
- class Table < UIElement
3
- attr_accessor :table_body
4
- attr_accessor :table_section
5
- attr_accessor :table_row
6
- attr_accessor :table_column
7
- attr_accessor :table_header
8
- attr_accessor :header_row
9
- attr_accessor :header_column
10
- attr_accessor :row_header
11
- attr_accessor :tree_expand
12
- attr_accessor :tree_collapse
13
-
14
- def initialize(name, parent, locator, context)
15
- super
16
- @type = :table
17
-
18
- table_spec = {
19
- table_body: 'tbody',
20
- table_section: nil,
21
- table_row: 'tr',
22
- table_column: 'td',
23
- table_header: 'thead',
24
- header_row: 'tr',
25
- header_column: 'th',
26
- row_header: nil
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
- def define_table_elements(element_spec)
41
- element_spec.each do |element, value|
42
- case element
43
- when :table_body
44
- @table_body = value
45
- when :table_section
46
- @table_section = value
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
- # Return number of rows in a table object.
70
- #
71
- # @return [Integer]
72
- # @example
73
- # num_rows = list_table.get_row_count
74
- #
75
- def get_row_count
76
- wait_until_exists(5)
77
- delimiter = case @locator_type
78
- when :xpath
79
- "/"
80
- when :css
81
- " > "
82
- end
83
- path = if @table_section.nil?
84
- "#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_row}"
85
- else
86
- "#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_section}"
87
- end
88
- page.all(@locator_type, path, visible: :all).count
89
- end
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
- # Wait until the table's row count equals the specified value, or until the specified wait time has expired. If the wait
92
- # time is nil, then the wait time will be Capybara.default_max_wait_time.
93
- #
94
- # @param value [Integer or Hash] value expected or comparison hash
95
- # @param seconds [Integer or Float] wait time in seconds
96
- # @example
97
- # list_table.wait_until_row_count_is(10, 15)
98
- # or
99
- # list_table.wait_until_row_count_is({ greater_than_or_equal: 1 }, 5)
100
- #
101
- def wait_until_row_count_is(value, seconds = nil, post_exception = true)
102
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
103
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
104
- wait.until { compare(value, get_row_count) }
105
- rescue
106
- if post_exception
107
- raise "Value of Table #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_row_count == value
108
- else
109
- get_row_count == value
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
- # Wait until the table's row count changes to a different value, or until the specified wait time has expired. If the
114
- # wait time is nil, then the wait time will be Capybara.default_max_wait_time.
115
- #
116
- # @param seconds [Integer or Float] wait time in seconds
117
- # @example
118
- # list_table.wait_until_row_count_changes(5)
119
- #
120
- def wait_until_row_count_changes(seconds = nil, post_exception = true)
121
- value = get_row_count
122
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
123
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
124
- wait.until { get_row_count != value }
125
- rescue
126
- if post_exception
127
- raise "Value of Table #{object_ref_message} failed to change from '#{value}' after #{timeout} seconds" if get_row_count == value
128
- else
129
- get_row_count == value
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
- # Return number of columns in a table object.
134
- #
135
- # @return [Integer]
136
- # @example
137
- # num_columns = list_table.get_column_count
138
- #
139
- def get_column_count
140
- row_count = get_row_count
141
- case @locator_type
142
- when :xpath
143
- delimiter = "/"
144
- index = "[2]"
145
- when :css
146
- delimiter = " > "
147
- index = ":nth-of-type(2)"
148
- end
149
- path = if row_count.zero?
150
- "#{@locator}#{delimiter}#{@table_header}#{delimiter}#{@header_row}#{delimiter}#{@header_column}"
151
- else
152
- if @table_section.nil?
153
- if row_count == 1
154
- "#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_row}#{delimiter}#{@table_column}"
155
- else
156
- "#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_row}#{index}#{delimiter}#{@table_column}"
157
- end
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 row_count == 1
160
- "#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_section}#{delimiter}#{@table_row}#{delimiter}#{@table_column}"
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
- "#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_section}#{index}#{delimiter}#{@table_row}#{delimiter}#{@table_column}"
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
- end
166
- if @row_header.nil?
167
- page.all(@locator_type, path, visible: :all).count
168
- else
169
- cols = page.all(@locator_type, path, visible: :all).count
170
-
171
- path = if @table_section.nil?
172
- if row_count == 1
173
- "#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_row}#{delimiter}#{@row_header}"
174
- else
175
- "#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_row}#{index}#{delimiter}#{@row_header}"
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
- "#{@locator}#{delimiter}#{@table_body}#{delimiter}#{@table_section}#{index}#{delimiter}#{@table_row}#{delimiter}#{@row_header}"
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
- end
184
- cols + page.all(@locator_type, path, visible: :all).count
185
+ cols + page.all(@locator_type, path, visible: :all).count
186
+ end
185
187
  end
186
- end
187
188
 
188
- # Hover over the specified cell in a table object.
189
- #
190
- # @param row [Integer] row number
191
- # @param column [Integer] column number
192
- # @example
193
- # list_table.hover_table_cell(2, 6)
194
- #
195
- def hover_table_cell(row, column)
196
- row_count = get_row_count
197
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
198
- column_count = get_column_count
199
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
200
- set_table_cell_locator(row, column)
201
- hover
202
- clear_alt_locator
203
- end
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
- # Double-click in the specified cell in a table object.
223
- #
224
- # @param row [Integer] row number
225
- # @param column [Integer] column number
226
- # @example
227
- # list_table.double_click_table_cell(3, 5)
228
- #
229
- def double_click_table_cell(row, column)
230
- row_count = get_row_count
231
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
232
- column_count = get_column_count
233
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
234
- set_table_cell_locator(row, column)
235
- double_click
236
- clear_alt_locator
237
- end
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
- # Click the link object embedded within the specified cell in a table object.
240
- #
241
- # @param row [Integer] row number
242
- # @param column [Integer] column number
243
- # @example
244
- # list_table.click_table_cell_link(3, 1)
245
- #
246
- def click_table_cell_link(row, column)
247
- row_count = get_row_count
248
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
249
- column_count = get_column_count
250
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
251
- set_table_cell_locator(row, column)
252
- saved_locator = @alt_locator
253
- case @locator_type
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
- def get_table_row(row)
285
- columns = []
286
- row_count = get_row_count
287
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
288
- column_count = get_column_count
289
- (1..column_count).each do |column|
290
- value = ''
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("#{saved_locator}//input")
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}//textarea")
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("#{saved_locator} input")
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} textarea")
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
- value = get_value if exists?
308
- columns.push(value)
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
- def get_row_data(row)
315
- row_count = get_row_count
316
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
317
- case @locator_type
318
- when :xpath
319
- row > 1 ?
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
- when :css
323
- row > 1 ?
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
- def get_table_column(column)
333
- rows = []
334
- column_count = get_column_count
335
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
336
- row_count = get_row_count
337
- (1..row_count).each do |row|
338
- value = ''
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
- value = get_value if exists?
356
- rows.push(value)
357
- end
358
- clear_alt_locator
359
- rows
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
- def verify_table_cell(row, column, expected, enqueue = false)
402
- actual = get_table_cell(row, column)
403
- enqueue ?
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
- end
407
+ end
407
408
 
408
- # Set the value of the specified cell in a table object.
409
- #
410
- # @param row [Integer] row number
411
- # @param column [Integer] column number
412
- # @param value [String] text to set
413
- # @example
414
- # list_table.set_table_cell(3, 1, 'Ontario')
415
- #
416
- def set_table_cell(row, column, value)
417
- row_count = get_row_count
418
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
419
- find_table_cell(row, column)
420
- find_table_cell(row, column) unless exists?
421
- set(value)
422
- clear_alt_locator
423
- end
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
- def get_cell_attribute(row, column, attrib)
426
- row_count = get_row_count
427
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
428
- column_count = get_column_count
429
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
430
- set_table_cell_locator(row, column)
431
- result = get_native_attribute(attrib)
432
- clear_alt_locator
433
- result
434
- end
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
- def get_row_attribute(row, attrib)
437
- row_count = get_row_count
438
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
439
- case @locator_type
440
- when :xpath
441
- row > 1 ?
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
- when :css
445
- row > 1 ?
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
- def find_row_attribute(attrib, search_value)
455
- (1..get_row_count).each do |row|
456
- return row if get_row_attribute(row, attrib) == search_value
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
- # Search for the specified text value in the specified row of the table object.
462
- # Returns the number of the first column that contains the search value.
463
- #
464
- # @param row [Integer] row nummber
465
- # @param search_value [String] value to be searched for
466
- # @return [Integer] column number of table cell that contains search value
467
- # @example
468
- # bom_table.find_in_table_row(4, 'High-speed Framus bolts')
469
- #
470
- def find_in_table_row(row, search_value)
471
- (1..get_column_count).each do |column|
472
- return column if get_table_cell(row, column) == search_value
473
- end
474
- nil
475
- end
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
- # Search for the specified text value in the specified column of the table object.
478
- # Returns the number of the first row that contains the search value.
479
- #
480
- # @param column [Integer] column nummber
481
- # @param search_value [String] value to be searched for
482
- # @return [Integer] row number of table cell that contains search value
483
- # @example
484
- # playlist_table.find_in_table_column(1, 'Ashes to Ashes')
485
- #
486
- def find_in_table_column(column, search_value)
487
- (1..get_row_count).each do |row|
488
- return row if get_table_cell(row, column) == search_value
489
- end
490
- nil
491
- end
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
- # Populate the specified row of this table object with the associated data from a Hash passed as an
494
- # argument. Data values must be in the form of a String for textfield and select list controls. For checkbox
495
- # and radio buttons, data must either be a Boolean or a String that evaluates to a Boolean value (Yes, No, 1,
496
- # 0, true, false)
497
- #
498
- # @param data [Hash] column numbers and associated data to be entered
499
- # @example
500
- # data = { 1 => 'Dr.',
501
- # 2 => 'Evangeline',
502
- # 3 => 'Devereaux',
503
- # 4 => 'MD',
504
- # 5 => 'Family Practice'
505
- # }
506
- # clinicians_table.populate_table_row(3, data)
507
- #
508
- def populate_table_row(row, data)
509
- wait_until_exists(2)
510
- data.each do |column, data_param|
511
- unless data_param.blank?
512
- if data_param == '!DELETE'
513
- set_table_cell(row, column, '')
514
- else
515
- set_table_cell(row, column, data_param)
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
- def get_header_columns
555
- columns = []
556
- column_count = get_column_count
557
- (1..column_count).each do |column|
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
- columns.push(get_value(:all)) if exists?(:all)
537
+ click if exists?
538
+ clear_alt_locator
565
539
  end
566
- clear_alt_locator
567
- columns
568
- end
569
540
 
570
- def is_table_row_expanded?(row, column)
571
- row_count = get_row_count
572
- raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
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("#{@alt_locator}/#{@tree_expand}")
546
+ set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
594
547
  when :css
595
- set_alt_locator("#{@alt_locator} > #{@tree_expand}")
548
+ set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
596
549
  end
597
- click if exists?
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
- def collapse_table_row(row, column)
603
- if is_table_row_expanded?(row, column)
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}/#{@tree_collapse}")
579
+ set_alt_locator("#{@alt_locator}/#{@tree_expand}")
608
580
  when :css
609
- set_alt_locator("#{@alt_locator} > #{@tree_collapse}")
581
+ set_alt_locator("#{@alt_locator} > #{@tree_expand}")
610
582
  end
611
- click if exists?
583
+ expanded = true
584
+ expanded = false if exists?
612
585
  clear_alt_locator
586
+ expanded
613
587
  end
614
- end
615
588
 
616
- def expand_all_table_rows(column)
617
- row_count = get_row_count
618
- column_count = get_column_count
619
- raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
620
- row_count.downto(1) do |row|
621
- expand_table_row(row, column)
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
- def get_table_cell_locator(row, column)
626
- case @locator_type
627
- when :xpath
628
- if @table_section.nil?
629
- row_spec = "#{@locator}/#{@table_body}/#{@table_row}"
630
- row_spec = "#{row_spec}[#{row}]"
631
- else
632
- row_spec = "#{@locator}/#{@table_body}/#{@table_section}"
633
- row_spec = "#{row_spec}[#{row}]/#{@table_row}[1]"
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
- column_spec = if @row_header.nil?
636
- "/#{@table_column}[#{column}]"
637
- else
638
- if column == 1
639
- "/#{@row_header}"
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
- "/#{@table_column}[#{column - 1}]"
639
+ if column == 1
640
+ "/#{@row_header}"
641
+ else
642
+ "/#{@table_column}[#{column - 1}]"
643
+ end
642
644
  end
643
- end
644
- when :css
645
- if @table_section.nil?
646
- row_spec = "#{@locator} > #{@table_body} > #{@table_row}"
647
- row_spec = "#{row_spec}:nth-of-type(#{row})"
648
- else
649
- row_spec = "#{@locator} > #{@table_body} > #{@table_section}"
650
- row_spec = "#{row_spec}:nth-of-type(#{row}) > #{@table_row}:nth-of-type(1)"
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
- column_spec = if @row_header.nil?
654
- " > #{@table_column}:nth-of-type(#{column})"
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
- " > #{@table_column}:nth-of-type(#{column - 1})"
657
+ if column == 1
658
+ " > #{@row_header}"
659
+ else
660
+ " > #{@table_column}:nth-of-type(#{column - 1})"
661
+ end
660
662
  end
661
- end
663
+ end
664
+ "#{row_spec}#{column_spec}"
662
665
  end
663
- "#{row_spec}#{column_spec}"
664
- end
665
666
 
666
- private
667
+ private
667
668
 
668
- def set_table_cell_locator(row, column)
669
- set_alt_locator(get_table_cell_locator(row, column))
670
- end
669
+ def set_table_cell_locator(row, column)
670
+ set_alt_locator(get_table_cell_locator(row, column))
671
+ end
671
672
 
672
- def find_table_cell(row, column)
673
- set_table_cell_locator(row, column)
674
- if exists?
675
- click
676
- else
677
- puts "Could not find table cell at #{@alt_locator}"
678
- end
679
- saved_locator = @alt_locator
680
- case @locator_type
681
- when :xpath
682
- set_alt_locator("#{saved_locator}//input")
683
- set_alt_locator("#{saved_locator}//textarea") unless exists?
684
- when :css
685
- set_alt_locator("#{saved_locator} input")
686
- set_alt_locator("#{saved_locator} textarea") unless exists?
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