Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Teamcapybara Capybara Path Assertion

From Leeroopedia
Knowledge Sources
Domains Testing, Assertions
Last Updated 2026-02-12 00:00 GMT

Overview

An assertion pattern that verifies the browser's current URL or path matches an expected value, with automatic waiting for navigation to complete.

Description

Path Assertion verifies that after a navigation action (like form submission or link clicking), the browser has arrived at the expected URL. It supports:

  • String comparison — Exact path or URL match
  • Regexp matching — Pattern-based URL verification
  • Auto-detection — Full URLs are compared against current_url; paths are compared against current_path + query string
  • Query ignoring — Option to ignore the query string portion

Like element assertions, path assertions use synchronize for auto-waiting, which is important after form submissions or redirects.

Usage

Use after actions that change the URL (form submissions, link clicks, redirects). Verify with expect(page).to have_current_path('/dashboard').

Theoretical Basis

# Abstract path assertion flow (not actual code)
assert_current_path(expected, url:, ignore_query:):
  synchronize(wait):
    actual = url ? current_url : current_path_with_query
    actual = strip_query(actual) if ignore_query
    match?(expected, actual) or raise ExpectationNotMet

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment