module Appium::Ios

Constants

UIAButton
UIASecureTextField
UIAStaticText
UIATextField
UIA_BUTTON
UIA_SECURE_TEXT_FIELD
UIA_STATIC_TEXT
UIA_TEXT_FIELD
XCUIELEMENT_TYPE_BUTTON
XCUIELEMENT_TYPE_SECURE_TEXT_FIELD
XCUIELEMENT_TYPE_STATIC_TEXT
XCUIELEMENT_TYPE_TEXT_FIELD
XCUIElementTypeButton
XCUIElementTypeSecureTextField
XCUIElementTypeStaticText
XCUIElementTypeTextField

Public Instance Methods

_all_pred(opts) click to toggle source

predicate - the predicate to evaluate on the main app

visible - if true, only visible elements are returned. default true

# File lib/appium_lib/ios/common/helper.rb, line 377
def _all_pred(opts)
  predicate = opts[:predicate]
  raise 'predicate must be provided' unless predicate

  visible = opts.fetch :visible, true
  %($.mainApp().getAllWithPredicate("#{predicate}", #{visible});)
end
_by_json(opts) click to toggle source

For Appium(automation name), not XCUITest typeArray - array of string types to search for. Example: [“UIAStaticText”] onlyFirst - boolean. returns only the first result if true. Example: true onlyVisible - boolean. returns only visible elements if true. Example: true target - string. the target value to search for. Example: “Buttons, Various uses of UIButton” substring - boolean. matches on substrings if true otherwise an exact mathc is required. Example: true insensitive - boolean. ignores case sensitivity if true otherwise it's case sensitive. Example: true

opts = {

typeArray: ["UIAStaticText"],
onlyFirst: true,
onlyVisible: true,
name: {
  target: "Buttons, Various uses of UIButton",
  substring: false,
  insensitive: false,
},
label: {
  target: "Buttons, Various uses of UIButton",
  substring: false,
  insensitive: false,
},
value: {
  target: "Buttons, Various uses of UIButton",
  substring: false,
  insensitive: false,
}

}

# File lib/appium_lib/ios/common/helper.rb, line 456
    def _by_json(opts)
      valid_keys = %i(typeArray onlyFirst onlyVisible name label value)
      unknown_keys = opts.keys - valid_keys
      raise "Unknown keys: #{unknown_keys}" unless unknown_keys.empty?

      type_array = opts[:typeArray]
      raise 'typeArray must be an array' unless type_array.is_a? Array

      only_first = opts[:onlyFirst]
      raise 'onlyFirst must be a boolean' unless [true, false].include? only_first

      only_visible = opts[:onlyVisible]
      raise 'onlyVisible must be a boolean' unless [true, false].include? only_visible

      # name/label/value are optional. when searching for class only, then none
      # will be present.
      _validate_object opts[:name], opts[:label], opts[:value]

      # NOTE: that mainWindow is sometimes nil so it's passed as a param
      # $._elementOrElementsByType will validate that the window isn't nil
      element_or_elements_by_type = <<-JS
        (function() {
          var opts = #{opts.to_json};
          var result = false;

          try {
            result = $._elementOrElementsByType($.mainWindow(), opts);
          } catch (e) {
          }

          return result;
        })();
      JS

      res = execute_script element_or_elements_by_type
      res || raise(Appium::Ios::CommandError, 'mainWindow is nil')
    end
_validate_object(*objects) click to toggle source
# File lib/appium_lib/ios/common/helper.rb, line 406
def _validate_object(*objects)
  raise 'objects must be an array' unless objects.is_a? Array

  objects.each do |obj|
    next unless obj # obj may be nil. if so, ignore.

    valid_keys   = %i[target substring insensitive]
    unknown_keys = obj.keys - valid_keys
    raise "Unknown keys: #{unknown_keys}" unless unknown_keys.empty?

    target = obj[:target]
    raise 'target must be a string' unless target.is_a? String

    substring = obj[:substring]
    raise 'substring must be a boolean' unless [true, false].include? substring

    insensitive = obj[:insensitive]
    raise 'insensitive must be a boolean' unless [true, false].include? insensitive
  end
end
alert_accept() click to toggle source

Accept the alert. @return [void]

# File lib/appium_lib/ios/element/alert.rb, line 19
def alert_accept
  # @driver.switch_to.alert.accept
  # ".switch_to.alert" calls alert_text so use bridge directly
  driver.send(:bridge).accept_alert
end
alert_dismiss() click to toggle source

Dismiss the alert. @return [void]

# File lib/appium_lib/ios/element/alert.rb, line 27
def alert_dismiss
  # @driver.switch_to.alert.dismiss
  # ".switch_to.alert" calls alert_text so use bridge directly
  driver.send(:bridge).dismiss_alert
end
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/element/button.rb, line 33
def button(value)
  # return button at index.
  return ele_index button_class, value if value.is_a? Numeric

  ele_by_json_visible_contains button_class, value
end
button_class() click to toggle source

@return [String] Class name for button

# File lib/appium_lib/ios/element/button.rb, line 25
def button_class
  UIA_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/element/button.rb, line 67
def button_exact(value)
  ele_by_json_visible_exact button_class, value
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/element/button.rb, line 44
def buttons(value = false)
  return tags button_class unless value

  eles_by_json_visible_contains button_class, value
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/element/button.rb, line 74
def buttons_exact(value)
  eles_by_json_visible_exact button_class, value
end
ele_by_json(opts) click to toggle source

see eles_by_json

# File lib/appium_lib/ios/common/helper.rb, line 512
def ele_by_json(opts)
  opts[:onlyFirst] = true
  result = _by_json(opts).first
  raise _no_such_element if result.nil?

  result
end
ele_by_json_visible_contains(element, value) click to toggle source

Find the first element that contains value. For Appium(automation name), not XCUITest @param element [String] the class name for the element @param value [String] the value to search for @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 320
def ele_by_json_visible_contains(element, value)
  ele_by_json string_visible_contains element, value
end
ele_by_json_visible_exact(element, value) click to toggle source

Find the first element exactly matching value For Appium(automation name), not XCUITest @param element [String] the class name for the element @param value [String] the value to search for @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 359
def ele_by_json_visible_exact(element, value)
  ele_by_json string_visible_exact element, value
end
ele_index(class_name, index) click to toggle source

Get the element of type class_name at matching index. @param class_name [String] the class name to find @param index [Integer] the index @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 109
def ele_index(class_name, index)
  raise 'Index must be >= 1' unless index == 'last()' || (index.is_a?(Integer) && index >= 1)

  elements = tags(class_name)

  if index == 'last()'
    result = elements.last
  else
    # elements array is 0 indexed
    index -= 1
    result = elements[index]
  end

  raise _no_such_element if result.nil?

  result
end
ele_with_pred(opts) click to toggle source

returns element matching predicate contained in the main app

predicate - the predicate to evaluate on the main app

visible - if true, only visible elements are returned. default true @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 391
def ele_with_pred(opts)
  # true = return only visible
  find_element(:uiautomation, _all_pred(opts))
end
eles_by_json(opts) click to toggle source

For Appium(automation name), not XCUITest example usage:

eles_by_json({

typeArray: ["UIAStaticText"],
onlyVisible: true,
name: {
  target: "Buttons, Various uses of UIButton",
  substring: false,
  insensitive: false,
},

})

# File lib/appium_lib/ios/common/helper.rb, line 506
def eles_by_json(opts)
  opts[:onlyFirst] = false
  _by_json opts
end
eles_by_json_visible_contains(element, value) click to toggle source

Find all elements containing value For Appium(automation name), not XCUITest @param element [String] the class name for the element @param value [String] the value to search for @return [Array<Element>]

# File lib/appium_lib/ios/common/helper.rb, line 329
def eles_by_json_visible_contains(element, value)
  eles_by_json string_visible_contains element, value
end
eles_by_json_visible_exact(element, value) click to toggle source

Find all elements exactly matching value For Appium(automation name), not XCUITest @param element [String] the class name for the element @param value [String] the value to search for @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 368
def eles_by_json_visible_exact(element, value)
  eles_by_json string_visible_exact element, value
end
eles_with_pred(opts) click to toggle source

returns elements matching predicate contained in the main app

predicate - the predicate to evaluate on the main app

visible - if true, only visible elements are returned. default true @return [Array<Element>]

# File lib/appium_lib/ios/common/helper.rb, line 402
def eles_with_pred(opts)
  find_elements(:uiautomation, _all_pred(opts))
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/element/generic.rb, line 20
def find(value)
  ele_by_json_visible_contains '*', value
end
find_ele_by_attr(class_name, attr, value) click to toggle source

Find the first element exactly matching class and attribute value. Note: Uses XPath Note: For XCUITest, this method return ALL elements include displayed or not displayed elements. @param class_name [String] the class name to search for @param attr [String] the attribute to inspect @param value [String] the expected value of the attribute @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 139
def find_ele_by_attr(class_name, attr, value)
  @driver.find_element :xpath, string_attr_exact(class_name, attr, value)
end
find_ele_by_attr_include(class_name, attr, value) click to toggle source

Get the first tag by attribute that exactly matches value. Note: Uses XPath @param class_name [String] the tag name to match @param attr [String] the attribute to compare @param value [String] the value of the attribute that the element must include @return [Element] the element of type tag who's attribute includes value

# File lib/appium_lib/ios/common/helper.rb, line 191
def find_ele_by_attr_include(class_name, attr, value)
  @driver.find_element :xpath, string_attr_include(class_name, attr, value)
end
find_ele_by_predicate(class_name: '*', value:) click to toggle source

Find the first element exactly matching attribute case insensitive value. Note: Uses Predicate @param value [String] the expected value of the attribute @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 163
def find_ele_by_predicate(class_name: '*', value:)
  elements = find_eles_by_predicate(class_name: class_name, value: value)
  raise _no_such_element if elements.empty?

  elements.first
end
find_ele_by_predicate_include(class_name: '*', value:) click to toggle source

Get the first elements that include insensitive value. Note: Uses Predicate @param value [String] the value of the attribute that the element must include @return [Element] the element of type tag who's attribute includes value

# File lib/appium_lib/ios/common/helper.rb, line 209
def find_ele_by_predicate_include(class_name: '*', value:)
  elements = find_eles_by_predicate_include(class_name: class_name, value: value)
  raise _no_such_element if elements.empty?

  elements.first
end
find_eles_by_attr(class_name, attr, value) click to toggle source

Find all elements exactly matching class and attribute value. Note: Uses XPath Note: For XCUITest, this method return ALL elements include displayed or not displayed elements. @param class_name [String] the class name to match @param attr [String] the attribute to compare @param value [String] the value of the attribute that the element must have @return [Array<Element>]

# File lib/appium_lib/ios/common/helper.rb, line 150
def find_eles_by_attr(class_name, attr, value)
  @driver.find_elements :xpath, string_attr_exact(class_name, attr, value)
end
find_eles_by_attr_include(class_name, attr, value) click to toggle source

Get tags by attribute that include value. Note: Uses XPath @param class_name [String] the tag name to match @param attr [String] the attribute to compare @param value [String] the value of the attribute that the element must include @return [Array<Element>] the elements of type tag who's attribute includes value

# File lib/appium_lib/ios/common/helper.rb, line 201
def find_eles_by_attr_include(class_name, attr, value)
  @driver.find_elements :xpath, string_attr_include(class_name, attr, value)
end
find_eles_by_predicate(class_name: '*', value:) click to toggle source

Find all elements exactly matching attribute case insensitive value. Note: Uses Predicate @param value [String] the value of the attribute that the element must have @param class_name [String] the tag name to match @return [Array<Element>]

# File lib/appium_lib/ios/common/helper.rb, line 175
def find_eles_by_predicate(class_name: '*', value:)
  predicate = if class_name == '*'
                %(name == "#{value}" || label == "#{value}" || value == "#{value}")
              else
                %(type == "#{class_name}" && ) +
                  %((name == "#{value}" || label == "#{value}" || value == "#{value}"))
              end
  @driver.find_elements :predicate, predicate
end
find_eles_by_predicate_include(class_name: '*', value:) click to toggle source

Get elements that include case insensitive value. Note: Uses Predicate @param value [String] the value of the attribute that the element must include @param class_name [String] the tag name to match @return [Array<Element>] the elements of type tag who's attribute includes value

# File lib/appium_lib/ios/common/helper.rb, line 221
def find_eles_by_predicate_include(class_name: '*', value:)
  predicate = if class_name == '*'
                %(name contains[c] "#{value}" || label contains[c] "#{value}" || value contains[c] "#{value}")
              else
                %(type == "#{class_name}" && ) +
                  %((name contains[c] "#{value}" || label contains[c] "#{value}" || value contains[c] "#{value}"))
              end
  @driver.find_elements :predicate, predicate
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/element/generic.rb, line 34
def find_exact(value)
  ele_by_json_visible_exact '*', value
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/element/generic.rb, line 27
def finds(value)
  eles_by_json_visible_contains '*', value
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/element/generic.rb, line 41
def finds_exact(value)
  eles_by_json_visible_exact '*', value
end
first_button() click to toggle source

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

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

Get the first tag that matches class_name @param class_name [String] the tag to match @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 234
def first_ele(class_name)
  ele_index class_name, 1
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/element/text.rb, line 51
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/element/textfield.rb, line 69
def first_textfield
  ele_by_json _textfield_visible
end
id(id) click to toggle source

Find by id @param id [String] the id to search for @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 101
def id(id)
  find_element(:id, id)
end
ios_password(length = 1) click to toggle source

iOS only. On Android uiautomator always returns an empty string for EditText password.

Password character returned from value of UIASecureTextField @param length [Integer] the length of the password to generate @return [String] the returned string is of size length

# File lib/appium_lib/ios/common/helper.rb, line 58
def ios_password(length = 1)
  8226.chr('UTF-8') * length
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/element/button.rb, line 60
def last_button
  last_ele button_class
end
last_ele(class_name) click to toggle source

Get the last tag that matches class_name @param class_name [String] the tag to match @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 241
def last_ele(class_name)
  ele_index class_name, 'last()'
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/element/text.rb, line 57
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/element/textfield.rb, line 75
def last_textfield
  result = eles_by_json(_textfield_visible).last
  raise _no_such_element if result.nil?

  result
end
page(opts = {}) click to toggle source

Prints a string of interesting elements to the console.

@example

```ruby
page class: :UIAButton # filter on buttons
page class: :UIAButton, window: 1
```

@option visible [Symbol] visible value to filter on @option class [Symbol] class name to filter on

@return [void]

# File lib/appium_lib/ios/common/helper.rb, line 74
def page(opts = {})
  class_name = opts.is_a?(Hash) ? opts.fetch(:class, nil) : opts

  source = get_source

  # current_context may be nil which breaks start_with
  if current_context&.start_with?('WEBVIEW')
    parser = @android_html_parser ||= Nokogiri::HTML::SAX::Parser.new(Appium::Common::HTMLElements.new)
    parser.document.reset
    parser.document.filter = class_name
    parser.parse source
    result = parser.document.result
    puts result
    result
  else
    parser = Nokogiri::XML::SAX::Parser.new(UITestElementsPrinter.new)
    if class_name
      parser.document.filter = class_name.is_a?(Symbol) ? class_name.to_s : class_name
    end
    parser.parse source
    nil
  end
end
secure_text_field_class() click to toggle source

@return [String] Class name for secure text field

# File lib/appium_lib/ios/element/textfield.rb, line 33
def secure_text_field_class
  UIA_SECURE_TEXT_FIELD
end
static_text_class() click to toggle source

@return [String] Class name for text

# File lib/appium_lib/ios/element/text.rb, line 25
def static_text_class
  UIA_STATIC_TEXT
end
string_attr_exact(class_name, attr, value) click to toggle source

@private

# File lib/appium_lib/ios/common/helper.rb, line 128
def string_attr_exact(class_name, attr, value)
  %(//#{class_name}[@visible="true" and @#{attr}="#{value}"])
end
string_attr_include(class_name, attr, value) click to toggle source

@private

# File lib/appium_lib/ios/common/helper.rb, line 155
def string_attr_include(class_name, attr, value)
  %(//#{class_name}[@visible="true" and contains(translate(@#{attr},"#{value.upcase}", "#{value}"), "#{value}")])
end
string_visible_contains(element, value) click to toggle source

@private Returns an object that matches the first element that contains value

example: ele_by_json_visible_contains 'UIATextField', 'sign in'

@param element [String] the class name for the element @param value [String] the value to search for @return [String]

# File lib/appium_lib/ios/common/helper.rb, line 299
def string_visible_contains(element, value)
  contains = {
    target: value,
    substring: true,
    insensitive: true
  }

  {
    typeArray: [element],
    onlyVisible: true,
    name: contains,
    label: contains,
    value: contains
  }
end
string_visible_exact(element, value) click to toggle source

@private Create an object to exactly match the first element with target value @param element [String] the class name for the element @param value [String] the value to search for @return [String]

# File lib/appium_lib/ios/common/helper.rb, line 338
def string_visible_exact(element, value)
  exact = {
    target: value,
    substring: false,
    insensitive: false
  }

  {
    typeArray: [element],
    onlyVisible: true,
    name: exact,
    label: exact,
    value: exact
  }
end
tag(class_name) click to toggle source

Returns the first visible element matching class_name

@param class_name [String] the class_name to search for @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 249
def tag(class_name)
  ele_by_json(typeArray: [class_name], onlyVisible: true)
end
tags(class_name) click to toggle source

Returns all visible elements matching class_name

@param class_name [String] the class_name to search for @return [Element]

# File lib/appium_lib/ios/common/helper.rb, line 257
def tags(class_name)
  eles_by_json(typeArray: [class_name], onlyVisible: true)
end
tags_exact(class_names:, value: nil) click to toggle source

Returns all visible elements matching class_names and value. This method calls find_element/s and element.value/text many times. So, if you set many class_names, this method's performance become worse.

@param class_names [Array] the class_names to search for @param value [String] the value to search for @return [Array]

# File lib/appium_lib/ios/common/helper.rb, line 283
def tags_exact(class_names:, value: nil)
  return unless class_names.is_a? Array

  class_names.flat_map do |class_name|
    value ? eles_by_json_visible_exact(class_name, value) : tags(class_name)
  end
end
tags_include(class_names:, value: nil) click to toggle source

Returns all visible elements matching class_names and value This method calls find_element/s and element.value/text many times. So, if you set many class_names, this method's performance become worse.

@param class_names [Array] the class_names to search for @param value [String] the value to search for @return [Array]

# File lib/appium_lib/ios/common/helper.rb, line 268
def tags_include(class_names:, value: nil)
  return unless class_names.is_a? Array

  class_names.flat_map do |class_name|
    value ? eles_by_json_visible_contains(class_name, value) : tags(class_name)
  end
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/element/text.rb, line 33
def text(value)
  return ele_index static_text_class, value if value.is_a? Numeric

  ele_by_json_visible_contains static_text_class, value
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|XCUIElementTypeStaticText]

# File lib/appium_lib/ios/element/text.rb, line 64
def text_exact(value)
  ele_by_json_visible_exact static_text_class, value
end
text_field_class() click to toggle source

@return [String] Class name for text field

# File lib/appium_lib/ios/element/textfield.rb, line 28
def text_field_class
  UIA_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/element/textfield.rb, line 42
def textfield(value)
  if value.is_a? Numeric
    index = value
    raise "#{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 = eles_by_json(_textfield_visible)[index]
    raise _no_such_element if result.nil?

    return result
  end

  ele_by_json _textfield_contains_string value
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/element/textfield.rb, line 85
def textfield_exact(value)
  ele_by_json _textfield_exact_string value
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/element/textfield.rb, line 61
def textfields(value = false)
  return eles_by_json _textfield_visible unless value

  eles_by_json _textfield_contains_string value
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/element/textfield.rb, line 92
def textfields_exact(value)
  eles_by_json _textfield_exact_string value
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/element/text.rb, line 43
def texts(value = false)
  return tags static_text_class unless value

  eles_by_json_visible_contains static_text_class, value
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|XCUIElementTypeStaticText>]

# File lib/appium_lib/ios/element/text.rb, line 71
def texts_exact(value)
  eles_by_json_visible_exact static_text_class, value
end

Private Instance Methods

_textfield_contains_string(value) click to toggle source

Appium

# File lib/appium_lib/ios/element/textfield.rb, line 111
def _textfield_contains_string(value)
  contains = { target: value, substring: true, insensitive: true }
  contains_obj = { name: contains, label: contains, value: contains }
  _textfield_visible.merge(contains_obj)
end
_textfield_exact_string(value) click to toggle source

Appium

# File lib/appium_lib/ios/element/textfield.rb, line 104
def _textfield_exact_string(value)
  exact = { target: value, substring: false, insensitive: false }
  exact_obj = { name: exact, label: exact, value: exact }
  _textfield_visible.merge(exact_obj)
end
_textfield_visible() click to toggle source

Appium

# File lib/appium_lib/ios/element/textfield.rb, line 99
def _textfield_visible
  { typeArray: [UIA_TEXT_FIELD, UIA_SECURE_TEXT_FIELD], onlyVisible: true }
end
raise_error_if_no_element(element) click to toggle source
# File lib/appium_lib/ios/element/generic.rb, line 47
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/element/generic.rb, line 55
def select_visible_elements(elements)
  elements.select(&:displayed?)
end