Method: Appium::Android#ele_index

Defined in:
lib/appium_lib/android/common/helper.rb

#ele_index(class_name, index) ⇒ Element

Find the element of type class_name at matching index.

Parameters:

  • class_name (String)

    the class name to find

  • index (Integer)

    the index

Returns:

  • (Element)

    the found element of type class_name



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/appium_lib/android/common/helper.rb', line 147

def ele_index(class_name, index)
  results = tags(class_name)
  if index == 'last()'
    index = results.length
    index -= 1 if index >= 0
  else
    raise ArgumentError, 'Index must be >= 1' unless index >= 1

    index -= 1 if index >= 1
  end

  # uiautomator has issues with index/instance so calculate the index
  # client side.
  results[index]
end