module Appium::Android::Espresso::Element
Public Instance Methods
scroll_to(text)
click to toggle source
Scroll to the first element containing target text or description. Scroll happens upto 30 times in centre of device width. @param text [String] the text or resourceId to search for in the text value and content description @return [Element] the element scrolled to
# File lib/appium_lib/android/espresso/element/generic.rb, line 23 def scroll_to(text) err = nil w_s = window_rect (1..30).each do |_count| action .move_to_location(w_s.width / 2, (w_s.height * 2) / 5) # pointer based magic number .pointer_down(:left) .move_to_location(0, w_s.height / 5) .release .perform sleep 1 # we must wait finish scrolling return text(text) rescue StandardError => e err = e end raise err end
scroll_to_exact(text)
click to toggle source
Scroll to the first element with the exact target text or description. Scroll happens upto 30 times in centre of device width. @param text [String] the text or resourceId to search for in the text value and content description @return [Element] the element scrolled to
# File lib/appium_lib/android/espresso/element/generic.rb, line 48 def scroll_to_exact(text) err = nil w_s = window_rect (1..30).each do |_count| action .move_to_location(w_s.width / 2, (w_s.height * 2) / 5) # pointer based magic number .pointer_down(:left) .move_to_location(0, w_s.height / 5) .release .perform sleep 1 # we must wait finish scrolling return text_exact(text) rescue StandardError => e err = e end raise err end
Private Instance Methods
raise_no_such_element_if_empty(elements)
click to toggle source
@private
# File lib/appium_lib/android/espresso/element/button.rb, line 98 def raise_no_such_element_if_empty(elements) raise _no_such_element if elements.empty? elements.first end