module Appium::Ios::Xcuitest::Element
Public Instance Methods
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 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
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
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
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
Find the first TextField. @return [TextField]
# File lib/appium_lib/ios/xcuitest/element/textfield.rb, line 66 def first_textfield _textfield_with_predicate end
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
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
@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
@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
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
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
@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
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
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
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
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
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
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
@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
@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
# 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
Return visible elements.
# File lib/appium_lib/ios/xcuitest/element/generic.rb, line 59 def select_visible_elements(elements) elements.select(&:displayed?) end