Method: Capybara::Session#current_path

Defined in:
lib/capybara/session.rb

#current_pathString

Returns Path of the current page, without any domain information.

Returns:

  • (String)

    Path of the current page, without any domain information


204
205
206
207
208
209
210
211
212
213
# File 'lib/capybara/session.rb', line 204

def current_path
  # Addressable parsing is more lenient than URI
  uri = ::Addressable::URI.parse(current_url)

  # Addressable doesn't support opaque URIs - we want nil here
  return nil if uri&.scheme == 'about'

  path = uri&.path
  path unless path&.empty?
end