Sha256: 46ce57f0e2e0a37db8fab771aa11181a2f21c9328b217017d7f23d2f374e8a26

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module TestCentricity
  class List < UIElement
    attr_accessor :list_item

    def initialize(name, parent, locator, context)
      super
      @type = :list
      define_list_elements({ :list_item => 'li' })
    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 object '#{get_name}' (#{get_locator})") :
          assert_equal(expected, actual, "Expected list object '#{get_name}' (#{get_locator}) to be #{expected} but found #{actual}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
testcentricity_web-1.0.12 lib/testcentricity_web/elements/list.rb
testcentricity_web-1.0.11 lib/testcentricity_web/elements/list.rb