Assert that a specific link on the page - identified by its visible text - has an href attribute that contains the given URL fragment. The step locates the first element whose exact visible text matches the first parameter, waits up to 5 seconds for it to appear, then reads the resolved href and checks whether the second parameter is a substring of that value.
The URL check is a substring match, so partial paths work: passing /about will match /about, /about-us, and https://example.org/about?ref=nav. The step fails immediately if no element with that text is found within the timeout, or if the resolved href does not contain the expected string. A companion phrasing lets you locate the link by a CSS selector or attribute value instead of by visible text - useful when multiple links share the same label or when the link has no readable text.
Accepted phrasings
Then the "Login" link should contain "/log-in"
Then "Home" link should contain "/"
And the "About Us" link should contain "/about"
# Locate by attribute / selector instead of visible text:
Then the "#about-us-id" link should contain "about" by attr
And the ".contactUs" link should contain "/contact-" by attr
And the "aboutUs" link should contain "about" by its "class" attribute
Examples
Then the "Login" link should contain "/log-in"
And the "About Us" link should contain "/about"
Then "Home" link should contain "/"
Then the "#skip-to-content" link should contain "#main" by attr
In a real scenario
@check @staging @production
Scenario: Footer navigation links resolve to the correct paths
Given I am an anonymous user
When I go to homepage
And wait
Then the "About" link should contain "/about"
And the "Contact Us" link should contain "/contact"
And the "Privacy Policy" link should contain "/privacy"
And the "Terms of Service" link should contain "/terms"