Class: Webdriver::Element
- Inherits:
-
Object
- Object
- Webdriver::Element
- Defined in:
- lib/webdriver/element.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #attribute(name) ⇒ Object
- #clear! ⇒ Object
- #click! ⇒ Object
- #css(name) ⇒ Object
- #displayed? ⇒ Boolean
- #element(using, value) ⇒ Object
- #elements(using, value) ⇒ Object
-
#enabled? ⇒ Boolean
form control enabled.
-
#initialize(id, connection) ⇒ Element
constructor
A new instance of Element.
- #location_in_view ⇒ Object
- #property(name) ⇒ Object
- #rect ⇒ Object
- #screenshot ⇒ Object
-
#selected? ⇒ Boolean
checkbox.
- #size ⇒ Object
- #tag ⇒ Object
- #text ⇒ Object
- #value!(value) ⇒ Object
Constructor Details
#initialize(id, connection) ⇒ Element
Returns a new instance of Element.
5 6 7 8 9 10 |
# File 'lib/webdriver/element.rb', line 5 def initialize(id, connection) @id = id @session_connection = connection @connection = Webdriver::PrefixConnection.new "element/#{@id}", connection end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/webdriver/element.rb', line 3 def id @id end |
Instance Method Details
#==(other) ⇒ Object
12 13 14 15 |
# File 'lib/webdriver/element.rb', line 12 def ==(other) return false unless other.is_a? Webdriver::Element @id == other.id end |
#attribute(name) ⇒ Object
80 81 82 |
# File 'lib/webdriver/element.rb', line 80 def attribute name @connection.get File.join("attribute", name) end |
#clear! ⇒ Object
43 44 45 46 47 |
# File 'lib/webdriver/element.rb', line 43 def clear! @connection.post "clear" click! self end |
#click! ⇒ Object
84 85 86 |
# File 'lib/webdriver/element.rb', line 84 def click! @connection.post "click" end |
#css(name) ⇒ Object
72 73 74 |
# File 'lib/webdriver/element.rb', line 72 def css name @connection.get File.join("css", name) end |
#displayed? ⇒ Boolean
29 30 31 |
# File 'lib/webdriver/element.rb', line 29 def displayed? @connection.get "displayed" end |
#element(using, value) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/webdriver/element.rb', line 88 def element using, value el = @connection.post "element", {}, { using: using, value: value } Webdriver::Element.new el["ELEMENT"], @session_connection end |
#elements(using, value) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/webdriver/element.rb', line 96 def elements using, value resp = @connection.post "elements", {}, { using: using, value: value } resp.map { |el| Webdriver::Element.new el["ELEMENT"], @session_connection } end |
#enabled? ⇒ Boolean
form control enabled
39 40 41 |
# File 'lib/webdriver/element.rb', line 39 def enabled? @connection.get "enabled" end |
#location_in_view ⇒ Object
17 18 19 |
# File 'lib/webdriver/element.rb', line 17 def location_in_view @connection.get "location_in_view" end |
#property(name) ⇒ Object
76 77 78 |
# File 'lib/webdriver/element.rb', line 76 def property name @connection.get File.join("property", name) end |
#rect ⇒ Object
64 65 66 |
# File 'lib/webdriver/element.rb', line 64 def rect @connection.get "rect" end |
#screenshot ⇒ Object
25 26 27 |
# File 'lib/webdriver/element.rb', line 25 def screenshot @connection.get "screenshot" end |
#selected? ⇒ Boolean
checkbox
34 35 36 |
# File 'lib/webdriver/element.rb', line 34 def selected? @connection.get "selected" end |
#size ⇒ Object
21 22 23 |
# File 'lib/webdriver/element.rb', line 21 def size @connection.get "size" end |
#tag ⇒ Object
68 69 70 |
# File 'lib/webdriver/element.rb', line 68 def tag @connection.get "name" end |
#text ⇒ Object
60 61 62 |
# File 'lib/webdriver/element.rb', line 60 def text @connection.get "text" end |
#value!(value) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/webdriver/element.rb', line 49 def value! value value_string = value.to_s if value_string == "" clear! else @connection.post "value", {}, { value: [value_string] } end end |