Capybara::Driver::Celerity::Node

Public Instance Methods

[](name) click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 7
def [](name)
  value = if name.to_sym == :class
    node.class_name
  else
    node.send(name.to_sym)
  end
  return value if value and not value.to_s.empty?
end
click() click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 52
def click
  node.click
end
drag_to(element) click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 56
def drag_to(element)
  node.fire_event('mousedown')
  element.node.fire_event('mousemove')
  element.node.fire_event('mouseup')
end
path() click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 72
def path
  node.xpath
end
select(option) click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 28
def select(option)
  node.select(option)
rescue
  options = all(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
  raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
end
set(value) click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 24
def set(value)
  node.set(value)
end
tag_name() click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 62
def tag_name
  # FIXME: this might be the dumbest way ever of getting the tag name
  # there has to be something better...
  node.to_xml[/^\s*<([a-z0-9\-\:]+)/, 1]
end
text() click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 3
def text
  node.text
end
trigger(event) click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 76
def trigger(event)
  node.fire_event(event.to_s)
end
unselect(option) click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 35
def unselect(option)
  unless node.multiple?
    raise Capybara::UnselectNotAllowed, "Cannot unselect option '#{option}' from single select box."
  end

  # FIXME: couldn't find a clean way to unselect, so clear and reselect
  selected_options = node.selected_options
  if unselect_option  = selected_options.detect { |value| value == option } ||
                        selected_options.detect { |value| value.index(option) }
    node.clear
    (selected_options - [unselect_option]).each { |value| node.select_value(value) }
  else
    options = all(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
    raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
  end
end
value() click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 16
def value
  if tag_name == "select" and node.multiple?
    node.selected_options
  else
    super
  end
end
visible?() click to toggle source
# File lib/capybara/driver/celerity_driver.rb, line 68
def visible?
  node.visible?
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.