Class: WDA::Element
- Inherits:
-
Object
- Object
- WDA::Element
- Defined in:
- lib/wda_lib/element.rb
Instance Method Summary collapse
-
#accessible? ⇒ Boolean
Check if element is accessible?.
-
#accessible_container? ⇒ Boolean
Check if element is accessibilityContainer?.
-
#attribute(name) ⇒ Object
(also: #[])
Get attribute value.
-
#clear ⇒ Object
Clearing text of an given element.
-
#click ⇒ Object
Tap on an element with its id.
-
#displayed? ⇒ Boolean
Check if element is displayed?.
-
#double_tap ⇒ Object
Double tap on an element with its id.
-
#drag_to(toX, toY, duration = 0) ⇒ Object
Drag on an element with its id and position.
- #eid ⇒ Object
-
#enabled? ⇒ Boolean
Check if element is enabled?.
-
#initialize(client, id) ⇒ Element
constructor
A new instance of Element.
-
#inspect ⇒ Object
Remove useless attributes, return object only with element.
-
#location ⇒ Struct
Get element size.
-
#name ⇒ Object
Get type from an element.
-
#rect ⇒ Object
Get wdRect by id.
- #ref ⇒ Object
-
#scroll(direction = nil) ⇒ Hash
Scroll on an element with its id.
-
#send_keys(value) ⇒ Object
Set value to an element.
-
#size ⇒ Struct
Get element size.
-
#text ⇒ Object
Get text from an element(StaticText or Button).
-
#touch_hold(duration) ⇒ Object
Touch and hold on for a while finger tap on an element with its id.
-
#two_finger_tap ⇒ Object
Two finger tap on an element with its id.
Constructor Details
#initialize(client, id) ⇒ Element
4 5 6 7 |
# File 'lib/wda_lib/element.rb', line 4 def initialize(client, id) @client = client @id = id end |
Instance Method Details
#accessible? ⇒ Boolean
Check if element is accessible?
60 61 62 |
# File 'lib/wda_lib/element.rb', line 60 def accessible? client.get('/element/' + eid + '/accessible')['value'] end |
#accessible_container? ⇒ Boolean
Check if element is accessibilityContainer?
67 68 69 |
# File 'lib/wda_lib/element.rb', line 67 def accessible_container? client.get('/element/' + eid + '/accessibilityContainer')['value'] end |
#attribute(name) ⇒ Object Also known as: []
Get attribute value
39 40 41 |
# File 'lib/wda_lib/element.rb', line 39 def attribute(name) client.get '/element/' + eid + '/attribute/' + name end |
#clear ⇒ Object
Clearing text of an given element
95 96 97 |
# File 'lib/wda_lib/element.rb', line 95 def clear client.post '/element/' + eid + '/clear' end |
#click ⇒ Object
Tap on an element with its id
88 89 90 |
# File 'lib/wda_lib/element.rb', line 88 def click client.post '/element/' + eid + '/click' end |
#displayed? ⇒ Boolean
Check if element is displayed?
53 54 55 |
# File 'lib/wda_lib/element.rb', line 53 def displayed? client.get('/element/' + eid + '/displayed')['value'] end |
#double_tap ⇒ Object
Double tap on an element with its id
102 103 104 |
# File 'lib/wda_lib/element.rb', line 102 def double_tap client.post '/uiaElement/' + eid + '/doubleTap' end |
#drag_to(toX, toY, duration = 0) ⇒ Object
Drag on an element with its id and position
129 130 131 132 133 |
# File 'lib/wda_lib/element.rb', line 129 def drag_to(toX, toY, duration = 0) fromX = location[:x] fromY = location[:y] client.post '/uiaTarget/' + eid + '/dragfromtoforduration', { fromX: fromX, toX: toX, fromY: fromY, toY: toY, duration: duration } end |
#eid ⇒ Object
18 19 20 |
# File 'lib/wda_lib/element.rb', line 18 def eid @id['ELEMENT'] end |
#enabled? ⇒ Boolean
Check if element is enabled?
25 26 27 |
# File 'lib/wda_lib/element.rb', line 25 def enabled? client.get('/element/' + eid + '/enabled')['value'] end |
#inspect ⇒ Object
Remove useless attributes, return object only with element
10 11 12 |
# File 'lib/wda_lib/element.rb', line 10 def inspect format '#<%s:0x%x id=%s>', self.class, hash * 2, @id.inspect end |
#location ⇒ Struct
Get element size
144 145 146 147 |
# File 'lib/wda_lib/element.rb', line 144 def location r = rect['value'] Point.new(r['x'], r['y']) end |
#name ⇒ Object
Get type from an element
74 75 76 |
# File 'lib/wda_lib/element.rb', line 74 def name client.get '/element/' + eid + '/name' end |
#rect ⇒ Object
Get wdRect by id
32 33 34 |
# File 'lib/wda_lib/element.rb', line 32 def rect client.get '/element/' + eid + '/rect' end |
#ref ⇒ Object
14 15 16 |
# File 'lib/wda_lib/element.rb', line 14 def ref @id end |
#scroll(direction = nil) ⇒ Hash
Scroll on an element with its id
123 124 125 |
# File 'lib/wda_lib/element.rb', line 123 def scroll(direction = nil) client.post '/uiaElement/' + eid + '/scroll', { direction: direction } end |
#send_keys(value) ⇒ Object
Set value to an element
81 82 83 |
# File 'lib/wda_lib/element.rb', line 81 def send_keys(value) client.post '/element/' + eid + '/value', { value: value.chars } end |
#size ⇒ Struct
Get element size
137 138 139 140 |
# File 'lib/wda_lib/element.rb', line 137 def size r = rect['value'] Dimension.new(r['width'], r['height']) end |
#text ⇒ Object
Get text from an element(StaticText or Button)
46 47 48 |
# File 'lib/wda_lib/element.rb', line 46 def text client.get '/element/' + eid + '/text' end |
#touch_hold(duration) ⇒ Object
Touch and hold on for a while finger tap on an element with its id
116 117 118 |
# File 'lib/wda_lib/element.rb', line 116 def touch_hold(duration) client.post '/uiaElement/' + eid + '/touchAndHold', { duration: duration } end |
#two_finger_tap ⇒ Object
Two finger tap on an element with its id
109 110 111 |
# File 'lib/wda_lib/element.rb', line 109 def two_finger_tap client.post '/uiaElement/' + eid + '/twoFingerTap' end |