Module: Appium::Android::Uiautomator2::Element
- Defined in:
- lib/appium_lib/android/uiautomator2/element.rb,
lib/appium_lib/android/uiautomator2/element/button.rb
Instance Method Summary collapse
-
#button(value) ⇒ Button
Find the first button that contains value or by index.
-
#button_exact(value) ⇒ Button
Find the first button that exactly matches value.
-
#buttons(value = false) ⇒ Array<Button>
Find all buttons containing value.
-
#buttons_exact(value) ⇒ Array<Button>
Find all buttons that exactly match value.
-
#first_button ⇒ Button
Find the first button.
-
#last_button ⇒ Button
Find the last button.
Instance Method Details
#button(value) ⇒ Button
Find the first button that contains value or by index. If int then the button at that index is returned.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 23 def (value) # Don't use ele_index because that only works on one element type. # Android needs to combine button and image button to match iOS. if value.is_a? Numeric index = value raise ArgumentError, "#{index} is not a valid index. Must be >= 1" if index <= 0 result = find_elements :uiautomator, (index: index) raise _no_such_element if result.empty? return result[value - 1] end elements = find_elements :uiautomator, (value) raise_no_such_element_if_empty(elements) end |
#button_exact(value) ⇒ Button
Find the first button that exactly matches value.
76 77 78 79 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 76 def (value) elements = find_elements :uiautomator, (value) raise_no_such_element_if_empty(elements) end |
#buttons(value = false) ⇒ Array<Button>
Find all buttons containing value. If value is omitted, all buttons are returned.
44 45 46 47 48 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 44 def (value = false) return find_elements :uiautomator, unless value find_elements :uiautomator, (value) end |
#buttons_exact(value) ⇒ Array<Button>
Find all buttons that exactly match value.
84 85 86 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 84 def (value) find_elements :uiautomator, (value) end |
#first_button ⇒ Button
Find the first button.
52 53 54 55 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 52 def elements = find_elements :uiautomator, (button_index: 0, image_button_index: 0) raise_no_such_element_if_empty(elements) end |
#last_button ⇒ Button
Find the last button.
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 59 def # uiautomator index doesn't support last # and it's 0 indexed = (::Appium::Android::Button).length -= 1 if .positive? = (::Appium::Android::ImageButton).length -= 1 if .positive? elements = find_elements :uiautomator, (button_index: , image_button_index: ) raise_no_such_element_if_empty(elements) end |