Method: AX::Row#child_in_column

Defined in:
lib/ax/row.rb

#child_in_column(filters, &block) ⇒ AX::Element

Retrieve the child in a row that corresponds to a specific column. You must pass filters here in the same way that you would for a search or wait.

This is useful for tables where it is difficult to identify which row item is the one you want based on the row items themselves. Often times the columns in the table will have identifying attributes, such as a header, and so you can use this method to figure out what column your row item is in and then the method will return the row item you wanted.

Examples:


rows  = table.rows
total = rows.inject(0) { |sum, row|
  sum += row.child_in_column(header: 'Price').value.to_i
}
puts "The average price is $ #{total / rows.size}"

Parameters:

Returns:

Raises:



30
31
32
33
34
35
# File 'lib/ax/row.rb', line 30

def child_in_column filters, &block
  qualifier = Accessibility::Qualifier.new(:Column, filters, &block)
  column    = self.parent.columns.index { |x| qualifier.qualifies? x }
  return self.children.at(column) if column
  raise Accessibility::SearchFailure.new(self.parent, 'column', filters, &block)
end