Class: Capybara::Node

Inherits:
Object
  • Object
show all
Includes:
Actions, Finders, Matchers
Defined in:
lib/capybara/node.rb,
lib/capybara/node/actions.rb,
lib/capybara/node/finders.rb,
lib/capybara/node/matchers.rb

Overview

A Capybara::Node represents either an element on a page through the subclass Capybara::Element or a document through Capybara::Document.

Both types of Node share the same methods, used for interacting with the elements on the page. These methods are divided into three categories, finders, actions and matchers. These are found in the modules Capybara::Node::Finders, Capybara::Node::Actions and Capybara::Node::Matchers respectively.

A Capybara::Session exposes all methods from Capybara::Document directly:

session = Capybara::Session.new(:rack_test, my_app)
session.visit('/')
session.fill_in('Foo', :with => 'Bar')    # from Capybara::Node::Actions
bar = session.find('#bar')              # from Capybara::Node::Finders
bar.select('Baz', :from => 'Quox')        # from Capybara::Node::Actions
session.has_css?('#foobar')               # from Capybara::Node::Matchers

Direct Known Subclasses

Document, Element

Defined Under Namespace

Modules: Actions, Finders, Matchers

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Matchers

#has_button?, #has_checked_field?, #has_content?, #has_css?, #has_field?, #has_link?, #has_no_button?, #has_no_content?, #has_no_css?, #has_no_field?, #has_no_link?, #has_no_select?, #has_no_table?, #has_no_xpath?, #has_select?, #has_table?, #has_unchecked_field?, #has_xpath?

Methods included from Actions

#attach_file, #check, #choose, #click_button, #click_link, #click_link_or_button, #drag, #fill_in, #select, #uncheck, #unselect

Methods included from Finders

#all, #find, #find_button, #find_by_id, #find_field, #find_link, #locate

Constructor Details

#initialize(session, base) ⇒ Node

Returns a new instance of Node.



34
35
36
37
# File 'lib/capybara/node.rb', line 34

def initialize(session, base)
  @session = session
  @base = base
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



28
29
30
# File 'lib/capybara/node.rb', line 28

def base
  @base
end

#sessionObject (readonly)

Returns the value of attribute session.



28
29
30
# File 'lib/capybara/node.rb', line 28

def session
  @session
end