Class: TestCentricity::Table
- Defined in:
- lib/testcentricity_web/elements/table.rb
Instance Attribute Summary collapse
-
#header_column ⇒ Object
Returns the value of attribute header_column.
-
#header_row ⇒ Object
Returns the value of attribute header_row.
-
#table_body ⇒ Object
Returns the value of attribute table_body.
-
#table_column ⇒ Object
Returns the value of attribute table_column.
-
#table_header ⇒ Object
Returns the value of attribute table_header.
-
#table_row ⇒ Object
Returns the value of attribute table_row.
-
#table_section ⇒ Object
Returns the value of attribute table_section.
-
#tree_collapse ⇒ Object
Returns the value of attribute tree_collapse.
-
#tree_expand ⇒ Object
Returns the value of attribute tree_expand.
Attributes inherited from UIElement
#alt_locator, #context, #locator, #parent, #type
Instance Method Summary collapse
-
#click_header_column(column) ⇒ Object
Click in the specified column header in a table object.
-
#click_table_cell(row, column) ⇒ Object
Click in the specified cell in a table object.
-
#click_table_cell_link(row, column) ⇒ Object
Click the link object embedded within the specified cell in a table object.
- #collapse_table_row(row, column) ⇒ Object
- #define_table_elements(element_spec) ⇒ Object
-
#double_click_table_cell(row, column) ⇒ Object
Double-click in the specified cell in a table object.
- #expand_all_table_rows(column) ⇒ Object
- #expand_table_row(row, column) ⇒ Object
-
#find_in_table_column(column, search_value) ⇒ Integer
Search for the specified text value in the specified column of the table object.
-
#find_in_table_row(row, search_value) ⇒ Integer
Search for the specified text value in the specified row of the table object.
-
#get_column_count ⇒ Integer
Return number of columns in a table object.
- #get_header_column(column) ⇒ Object
- #get_header_columns ⇒ Object
-
#get_row_count ⇒ Integer
Return number of rows in a table object.
- #get_row_data(row) ⇒ Object
-
#get_table_cell(row, column) ⇒ String
Return text contained in specified cell of a table object.
- #get_table_column(column) ⇒ Object
- #get_table_row(row) ⇒ Object
-
#hover_table_cell(row, column) ⇒ Object
Hover over the specified cell in a table object.
-
#initialize(parent, locator, context) ⇒ Table
constructor
A new instance of Table.
- #is_table_row_expanded?(row, column) ⇒ Boolean
-
#populate_table_row(row, data) ⇒ Object
Populate the specified row of this table object with the associated data from a Hash passed as an argument.
-
#set_table_cell(row, column, value) ⇒ Object
Set the value of the specified cell in a table object.
- #verify_table_cell(row, column, expected, enqueue = false) ⇒ Object
Methods inherited from UIElement
#clear_alt_locator, #click, #click_at, #disabled?, #double_click, #drag_by, #enabled?, #exists?, #get_attribute, #get_locator, #get_native_attribute, #get_object_type, #get_siebel_object_type, #get_value, #hidden?, #hover, #invoke_siebel_dialog, #send_keys, #set, #set_alt_locator, #verify_value, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible
Constructor Details
#initialize(parent, locator, context) ⇒ Table
Returns a new instance of Table.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/testcentricity_web/elements/table.rb', line 13 def initialize(parent, locator, context) @parent = parent @locator = locator @context = context @type = :table @alt_locator = nil table_spec = { :table_body => 'tbody', :table_section => nil, :table_row => 'tr', :table_column => 'td', :table_header => 'thead', :header_row => 'tr', :header_column => 'th', :tree_expand => "div/div[contains(@class, 'tree-plus treeclick')]", :tree_collapse => "div/div[contains(@class, 'tree-minus treeclick')]" } define_table_elements(table_spec) end |
Instance Attribute Details
#header_column ⇒ Object
Returns the value of attribute header_column.
9 10 11 |
# File 'lib/testcentricity_web/elements/table.rb', line 9 def header_column @header_column end |
#header_row ⇒ Object
Returns the value of attribute header_row.
8 9 10 |
# File 'lib/testcentricity_web/elements/table.rb', line 8 def header_row @header_row end |
#table_body ⇒ Object
Returns the value of attribute table_body.
3 4 5 |
# File 'lib/testcentricity_web/elements/table.rb', line 3 def table_body @table_body end |
#table_column ⇒ Object
Returns the value of attribute table_column.
6 7 8 |
# File 'lib/testcentricity_web/elements/table.rb', line 6 def table_column @table_column end |
#table_header ⇒ Object
Returns the value of attribute table_header.
7 8 9 |
# File 'lib/testcentricity_web/elements/table.rb', line 7 def table_header @table_header end |
#table_row ⇒ Object
Returns the value of attribute table_row.
5 6 7 |
# File 'lib/testcentricity_web/elements/table.rb', line 5 def table_row @table_row end |
#table_section ⇒ Object
Returns the value of attribute table_section.
4 5 6 |
# File 'lib/testcentricity_web/elements/table.rb', line 4 def table_section @table_section end |
#tree_collapse ⇒ Object
Returns the value of attribute tree_collapse.
11 12 13 |
# File 'lib/testcentricity_web/elements/table.rb', line 11 def tree_collapse @tree_collapse end |
#tree_expand ⇒ Object
Returns the value of attribute tree_expand.
10 11 12 |
# File 'lib/testcentricity_web/elements/table.rb', line 10 def @tree_expand end |
Instance Method Details
#click_header_column(column) ⇒ Object
Click in the specified column header in a table object.
350 351 352 353 354 355 356 |
# File 'lib/testcentricity_web/elements/table.rb', line 350 def click_header_column(column) column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{@locator}" if column > column_count set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]") click if exists? clear_alt_locator end |
#click_table_cell(row, column) ⇒ Object
Click in the specified cell in a table object.
120 121 122 123 124 125 126 127 128 |
# File 'lib/testcentricity_web/elements/table.rb', line 120 def click_table_cell(row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) click clear_alt_locator end |
#click_table_cell_link(row, column) ⇒ Object
Click the link object embedded within the specified cell in a table object.
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/testcentricity_web/elements/table.rb', line 154 def click_table_cell_link(row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) saved_locator = @alt_locator set_alt_locator("#{@alt_locator}/a") set_alt_locator("#{saved_locator}/span/a") unless exists? # if link not present, check for text entry fields and try to dismiss by tabbing out unless exists? set_alt_locator("#{saved_locator}/input") set_alt_locator("#{saved_locator}/textarea") unless exists? send_keys(:tab) if exists? set_alt_locator("#{saved_locator}/a") set_alt_locator("#{saved_locator}/span/a") unless exists? send_keys(:tab) unless exists? end wait_until_exists(1) click clear_alt_locator end |
#collapse_table_row(row, column) ⇒ Object
400 401 402 403 404 405 406 407 |
# File 'lib/testcentricity_web/elements/table.rb', line 400 def collapse_table_row(row, column) if (row, column) set_table_cell_locator(row, column) set_alt_locator("#{@alt_locator}/#{@tree_collapse}") click if exists? clear_alt_locator end end |
#define_table_elements(element_spec) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/testcentricity_web/elements/table.rb', line 33 def define_table_elements(element_spec) element_spec.each do | element, value | case element when :table_body @table_body = value when :table_section @table_section = value when :table_row @table_row = value when :table_column @table_column = value when :table_header @table_header = value when :header_row @header_row = value when :header_column @header_column = value when :tree_expand @tree_expand = value when :tree_collapse @tree_collapse = value end end end |
#double_click_table_cell(row, column) ⇒ Object
Double-click in the specified cell in a table object.
137 138 139 140 141 142 143 144 145 |
# File 'lib/testcentricity_web/elements/table.rb', line 137 def double_click_table_cell(row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) double_click clear_alt_locator end |
#expand_all_table_rows(column) ⇒ Object
409 410 411 412 413 414 415 416 |
# File 'lib/testcentricity_web/elements/table.rb', line 409 def (column) row_count = get_row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count row_count.downto(1) do |row| (row, column) end end |
#expand_table_row(row, column) ⇒ Object
391 392 393 394 395 396 397 398 |
# File 'lib/testcentricity_web/elements/table.rb', line 391 def (row, column) unless (row, column) set_table_cell_locator(row, column) set_alt_locator("#{@alt_locator}/#{@tree_expand}") click if exists? clear_alt_locator end end |
#find_in_table_column(column, search_value) ⇒ Integer
Search for the specified text value in the specified column of the table object. Returns the number of the first row that contains the search value.
309 310 311 312 313 314 |
# File 'lib/testcentricity_web/elements/table.rb', line 309 def find_in_table_column(column, search_value) (1..get_row_count).each do |row| return row if get_table_cell(row, column) == search_value end nil end |
#find_in_table_row(row, search_value) ⇒ Integer
Search for the specified text value in the specified row of the table object. Returns the number of the first column that contains the search value.
293 294 295 296 297 298 |
# File 'lib/testcentricity_web/elements/table.rb', line 293 def find_in_table_row(row, search_value) (1..get_column_count).each do |column| return column if get_table_cell(row, column) == search_value end nil end |
#get_column_count ⇒ Integer
Return number of columns in a table object.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/testcentricity_web/elements/table.rb', line 79 def get_column_count row_count = get_row_count if row_count == 0 page.all(:xpath, "#{@locator}/#{@table_header}/#{@header_row}/#{@header_column}", :visible => :all).count else if @table_section.nil? (row_count == 1) ? page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}/#{@table_column}", :visible => :all).count : page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}[2]/#{@table_column}", :visible => :all).count else (row_count == 1) ? page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_section}/#{@table_row}/#{@table_column}", :visible => :all).count : page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_section}[2]/#{@table_row}/#{@table_column}", :visible => :all).count end end end |
#get_header_column(column) ⇒ Object
358 359 360 361 362 363 364 365 |
# File 'lib/testcentricity_web/elements/table.rb', line 358 def get_header_column(column) column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{@locator}" if column > column_count set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]") value = get_value(:all) if exists?(:all) clear_alt_locator value end |
#get_header_columns ⇒ Object
367 368 369 370 371 372 373 374 375 376 |
# File 'lib/testcentricity_web/elements/table.rb', line 367 def get_header_columns columns = [] column_count = get_column_count (1..column_count).each do |column| set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]") columns.push(get_value(:all)) if exists?(:all) end clear_alt_locator columns end |
#get_row_count ⇒ Integer
Return number of rows in a table object.
64 65 66 67 68 69 70 71 |
# File 'lib/testcentricity_web/elements/table.rb', line 64 def get_row_count wait_until_exists(5) if @table_section.nil? page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}", :visible => :all).count else page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_section}", :visible => :all).count end end |
#get_row_data(row) ⇒ Object
198 199 200 201 202 203 204 205 206 207 |
# File 'lib/testcentricity_web/elements/table.rb', line 198 def get_row_data(row) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count (row > 1) ? set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}[#{row}]") : set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}") value = get_value if exists? clear_alt_locator value end |
#get_table_cell(row, column) ⇒ String
Return text contained in specified cell of a table object.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/testcentricity_web/elements/table.rb', line 238 def get_table_cell(row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) saved_locator = @alt_locator set_alt_locator("#{saved_locator}/input") unless exists? set_alt_locator("#{saved_locator}/textarea") set_alt_locator(saved_locator) unless exists? end if exists? value = get_value else puts "Could not find table cell at #{@alt_locator}" value = '' end clear_alt_locator value end |
#get_table_column(column) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/testcentricity_web/elements/table.rb', line 209 def get_table_column(column) rows = [] column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count row_count = get_row_count (1..row_count).each do |row| value = '' set_table_cell_locator(row, column) saved_locator = @alt_locator set_alt_locator("#{saved_locator}/input") unless exists? set_alt_locator("#{saved_locator}/textarea") set_alt_locator(saved_locator) unless exists? end value = get_value if exists? rows.push(value) end clear_alt_locator rows end |
#get_table_row(row) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/testcentricity_web/elements/table.rb', line 177 def get_table_row(row) columns = [] row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count (1..column_count).each do |column| value = '' set_table_cell_locator(row, column) saved_locator = @alt_locator set_alt_locator("#{saved_locator}/input") unless exists? set_alt_locator("#{saved_locator}/textarea") set_alt_locator(saved_locator) unless exists? end value = get_value if exists? columns.push(value) end clear_alt_locator columns end |
#hover_table_cell(row, column) ⇒ Object
Hover over the specified cell in a table object.
103 104 105 106 107 108 109 110 111 |
# File 'lib/testcentricity_web/elements/table.rb', line 103 def hover_table_cell(row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) hover clear_alt_locator end |
#is_table_row_expanded?(row, column) ⇒ Boolean
378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/testcentricity_web/elements/table.rb', line 378 def (row, column) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count column_count = get_column_count raise "Column #{column} exceeds number of columns (#{column_count}) in table #{@locator}" if column > column_count set_table_cell_locator(row, column) set_alt_locator("#{@alt_locator}/#{@tree_expand}") = true = false if exists? clear_alt_locator end |
#populate_table_row(row, data) ⇒ Object
Populate the specified row of this table object with the associated data from a Hash passed as an argument. Data values must be in the form of a String for textfield and select list controls. For checkbox and radio buttons, data must either be a Boolean or a String that evaluates to a Boolean value (Yes, No, 1, 0, true, false)
331 332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/testcentricity_web/elements/table.rb', line 331 def populate_table_row(row, data) wait_until_exists(2) data.each do | column, data_param | unless data_param.blank? if data_param == '!DELETE' set_table_cell(row, column, '') else set_table_cell(row, column, data_param) end end end end |
#set_table_cell(row, column, value) ⇒ Object
Set the value of the specified cell in a table object.
275 276 277 278 279 280 281 282 |
# File 'lib/testcentricity_web/elements/table.rb', line 275 def set_table_cell(row, column, value) row_count = get_row_count raise "Row #{row} exceeds number of rows (#{row_count}) in table #{@locator}" if row > row_count find_table_cell(row, column) find_table_cell(row, column) unless exists? set(value) clear_alt_locator end |
#verify_table_cell(row, column, expected, enqueue = false) ⇒ Object
260 261 262 263 264 265 |
# File 'lib/testcentricity_web/elements/table.rb', line 260 def verify_table_cell(row, column, expected, enqueue = false) actual = get_table_cell(row, column) enqueue ? ExceptionQueue.enqueue_assert_equal(expected.strip, actual.strip, "Expected #{@locator} row #{row}/column #{column}") : assert_equal(expected.strip, actual.strip, "Expected #{@locator} row #{row}/column #{column} to display '#{expected}' but found '#{actual}'") end |