Skip to main content

Links

DrevOps\BehatSteps\Steps\Web\LinkTrait - Source, Example

Verify link elements with attribute and content assertions.

  • Find links by text, by title, or by text and href, optionally within an element.
  • Assert link existence and href match.
  • Assert absolute and relative link paths.

Steps​

@When I follow the link with the title :title

Click on the link with a title

When I follow the link with the title "Return to site content"
@Then I should see the link :link

Assert that a link exists

Then I should see the link "About us"
@Then I should not see the link :link

Assert that a link does not exist

Then I should not see the link "Admin"
@Then the link :link with the href :href should exist

Assert a link with a href exists

Then the link "About us" with the href "/about-us" should exist
Then the link "About us" with the href "/about*" should exist
@Then the link :link with the href :href within the element :selector should exist

Assert link with a href exists within an element

Then the link "About us" with the href "/about-us" within the element ".main-nav" should exist
Then the link "About us" with the href "/about*" within the element ".main-nav" should exist
@Then the link :link with the href :href should not exist

Assert link with a href does not exist

Then the link "About us" with the href "/about-us" should not exist
Then the link "About us" with the href "/about*" should not exist
@Then the link :link with the href :href within the element :selector should not exist

Assert link with a href does not exist within an element

Then the link "About us" with the href "/about-us" within the element ".main-nav" should not exist
Then the link "About us" with the href "/about*" within the element ".main-nav" should not exist
@Then the link with the title :title should exist

Assert that a link with a title exists

Then the link with the title "Return to site content" should exist
@Then the link with the title :title should not exist

Assert that a link with a title does not exist

Then the link with the title "Some non-existing title" should not exist
@Then the link :link should be an absolute link

Assert that the link with a text is absolute

Then the link "my-link-title" should be an absolute link
@Then the link :link should not be an absolute link

Assert that the link is not absolute

Then the link "Return to site content" should not be an absolute link