Class: Capybara::Driver::MechanicalCuke::Node
- Inherits:
-
Node
- Object
- Node
- Capybara::Driver::MechanicalCuke::Node
- Defined in:
- lib/mechanical-cuke/capybara.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #click ⇒ Object
- #select(option) ⇒ Object
- #set(value) ⇒ Object
- #tag_name ⇒ Object
- #text ⇒ Object
- #value ⇒ Object
Instance Method Details
#[](name) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/mechanical-cuke/capybara.rb', line 18 def [](name) if name == :value node.value else node.attribute(name.to_s) end end |
#click ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/mechanical-cuke/capybara.rb', line 57 def click if tag_name == 'a' link = driver.current_page.link_with(:node => self.node) link.click elsif self.node['type'] == 'submit' = driver.form.(:node => self.node) driver.form.() else nil end end |
#select(option) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/mechanical-cuke/capybara.rb', line 48 def select(option) field = driver.form.field_with(:node => node) if field_option = field.option_with(:value => option) field_option.select else raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: TODO" end end |
#set(value) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mechanical-cuke/capybara.rb', line 30 def set(value) case self.node['type'] when 'radio' radio = driver.form.(:node => node) if (value) radio.check else radio.uncheck end when 'checkbox' driver.form.checkbox_with(:node => node).checked = value when 'file' driver.form.file_upload_with(:node => node).file_name = value else driver.form.field_with(:node => node).value = value end end |
#tag_name ⇒ Object
69 70 71 |
# File 'lib/mechanical-cuke/capybara.rb', line 69 def tag_name node.node_name end |
#text ⇒ Object
14 15 16 |
# File 'lib/mechanical-cuke/capybara.rb', line 14 def text node.text end |
#value ⇒ Object
26 27 28 |
# File 'lib/mechanical-cuke/capybara.rb', line 26 def value driver.form.field_with(:node => node).value end |