Class: TestCentricity::AppList

Inherits:
AppUIElement show all
Defined in:
lib/testcentricity/app_elements/list.rb

Instance Attribute Summary

Attributes inherited from AppUIElement

#context, #locator, #name, #parent, #type

Instance Method Summary collapse

Methods inherited from AppUIElement

#clear, #click, #disabled?, #double_tap, #enabled?, #exists?, #get_attribute, #get_caption, #get_locator, #get_name, #get_object_type, #get_value, #height, #hidden?, #scroll, #selected?, #send_keys, #set, #swipe, #tag_name, #tap, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible, #width, #x_loc, #y_loc

Constructor Details

#initialize(name, parent, locator, context) ⇒ AppList

Returns a new instance of AppList.



3
4
5
6
# File 'lib/testcentricity/app_elements/list.rb', line 3

def initialize(name, parent, locator, context)
  super
  @type = :list
end

Instance Method Details

#get_item_count ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/testcentricity/app_elements/list.rb', line 8

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

#get_list_item(index) ⇒ Object



23
24
25
# File 'lib/testcentricity/app_elements/list.rb', line 23

def get_list_item(index)

end

#get_list_items ⇒ Object



19
20
21
# File 'lib/testcentricity/app_elements/list.rb', line 19

def get_list_items

end

#wait_until_item_count_changes(seconds = nil) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/testcentricity/app_elements/list.rb', line 35

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

#wait_until_item_count_is(value, seconds = nil) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/testcentricity/app_elements/list.rb', line 27

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 { get_item_count == value }
rescue
  raise "Value of List #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_item_count == value
end