Class: Capybara::Driver::Akephalos::Node
- Inherits:
-
Node
- Object
- Node
- Capybara::Driver::Akephalos::Node
- Defined in:
- lib/akephalos/capybara.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #click ⇒ Object
- #drag_to(element) ⇒ Object
- #select(option) ⇒ Object
- #set(value) ⇒ Object
- #tag_name ⇒ Object
- #text ⇒ Object
- #trigger(event) ⇒ Object
- #unselect(option) ⇒ Object
- #value ⇒ Object
- #visible? ⇒ Boolean
Instance Method Details
#[](name) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/akephalos/capybara.rb', line 5 def [](name) name = name.to_s case name when 'checked' node.checked? else node[name.to_s] end end |
#click ⇒ Object
81 82 83 |
# File 'lib/akephalos/capybara.rb', line 81 def click node.click end |
#drag_to(element) ⇒ Object
75 76 77 78 79 |
# File 'lib/akephalos/capybara.rb', line 75 def drag_to(element) trigger('mousedown') element.trigger('mousemove') element.trigger('mouseup') end |
#select(option) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/akephalos/capybara.rb', line 37 def select(option) result = node.select_option(option) if result == nil = node..map(&:text).join(", ") raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{}" else result end end |
#set(value) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/akephalos/capybara.rb', line 23 def set(value) if tag_name == 'textarea' node.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' node.value = value.to_s end end |
#tag_name ⇒ Object
67 68 69 |
# File 'lib/akephalos/capybara.rb', line 67 def tag_name node.tag_name end |
#text ⇒ Object
15 16 17 |
# File 'lib/akephalos/capybara.rb', line 15 def text node.text end |
#trigger(event) ⇒ Object
63 64 65 |
# File 'lib/akephalos/capybara.rb', line 63 def trigger(event) node.fire_event(event.to_s) end |
#unselect(option) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/akephalos/capybara.rb', line 48 def unselect(option) unless self[:multiple] raise Capybara::UnselectNotAllowed, "Cannot unselect option '#{option}' from single select box." end result = node.unselect_option(option) if result == nil = node..map(&:text).join(", ") raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{}" else result end end |
#value ⇒ Object
19 20 21 |
# File 'lib/akephalos/capybara.rb', line 19 def value node.value end |
#visible? ⇒ Boolean
71 72 73 |
# File 'lib/akephalos/capybara.rb', line 71 def visible? node.visible? end |