module Appium::Android::Uiautomator2::Helper
Public Instance Methods
Find the first element that contains value @param class_name [String] the class name for the element @param value [String] the value to search for @return [Element]
# File lib/appium_lib/android/uiautomator2/helper.rb, line 45 def complex_find_contains(class_name, value) elements = find_elements :uiautomator, string_visible_contains(class_name, value) raise _no_such_element if elements.empty? elements.first end
Find the first element exactly matching value @param class_name [String] the class name for the element @param value [String] the value to search for @return [Element]
# File lib/appium_lib/android/uiautomator2/helper.rb, line 84 def complex_find_exact(class_name, value) elements = find_elements :uiautomator, string_visible_exact(class_name, value) raise _no_such_element if elements.empty? elements.first end
Find all elements containing value @param class_name [String] the class name for the element @param value [String] the value to search for @return [Array<Element>]
# File lib/appium_lib/android/uiautomator2/helper.rb, line 56 def complex_finds_contains(class_name, value) find_elements :uiautomator, string_visible_contains(class_name, value) end
Find all elements exactly matching value @param class_name [String] the class name for the element @param value [String] the value to search for @return [Element]
# File lib/appium_lib/android/uiautomator2/helper.rb, line 95 def complex_finds_exact(class_name, value) find_elements :uiautomator, string_visible_exact(class_name, value) end
Returns a string that matches the first element that contains value For automationName is Appium
example: string_visible_contains
'UIATextField', 'sign in' note for XPath: github.com/appium/ruby_lib/pull/561
@param class_name [String] the class name for the element @param value [String] the value to search for @return [String]
# File lib/appium_lib/android/uiautomator2/helper.rb, line 27 def string_visible_contains(class_name, value) value = %("#{value}") if class_name == '*' return (resource_id(value, "new UiSelector().resourceId(#{value});") + "new UiSelector().descriptionContains(#{value});" \ "new UiSelector().textContains(#{value});") end class_name = %("#{class_name}") resource_id(value, "new UiSelector().className(#{class_name}).resourceId(#{value});") + "new UiSelector().className(#{class_name}).descriptionContains(#{value});" \ "new UiSelector().className(#{class_name}).textContains(#{value});" end
@private Create an string to exactly match the first element with target value @param class_name [String] the class name for the element @param value [String] the value to search for @return [String]
# File lib/appium_lib/android/uiautomator2/helper.rb, line 65 def string_visible_exact(class_name, value) value = %("#{value}") if class_name == '*' return (resource_id(value, "new UiSelector().resourceId(#{value});") + "new UiSelector().description(#{value});" \ "new UiSelector().text(#{value});") end class_name = %("#{class_name}") resource_id(value, "new UiSelector().className(#{class_name}).resourceId(#{value});") + "new UiSelector().className(#{class_name}).description(#{value});" \ "new UiSelector().className(#{class_name}).text(#{value});" end