module Appium::Ios::Xcuitest::Element

Public Instance Methods

button(value) click to toggle source

Find the first UIAButton|XCUIElementTypeButton that contains value or by index. @param value [String, Integer] the value to exactly match. If int then the UIAButton|XCUIElementTypeButton at that index is returned. @return [UIA_BUTTON|XCUIELEMENT_TYPE_BUTTON]

# File lib/appium_lib/ios/xcuitest/element/button.rb, line 31
def button(value)
  # return button at index.
  return ele_index button_class, value if value.is_a? Numeric

  raise_error_if_no_element buttons(value).first
end
button_class() click to toggle source

@return [String] Class name for button

# File lib/appium_lib/ios/xcuitest/element/button.rb, line 23
def button_class
  ::Appium::Ios::XCUIELEMENT_TYPE_BUTTON
end
button_exact(value) click to toggle source

Find the first UIAButton|XCUIElementTypeButton that exactly matches value. @param value [String] the value to match exactly @return [UIA_BUTTON|XCUIELEMENT_TYPE_BUTTON]

# File lib/appium_lib/ios/xcuitest/element/button.rb, line 66
def button_exact(value)
  raise_error_if_no_element buttons_exact(value).first
end
buttons(value = false) click to toggle source

Find all UIAButtons|XCUIElementTypeButtons containing value. If value is omitted, all UIAButtons|XCUIElementTypeButtons are returned. @param value [String] the value to search for @return [Array<UIA_BUTTON|XCUIELEMENT_TYPE_BUTTON>]

# File lib/appium_lib/ios/xcuitest/element/button.rb, line 42
def buttons(value = false)
  return tags button_class unless value

  elements = find_eles_by_predicate_include(class_name: button_class, value: value)
  select_visible_elements elements
end
buttons_exact(value) click to toggle source

Find all UIAButtons|XCUIElementTypeButtons that exactly match value. @param value [String] the value to match exactly @return [Array<UIA_BUTTON|XCUIELEMENT_TYPE_BUTTON>]

# File lib/appium_lib/ios/xcuitest/element/button.rb, line 73
def buttons_exact(value)
  elements = find_eles_by_predicate(class_name: button_class, value: value)
  select_visible_elements elements
end
find(value) click to toggle source

Find the first element containing value @param value [String] the value to search for @return [Element]

# File lib/appium_lib/ios/xcuitest/element/generic.rb, line 22
def find(value)
  raise_error_if_no_element finds(value).first
end
find_exact(value) click to toggle source

Find the first element exactly matching value @param value [String] the value to search for @return [Element]

# File lib/appium_lib/ios/xcuitest/element/generic.rb, line 37
def find_exact(value)
  raise_error_if_no_element finds_exact(value).first
end
finds(value) click to toggle source

Find all elements containing value @param value [String] the value to search for @return [Array<Element>]

# File lib/appium_lib/ios/xcuitest/element/generic.rb, line 29
def finds(value)
  elements = find_eles_by_predicate_include value: value
  select_visible_elements elements
end
finds_exact(value) click to toggle source

Find all elements exactly matching value @param value [String] the value to search for @return [Array<Element>]

# File lib/appium_lib/ios/xcuitest/element/generic.rb, line 44
def finds_exact(value)
  elements = find_eles_by_predicate value: value
  select_visible_elements elements
end
first_button() click to toggle source

Find the first UIAButton|XCUIElementTypeButton. @return [UIA_BUTTON|XCUIELEMENT_TYPE_BUTTON]

# File lib/appium_lib/ios/xcuitest/element/button.rb, line 51
def first_button
  first_ele button_class
end
first_text() click to toggle source

Find the first UIAStaticText|XCUIElementTypeStaticText. @return [UIA_STATIC_TEXT|XCUIELEMENT_TYPE_STATIC_TEXT]

# File lib/appium_lib/ios/xcuitest/element/text.rb, line 50
def first_text
  first_ele static_text_class
end
first_textfield() click to toggle source

Find the first TextField. @return [TextField]

# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 66
def first_textfield
  _textfield_with_predicate
end
last_button() click to toggle source

TODO: add documentation regarding previous element.

Previous UIAElement is differ from UIAButton|XCUIElementTypeButton. So, the results are different.

Find the last UIAButton|XCUIElementTypeButton. @return [UIA_BUTTON|XCUIELEMENT_TYPE_BUTTON]

# File lib/appium_lib/ios/xcuitest/element/button.rb, line 59
def last_button
  last_ele button_class
end
last_text() click to toggle source

Find the last UIAStaticText|XCUIElementTypeStaticText. @return [UIA_STATIC_TEXT|XCUIELEMENT_TYPE_STATIC_TEXT]

# File lib/appium_lib/ios/xcuitest/element/text.rb, line 56
def last_text
  last_ele static_text_class
end
last_textfield() click to toggle source

Find the last TextField. @return [TextField]

# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 72
def last_textfield
  result = _textfields_with_predicate.last
  raise _no_such_element if result.nil?

  result
end
secure_text_field_class() click to toggle source

@return [String] Class name for secure text field

# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 28
def secure_text_field_class
  ::Appium::Ios::XCUIELEMENT_TYPE_SECURE_TEXT_FIELD
end
static_text_class() click to toggle source

@return [String] Class name for text

# File lib/appium_lib/ios/xcuitest/element/text.rb, line 23
def static_text_class
  ::Appium::Ios::XCUIELEMENT_TYPE_STATIC_TEXT
end
text(value) click to toggle source

Find the first UIAStaticText|XCUIElementTypeStaticText that contains value or by index. @param value [String, Integer] the value to find. If int then the UIAStaticText|XCUIElementTypeStaticText at that index is returned. @return [UIA_STATIC_TEXT|XCUIELEMENT_TYPE_STATIC_TEXT]

# File lib/appium_lib/ios/xcuitest/element/text.rb, line 31
def text(value)
  return ele_index static_text_class, value if value.is_a? Numeric

  raise_error_if_no_element texts(value).first
end
text_exact(value) click to toggle source

Find the first UIAStaticText|XCUIElementTypeStaticText that exactly matches value. @param value [String] the value to match exactly @return [UIA_STATIC_TEXT|XCUIELEMENT_TYPE_STATIC_TEXT]

# File lib/appium_lib/ios/xcuitest/element/text.rb, line 63
def text_exact(value)
  raise_error_if_no_element texts_exact(value).first
end
text_field_class() click to toggle source

@return [String] Class name for text field

# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 23
def text_field_class
  ::Appium::Ios::XCUIELEMENT_TYPE_TEXT_FIELD
end
textfield(value) click to toggle source

Find the first TextField that contains value or by index. Note: Uses XPath @param value [String, Integer] the text to match exactly. If int then the TextField at that index is returned. @return [TextField]

# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 37
def textfield(value)
  if value.is_a? Numeric
    index = value
    raise ArgumentError, "#{index} is not a valid index. Must be >= 1" if index <= 0

    index -= 1 # eles_by_json and _textfields_with_predicate is 0 indexed.
    result = _textfields_with_predicate[index]
    raise _no_such_element if result.nil?

    return result

  end

  raise_error_if_no_element textfields(value).first
end
textfield_exact(value) click to toggle source

Find the first TextField that exactly matches value. @param value [String] the value to match exactly @return [TextField]

# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 82
def textfield_exact(value)
  raise_error_if_no_element textfields_exact(value).first
end
textfields(value = false) click to toggle source

Find all TextFields containing value. If value is omitted, all TextFields are returned. @param value [String] the value to search for @return [Array<TextField>]

# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 57
def textfields(value = false)
  return tags_include(class_names: [text_field_class, secure_text_field_class]) unless value

  elements = tags_include class_names: [text_field_class, secure_text_field_class], value: value
  select_visible_elements elements
end
textfields_exact(value) click to toggle source

Find all TextFields that exactly match value. @param value [String] the value to match exactly @return [Array<TextField>]

# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 89
def textfields_exact(value)
  elements = tags_exact class_names: [text_field_class, secure_text_field_class], value: value
  select_visible_elements elements
end
texts(value = false) click to toggle source

Find all UIAStaticTexts|XCUIElementTypeStaticTexts containing value. If value is omitted, all UIAStaticTexts|XCUIElementTypeStaticTexts are returned @param value [String] the value to search for @return [Array<UIA_STATIC_TEXT|XCUIELEMENT_TYPE_STATIC_TEXT>]

# File lib/appium_lib/ios/xcuitest/element/text.rb, line 41
def texts(value = false)
  return tags static_text_class unless value

  elements = find_eles_by_predicate_include(class_name: static_text_class, value: value)
  select_visible_elements elements
end
texts_exact(value) click to toggle source

Find all UIAStaticTexts|XCUIElementTypeStaticTexts that exactly match value. @param value [String] the value to match exactly @return [Array<UIA_STATIC_TEXT|XCUIELEMENT_TYPE_STATIC_TEXT>]

# File lib/appium_lib/ios/xcuitest/element/text.rb, line 70
def texts_exact(value)
  elements = find_eles_by_predicate(class_name: static_text_class, value: value)
  select_visible_elements elements
end

Private Instance Methods

_textfield_with_predicate() click to toggle source

@private for XCUITest

# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 98
def _textfield_with_predicate
  raise_error_if_no_element _textfields_with_predicate.first
end
_textfields_with_predicate() click to toggle source

@private for XCUITest

# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 104
def _textfields_with_predicate
  elements = tags_include(class_names: [text_field_class, secure_text_field_class])
  select_visible_elements elements
end
raise_error_if_no_element(element) click to toggle source
# File lib/appium_lib/ios/xcuitest/element/generic.rb, line 51
def raise_error_if_no_element(element)
  error_message = 'An element could not be located on the page using the given search parameters.'
  raise(::Selenium::WebDriver::Error::NoSuchElementError, error_message) if element.nil?

  element
end
select_visible_elements(elements) click to toggle source

Return visible elements.

# File lib/appium_lib/ios/xcuitest/element/generic.rb, line 59
def select_visible_elements(elements)
  elements.select(&:displayed?)
end