Skip to content

I.amAt()

Validate the URL of the current page.

Usage

js
I.amAt(url: string | RegExp)

Parameters

ParameterTypeDescription
urlstring | RegExpThe expected URL, relative path, query string, hash, or a regular expression to match against the current URL

Examples

Validate using absolute URL

js
I.goTo("https://example.com/cart")
I.amAt("https://example.com/cart")

Validates that the browser is currently at the exact URL.

Validate using relative path

js
I.goTo("https://example.com/cart")
I.amAt("/cart")

Validates that the current URL path is /cart.

Validate using a query string

js
I.goTo("https://mystore.com/?search=alice")
I.amAt("?search=alice")

Validates that the current URL query matches ?search=alice.

Validate using a hash

js
I.goTo("https://mystore.com/books#mystery")
I.amAt("#mystery")

Validates that the current URL hash is #mystery.

Validate using a regular expression

js
I.goTo("https://example.com/orders/12345?status=paid")
I.amAt(/\/orders\/\d+\?status=paid/)

Validates that the current URL matches the regular expression — this is useful when part of the URL is dynamic.