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



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

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