Sha256: 252aa883767fee264c346ec189db70861f95d6e2556e0d3dfaa71fca99327436

Contents?: true

Size: 1.19 KB

Versions: 12

Compression:

Stored size: 1.19 KB

Contents

module TestCentricity
  class List < UIElement
    attr_accessor :list_item

    def initialize(parent, locator, context)
      @parent  = parent
      @locator = locator
      @context = context
      @type    = :list
      @alt_locator = nil
      list_spec = { :list_item => 'li' }
      define_list_elements(list_spec)
    end

    def define_list_elements(element_spec)
      element_spec.each do | element, value |
        case element
          when :list_item
            @list_item = value
        end
      end
    end

    def get_list_items(element_spec = nil)
      define_list_elements(element_spec) unless element_spec.nil?
      obj, _ = find_element
      object_not_found_exception(obj, nil)
      obj.all(@list_item).collect(&:text)
    end

    def get_item_count
      obj, _ = find_element
      object_not_found_exception(obj, nil)
      obj.all(@list_item).count
    end

    def verify_list_items(expected, enqueue = false)
      actual = get_list_items
      enqueue ?
          ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list  #{@locator}") :
          assert_equal(expected, actual, "Expected list #{@locator} to be #{expected} but found #{actual}")
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
testcentricity_web-1.0.10 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.9 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.8 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.7 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.6 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.5 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.4 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.3 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.2 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.1 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.0.1 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.0 lib/testcentricity_web/elements/list.rb