Sha256: 524129acdc2f97b0ba6260d47fc21f00ce6f53eda74baa37df68c74f975cc3b6

Contents?: true

Size: 1.81 KB

Versions: 3

Compression:

Stored size: 1.81 KB

Contents

module TestCentricity
  class AppList < AppUIElement
    def initialize(name, parent, locator, context)
      super
      @type = :list
    end

    def get_item_count
      obj = element
      object_not_found_exception(obj)
      if Environ.device_os == :ios
        items = obj.find_elements(:class, 'XCUIElementTypeCell')
      else
        items = obj.find_elements(:class, 'android.widget.FrameLayout')
      end
      items.size
    end

    def get_list_items

    end

    def get_list_item(index)

    end

    # Wait until the list's item_count equals the specified value, or until the specified wait time has expired. If the wait
    # time is nil, then the wait time will be Environ.default_max_wait_time.
    #
    # @param value [Integer or Hash] value expected or comparison hash
    # @param seconds [Integer or Float] wait time in seconds
    # @example
    #   search_results_list.wait_until_item_count_is(10, 15)
    #     or
    #   search_results_list.wait_until_item_count_is({ :greater_than_or_equal => 1 }, 5)
    #
    def wait_until_item_count_is(value, seconds = nil)
      timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
      wait = Selenium::WebDriver::Wait.new(timeout: timeout)
      wait.until { compare(value, get_item_count) }
    rescue
      raise "Value of List #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_item_count == value
    end

    def wait_until_item_count_changes(seconds = nil)
      value = get_item_count
      timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
      wait = Selenium::WebDriver::Wait.new(timeout: timeout)
      wait.until { get_item_count != value }
    rescue
      raise "Value of List #{object_ref_message} failed to change from '#{value}' after #{timeout} seconds" if get_item_count == value
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
testcentricity-2.3.19 lib/testcentricity/app_elements/list.rb
testcentricity-2.3.18 lib/testcentricity/app_elements/list.rb
testcentricity-2.3.17 lib/testcentricity/app_elements/list.rb