Class: Capybara::Driver::Akephalos::Node
- Inherits:
-
Node
- Object
- Node
- Capybara::Driver::Akephalos::Node
- Defined in:
- lib/akephalos/capybara.rb
Overview
Akephalos-specific implementation for Capybara’s Driver::Node class.
Instance Method Summary collapse
-
#[](name) ⇒ String
The attribute value.
-
#checked? ⇒ true, false
The element’s visiblity.
-
#click ⇒ Object
Click the element.
-
#drag_to(element) ⇒ Object
Drag the element on top of the target element.
-
#find(selector) ⇒ Array<Node>
The matched nodes.
-
#path ⇒ String
The XPath to locate the node.
- #select_option ⇒ Object
-
#selected? ⇒ true, false
The element’s visiblity.
-
#set(value) ⇒ Object
Set the form element’s value.
-
#tag_name ⇒ String
The element’s tag name.
-
#text ⇒ String
The inner text of the node.
-
#trigger(event) ⇒ Object
Trigger an event on the element.
-
#unselect_option ⇒ Object
Unselect an option from a select box.
-
#value ⇒ String+
The form element’s value.
-
#visible? ⇒ true, false
The element’s visiblity.
Instance Method Details
#[](name) ⇒ String
Returns the attribute value.
21 22 23 24 25 26 27 28 29 |
# File 'lib/akephalos/capybara.rb', line 21 def [](name) name = name.to_s case name when 'checked' native.checked? else native[name.to_s] end end |
#checked? ⇒ true, false
Returns the element’s visiblity.
100 101 102 |
# File 'lib/akephalos/capybara.rb', line 100 def checked? native.checked? end |
#click ⇒ Object
Click the element.
72 73 74 |
# File 'lib/akephalos/capybara.rb', line 72 def click native.click end |
#drag_to(element) ⇒ Object
Drag the element on top of the target element.
80 81 82 83 84 |
# File 'lib/akephalos/capybara.rb', line 80 def drag_to(element) trigger('mousedown') element.trigger('mousemove') element.trigger('mouseup') end |
#find(selector) ⇒ Array<Node>
Returns the matched nodes.
127 128 129 130 131 |
# File 'lib/akephalos/capybara.rb', line 127 def find(selector) nodes = [] native.find(selector).each { |node| nodes << self.class.new(self, node) } nodes end |
#path ⇒ String
Returns the XPath to locate the node.
112 113 114 |
# File 'lib/akephalos/capybara.rb', line 112 def path native.xpath end |
#select_option ⇒ Object
56 57 58 |
# File 'lib/akephalos/capybara.rb', line 56 def select_option native.click end |
#selected? ⇒ true, false
Returns the element’s visiblity.
106 107 108 |
# File 'lib/akephalos/capybara.rb', line 106 def selected? native.selected? end |
#set(value) ⇒ Object
Set the form element’s value.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/akephalos/capybara.rb', line 41 def set(value) if tag_name == 'textarea' native.value = value.to_s elsif tag_name == 'input' and type == 'radio' click elsif tag_name == 'input' and type == 'checkbox' if value != self['checked'] click end elsif tag_name == 'input' native.value = value.to_s end end |
#tag_name ⇒ String
Returns the element’s tag name.
88 89 90 |
# File 'lib/akephalos/capybara.rb', line 88 def tag_name native.tag_name end |
#text ⇒ String
Returns the inner text of the node.
14 15 16 |
# File 'lib/akephalos/capybara.rb', line 14 def text native.text end |
#trigger(event) ⇒ Object
Trigger an event on the element.
120 121 122 |
# File 'lib/akephalos/capybara.rb', line 120 def trigger(event) native.fire_event(event.to_s) end |
#unselect_option ⇒ Object
Unselect an option from a select box.
63 64 65 66 67 68 69 |
# File 'lib/akephalos/capybara.rb', line 63 def unselect_option unless select_node.multiple_select? raise Capybara::UnselectNotAllowed, "Cannot unselect option from single select box." end native.unselect end |
#value ⇒ String+
Returns the form element’s value.
33 34 35 |
# File 'lib/akephalos/capybara.rb', line 33 def value native.value end |
#visible? ⇒ true, false
Returns the element’s visiblity.
94 95 96 |
# File 'lib/akephalos/capybara.rb', line 94 def visible? native.visible? end |