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
62 63 64 |
# File 'lib/webdriver/element.rb', line 62 def attribute name @connection.get File.join("attribute", name) end |
#clear! ⇒ Object
26 27 28 29 |
# File 'lib/webdriver/element.rb', line 26 def clear! @connection.post "clear" click! end |
#click! ⇒ Object
66 67 68 |
# File 'lib/webdriver/element.rb', line 66 def click! @connection.post "click" end |
#css(name) ⇒ Object
54 55 56 |
# File 'lib/webdriver/element.rb', line 54 def css name @connection.get File.join("css", name) end |
#element(using, value) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/webdriver/element.rb', line 70 def element using, value el = @connection.post "element", {}, { using: using, value: value } Webdriver::Element.new el["ELEMENT"], @session_connection end |
#elements(using, value) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/webdriver/element.rb', line 78 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
58 59 60 |
# File 'lib/webdriver/element.rb', line 58 def property name @connection.get File.join("property", name) end |
#rect ⇒ Object
46 47 48 |
# File 'lib/webdriver/element.rb', line 46 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
50 51 52 |
# File 'lib/webdriver/element.rb', line 50 def tag @connection.get "name" end |
#text ⇒ Object
42 43 44 |
# File 'lib/webdriver/element.rb', line 42 def text @connection.get "text" end |
#value!(value) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/webdriver/element.rb', line 31 def value! value value_string = value.to_s if value_string == "" clear! else @connection.post "value", {}, { value: [value_string] } end end |