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
- #attribute(name) ⇒ Object
- #clear! ⇒ Object
- #click! ⇒ Object
- #css(name) ⇒ Object
- #element(using, value) ⇒ Object
- #elements(using, value) ⇒ Object
-
#enabled? ⇒ Boolean
form control enabled.
-
#initialize(id, connection) ⇒ Element
constructor
A new instance of Element.
- #property(name) ⇒ Object
- #rect ⇒ Object
- #screenshot ⇒ Object
-
#selected? ⇒ Boolean
checkbox.
- #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
#attribute(name) ⇒ Object
63 64 65 |
# File 'lib/webdriver/element.rb', line 63 def attribute name @connection.get File.join("attribute", name) end |
#clear! ⇒ Object
26 27 28 29 30 |
# File 'lib/webdriver/element.rb', line 26 def clear! @connection.post "clear" click! self end |
#click! ⇒ Object
67 68 69 |
# File 'lib/webdriver/element.rb', line 67 def click! @connection.post "click" end |
#css(name) ⇒ Object
55 56 57 |
# File 'lib/webdriver/element.rb', line 55 def css name @connection.get File.join("css", name) end |
#element(using, value) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/webdriver/element.rb', line 71 def element using, value el = @connection.post "element", {}, { using: using, value: value } Webdriver::Element.new el["ELEMENT"], @session_connection end |
#elements(using, value) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/webdriver/element.rb', line 79 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
22 23 24 |
# File 'lib/webdriver/element.rb', line 22 def enabled? @connection.get "enabled" end |
#property(name) ⇒ Object
59 60 61 |
# File 'lib/webdriver/element.rb', line 59 def property name @connection.get File.join("property", name) end |
#rect ⇒ Object
47 48 49 |
# File 'lib/webdriver/element.rb', line 47 def rect @connection.get "rect" end |
#screenshot ⇒ Object
12 13 14 |
# File 'lib/webdriver/element.rb', line 12 def screenshot @connection.get "screenshot" end |
#selected? ⇒ Boolean
checkbox
17 18 19 |
# File 'lib/webdriver/element.rb', line 17 def selected? @connection.get "selected" end |
#tag ⇒ Object
51 52 53 |
# File 'lib/webdriver/element.rb', line 51 def tag @connection.get "name" end |
#text ⇒ Object
43 44 45 |
# File 'lib/webdriver/element.rb', line 43 def text @connection.get "text" end |
#value!(value) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/webdriver/element.rb', line 32 def value! value value_string = value.to_s if value_string == "" clear! else @connection.post "value", {}, { value: [value_string] } end end |