Sha256: 898718976777cc78d6a1e90748383736883901b2181c4690dac2ae302df11a77

Contents?: true

Size: 1.56 KB

Versions: 73

Compression:

Stored size: 1.56 KB

Contents

module TestCentricity
  class ListElement < UIElement
    attr_accessor :list
    attr_accessor :element_locator

    def initialize(name, parent, locator, context, list, proxy = nil)
      @name            = name
      @parent          = parent
      @context         = context
      @alt_locator     = nil
      @list            = list
      @element_locator = locator

      set_locator_type(@list.get_locator)

      if locator.nil?
        @locator = list.get_list_row_locator('ROW_SPEC')
      else
        case @locator_type
        when :xpath
          @locator = "#{list.get_list_row_locator('ROW_SPEC')}/#{@element_locator}"
        when :css
          @locator = "#{list.get_list_row_locator('ROW_SPEC')} > #{@element_locator}"
        end
      end
    end

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

    def click(row)
      obj, = find_list_element(row)
      list_object_not_found_exception(obj, @type, row)
      obj.click
    end

    def get_value(row, visible = true)
      obj, = find_list_element(row, visible)
      list_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_list_element(row, visible = true)
      set_alt_locator("#{@locator.gsub('ROW_SPEC', row.to_s)}")
      find_element(visible)
    end

    def list_object_not_found_exception(obj, obj_type, row)
      object_not_found_exception(obj, "Row #{row} #{obj_type}")
    end
  end
end

Version data entries

73 entries across 73 versions & 2 rubygems

Version Path
testcentricity_web-3.2.0 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.11 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.10 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.9.1 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.9 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.8 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.7 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.6 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.5.1 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.5 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.4 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.3 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.2 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.1 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.1.0 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.0.20 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.0.19.1 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.0.19 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.0.18 lib/testcentricity_web/web_elements/list_element.rb
testcentricity_web-3.0.17 lib/testcentricity_web/web_elements/list_element.rb