Method: Capybara::Node::Simple#text

Defined in:
lib/capybara/node/simple.rb

#text(_type = nil, normalize_ws: false) ⇒ String

Returns The text of the element.

Returns:

  • (String)

    The text of the element


31
32
33
34
# File 'lib/capybara/node/simple.rb', line 31

def text(_type = nil, normalize_ws: false)
  txt = native.text
  normalize_ws ? txt.gsub(/[[:space:]]+/, ' ').strip : txt
end