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.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 9 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 "#{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.
62 63 64 65 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 62 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.
30 31 32 33 34 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 30 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.
70 71 72 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 70 def (value) find_elements :uiautomator, (value) end |
#first_button ⇒ Button
Find the first button.
38 39 40 41 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 38 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.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/appium_lib/android/uiautomator2/element/button.rb', line 45 def # uiautomator index doesn't support last # and it's 0 indexed = (::Appium::Android::Button).length -= 1 if > 0 = (::Appium::Android::ImageButton).length -= 1 if > 0 elements = find_elements :uiautomator, (button_index: , image_button_index: ) raise_no_such_element_if_empty(elements) end |