Class: Capybara::RackTest::Node

### Home Classes Methods

### In Files

- lib/capybara/rack_test/node.rb

### Parent

Capybara::Driver::Node

### Methods

- #==
- #[]
- #all_text
- #checked?
- #click
- #disabled?
- #find_css
- #find_xpath
- #path
- #select_option
- #selected?
- #set
- #tag_name
- #unnormalized_text
- #unselect_option
- #value
- #visible?
- #visible_text

### Files

- another_test_file.txt
- test_file.txt

### Class/Module Index

Quicksearch

- Capybara
- Capybara::Ambiguous
- Capybara::CapybaraError
- Capybara::DSL
- Capybara::Driver
- Capybara::Driver::Base
- Capybara::Driver::Node
- Capybara::DriverNotFoundError
- Capybara::ElementNotFound
- Capybara::ExpectationNotMet
- Capybara::Features
- Capybara::FileNotFound
- Capybara::FrozenInTime
- Capybara::Helpers
- Capybara::InfiniteRedirectError
- Capybara::ModalNotFound
- Capybara::Node
- Capybara::Node::Actions
- Capybara::Node::Base
- Capybara::Node::Document
- Capybara::Node::DocumentMatchers
- Capybara::Node::Element
- Capybara::Node::Finders
- Capybara::Node::Matchers
- Capybara::Node::Simple
- Capybara::NotSupportedByDriverError
- Capybara::Queries
- Capybara::Queries::BaseQuery
- Capybara::Queries::TextQuery
- Capybara::Queries::TitleQuery
- Capybara::Query
- Capybara::RSpecMatchers
- Capybara::RSpecMatchers::BecomeClosed
- Capybara::RSpecMatchers::HaveSelector
- Capybara::RSpecMatchers::HaveText
- Capybara::RSpecMatchers::HaveTitle
- Capybara::RSpecMatchers::Matcher
- Capybara::RackTest
- Capybara::RackTest::Browser
- Capybara::RackTest::CSSHandlers
- Capybara::RackTest::Driver
- Capybara::RackTest::Form
- Capybara::RackTest::Form::NilUploadedFile
- Capybara::RackTest::Node
- Capybara::ReadOnlyElementError
- Capybara::Result
- Capybara::ScopeError
- Capybara::Selector
- Capybara::Selector::Filter
- Capybara::Selenium
- Capybara::Selenium::Driver
- Capybara::Selenium::Node
- Capybara::Server
- Capybara::Server::Middleware
- Capybara::Session
- Capybara::SpecHelper
- Capybara::UnselectNotAllowed
- Capybara::Window
- Capybara::WindowError
- TestApp
- TestApp::TestAppError
- Object

No matching classes.

# Capybara::RackTest::Node

### Public Instance Methods

==(other) click to toggle source

    # File lib/capybara/rack_test/node.rb, line 100
    def ==(other)
      native == other.native
    end

[](name) click to toggle source

    # File lib/capybara/rack_test/node.rb, line 10
    def [](name)
      string_node[name]
    end

all_text() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 2
    def all_text
      Capybara::Helpers.normalize_whitespace(native.text)
    end

checked?() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 72
    def checked?
      string_node.checked?
    end

click() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 52
    def click
      if tag_name == 'a' && !self[:href].nil?
        method = self["data-method"] if driver.options[:respect_data_method]
        method ||= :get
        driver.follow(method, self[:href].to_s)
      elsif (tag_name == 'input' and %(submit image).include?(type)) or
          ((tag_name == 'button') and type.nil? or type == "submit")
        associated_form = form
        Capybara::RackTest::Form.new(driver, associated_form).submit(self) if associated_form
      end
    end

disabled?() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 80
    def disabled?
      if %(option optgroup).include? tag_name
        string_node.disabled? || find_xpath("parent::*")[0].disabled?
      else
        string_node.disabled?
      end
    end

find_css(locator) click to toggle source

    # File lib/capybara/rack_test/node.rb, line 96
    def find_css(locator)
      native.css(locator, Capybara::RackTest::CSSHandlers.new).map { |n| self.class.new(driver, n) }
    end

find_xpath(locator) click to toggle source

    # File lib/capybara/rack_test/node.rb, line 92
    def find_xpath(locator)
      native.xpath(locator).map { |n| self.class.new(driver, n) }
    end

path() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 88
    def path
      native.path
    end

select_option() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 38
    def select_option
      if select_node['multiple'] != 'multiple'
        select_node.find_xpath(".//option[@selected]").each { |node| node.native.remove_attribute("selected") }
      end
      native["selected"] = 'selected'
    end

selected?() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 76
    def selected?
      string_node.selected?
    end

set(value) click to toggle source

    # File lib/capybara/rack_test/node.rb, line 18
    def set(value)
      if (Array === value) && !self[:multiple]
        raise ArgumentError.new "Value cannot be an Array when 'multiple' attribute is not present. Not a #{value.class}"
      end

      if radio?
        set_radio(value)
      elsif checkbox?
        set_checkbox(value)
      elsif input_field?
        set_input(value)
      elsif textarea?
        if self[:readonly]
          warn "Attempt to set readonly element with value: #{value} \n * This will raise an exception in a future version of Capybara"
        else
          native.content = value.to_s
        end
      end
    end

tag_name() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 64
    def tag_name
      native.node_name
    end

unselect_option() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 45
    def unselect_option
      if select_node['multiple'] != 'multiple'
        raise Capybara::UnselectNotAllowed, "Cannot unselect option from single select box."
      end
      native.remove_attribute('selected')
    end

value() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 14
    def value
      string_node.value
    end

visible?() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 68
    def visible?
      string_node.visible?
    end

visible_text() click to toggle source

    # File lib/capybara/rack_test/node.rb, line 6
    def visible_text
      Capybara::Helpers.normalize_whitespace(unnormalized_text)
    end

### Protected Instance Methods

unnormalized_text(check_ancestor_visibility = true) click to toggle source

    # File lib/capybara/rack_test/node.rb, line 106
    def unnormalized_text(check_ancestor_visibility = true)
      if !string_node.visible?(check_ancestor_visibility)
        ''
      elsif native.text?
        native.text
      elsif native.element?
        native.children.map do |child|
          Capybara::RackTest::Node.new(driver, child).unnormalized_text(false)
        end.join
      else
        ''
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.