Sha256: 529efe7d1a73e11a82a2d1f16340f0c8a68c7de06e87c69be50ee0c6755bc729

Contents?: true

Size: 1.85 KB

Versions: 26

Compression:

Stored size: 1.85 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

      set_locator_type(@table.get_locator)
      set_column(column)
    end

    def set_column(column)
      @column  = column
      @locator = case @locator_type
                 when :xpath
                   "#{@table.get_table_cell_locator('ROW_SPEC', @column)}/#{@element_locator}"
                 when :css
                   "#{@table.get_table_cell_locator('ROW_SPEC', @column)} > #{@element_locator}"
                 end
    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

26 entries across 26 versions & 1 rubygems

Version Path
testcentricity_web-3.3.0 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.25 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.24 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.23 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.22 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.21 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.20 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.19 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.18 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.17 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.16 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.15 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.14 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.13 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.12 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.11 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.10 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.9 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.8 lib/testcentricity_web/web_elements/cell_element.rb
testcentricity_web-3.2.7 lib/testcentricity_web/web_elements/cell_element.rb