Skip to content

Instantly share code, notes, and snippets.

@bm2ilabs
Created August 26, 2019 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bm2ilabs/88c699847870f2e604181b6da15be623 to your computer and use it in GitHub Desktop.
Save bm2ilabs/88c699847870f2e604181b6da15be623 to your computer and use it in GitHub Desktop.
Find link with href Dusk
<?php
Browser::macro('assertSeeLinkWithHref', function ($link, $href) {
$message = "Did not see expected link [{$link}] with href [{$href}].";
if ($this->resolver->prefix) {
$message .= " within [{$this->resolver->prefix}].";
}
$anchor = $this->resolver->find("a[href$='{$href}']");
$hasText = $anchor && (strpos($anchor->getText(), $link) !== false);
PHPUnit::assertTrue($anchor && $hasText, $message);
return $this;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment