class Element
Constants
- Point
- Size
Public Class Methods
new(xml_representation)
click to toggle source
# File lib/adb_driver/element.rb, line 5 def initialize(xml_representation) @xml_representation = xml_representation end
Public Instance Methods
center()
click to toggle source
# File lib/adb_driver/element.rb, line 54 def center Point.new(top_left.x + width / 2, top_left.y + height / 2) end
checked?()
click to toggle source
# File lib/adb_driver/element.rb, line 29 def checked? @xml_representation.attributes['checked'] == 'true' end
class_name()
click to toggle source
# File lib/adb_driver/element.rb, line 62 def class_name @xml_representation.attributes['class'] end
click()
click to toggle source
# File lib/adb_driver/element.rb, line 9 def click `adb shell input tap #{center.x} #{center.y}` end
content_desc()
click to toggle source
# File lib/adb_driver/element.rb, line 33 def content_desc @xml_representation.attributes['content-desc'] end
height()
click to toggle source
# File lib/adb_driver/element.rb, line 50 def height lower_right.y - top_left.y end
long_click()
click to toggle source
# File lib/adb_driver/element.rb, line 13 def long_click `adb shell input swipe #{center.x} #{center.y} #{center.x} #{center.y} 800` end
lower_right()
click to toggle source
# File lib/adb_driver/element.rb, line 42 def lower_right Point.new(coordinates[2], coordinates[3]) end
send_keys(text)
click to toggle source
# File lib/adb_driver/element.rb, line 17 def send_keys(text) click sleep 2 text.scan(/.{1,10}/).each do |part| `adb shell "input text '#{part}'"` end end
size()
click to toggle source
# File lib/adb_driver/element.rb, line 58 def size Size.new(width, height) end
text()
click to toggle source
# File lib/adb_driver/element.rb, line 25 def text @xml_representation.attributes['text'] end
top_left()
click to toggle source
# File lib/adb_driver/element.rb, line 37 def top_left Point.new(coordinates[0], coordinates[1]) end
Also aliased as: location
width()
click to toggle source
# File lib/adb_driver/element.rb, line 46 def width lower_right.x - top_left.x end
Private Instance Methods
coordinates()
click to toggle source
# File lib/adb_driver/element.rb, line 68 def coordinates @coordinates ||= @xml_representation.attributes['bounds'].scan(/\d+/).map(&:to_i) end