class Capybara::Poltergeist::Node
Attributes
id[R]
page_id[R]
Public Class Methods
new(driver, page_id, id)
click to toggle source
Calls superclass method
# File lib/capybara/poltergeist/node.rb, line 5 def initialize(driver, page_id, id) super(driver, self) @page_id = page_id @id = id end
Public Instance Methods
==(other)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 127 def ==(other) command :equals, other.id end
[](name)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 49 def [](name) command :attribute, name end
all_text()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 41 def all_text filter_text command(:all_text) end
browser()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 12 def browser driver.browser end
checked?()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 95 def checked? self[:checked] end
click()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 107 def click command :click end
command(name, *args)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 16 def command(name, *args) browser.send(name, page_id, id, *args) rescue BrowserError => error case error.name when 'Poltergeist.ObsoleteNode' raise ObsoleteNode.new(self, error.response) when 'Poltergeist.MouseEventFailed' raise MouseEventFailed.new(self, error.response) else raise end end
disabled?()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 103 def disabled? command :disabled? end
double_click()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 111 def double_click command :double_click end
drag_to(other)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 119 def drag_to(other) command :drag, other.id end
find(method, selector)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 29 def find(method, selector) command(:find_within, method, selector).map { |id| self.class.new(driver, page_id, id) } end
find_css(selector)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 37 def find_css(selector) find :css, selector end
find_xpath(selector)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 33 def find_xpath(selector) find :xpath, selector end
hover()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 115 def hover command :hover end
select_option()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 78 def select_option command :select, true end
selected?()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 99 def selected? self[:selected] end
send_keys(*keys)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 131 def send_keys(*keys) command :send_keys, keys end
Also aliased as: send_key
set(value)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 57 def set(value) if tag_name == 'input' case self[:type] when 'radio' click when 'checkbox' click if value != checked? when 'file' files = value.respond_to?(:to_ary) ? value.to_ary.map(&:to_s) : value.to_s command :select_file, files else command :set, value.to_s end elsif tag_name == 'textarea' command :set, value.to_s elsif self[:contenteditable] == 'true' command :delete_text send_keys(value.to_s) end end
tag_name()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 87 def tag_name @tag_name ||= command(:tag_name) end
trigger(event)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 123 def trigger(event) command :trigger, event end
unselect_option()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 82 def unselect_option command(:select, false) or raise(Capybara::UnselectNotAllowed, "Cannot unselect option from single select box.") end
value()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 53 def value command :value end
visible?()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 91 def visible? command :visible? end
visible_text()
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 45 def visible_text filter_text command(:visible_text) end
Private Instance Methods
filter_text(text)
click to toggle source
# File lib/capybara/poltergeist/node.rb, line 138 def filter_text(text) Capybara::Helpers.normalize_whitespace(text.to_s) end