Sha256: aca150737b6844833f37fdceca78914fceea8d1115c03d628a45235683794d95

Contents?: true

Size: 1.68 KB

Versions: 15

Compression:

Stored size: 1.68 KB

Contents

module TestCentricity
  class CellElement < UIElement
    attr_accessor :table
    attr_accessor :column
    attr_accessor :element_locator

    def initialize(name, parent, locator, context, table, column, proxy = nil)
      @name            = name
      @parent          = parent
      @context         = context
      @alt_locator     = nil
      @table           = table
      @column          = column
      @element_locator = locator
      @locator         = "#{@table.get_table_cell_locator('ROW_SPEC', @column)}/#{@element_locator}"
    end

    def set_column(column)
      @column  = column
      @locator = "#{@table.get_table_cell_locator('ROW_SPEC', @column)}/#{@element_locator}"
    end

    def exists?(row)
      obj, = find_cell_element(row)
      obj != nil
    end

    def click(row)
      obj, = find_cell_element(row)
      cell_object_not_found_exception(obj, @type, row)
      obj.click
    end

    def get_native_attribute(row, attrib)
      obj, = find_cell_element(row)
      cell_object_not_found_exception(obj, @type, row)
      obj.get_native_attribute(attrib)
    end

    def get_value(row, visible = true)
      obj, = find_cell_element(row, visible)
      cell_object_not_found_exception(obj, @type, row)
      case obj.tag_name.downcase
      when 'input', 'select', 'textarea'
        obj.value
      else
        obj.text
      end
    end

    alias get_caption get_value

    def find_cell_element(row, visible = true)
      set_alt_locator("#{@locator.gsub('ROW_SPEC', row.to_s)}")
      find_element(visible)
    end

    def cell_object_not_found_exception(obj, obj_type, row)
      object_not_found_exception(obj, "Row #{row}/Col #{@column} #{obj_type}")
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
testcentricity_web-2.1.10 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.1.9 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.1.8.3 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.1.7 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.1.6 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.1.5 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.1.4 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.1.3 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.1.2 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.1.1 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.1.0 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.0.23 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.0.21 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.0.20.1 lib/testcentricity_web/elements/cell_element.rb
testcentricity_web-2.0.20 lib/testcentricity_web/elements/cell_element.rb