I'm new to Behat testing for my Drupal 8 site and trying to write a scenario to test that a URL does not exist on a page, but I can't seem to get it to work. The body field has a <a href="www.google.com"> cool</a> element.
@api
Feature: URL Scenario: Find a URL Given I am on "/hello" Then I should not see the link "www.google.com"
public function iShouldNotSeeTheLink($href, $index = 0, $message = '') {
$xpath = $this
->buildXPathQuery('//a[contains(@href, :href)]', [
':href' => $href,
]);
$message = $message ? $message : strtr('Link containing href %href found.', [
'%href' => $href,
]);
$links = $this->session
->getPage()
->findAll('xpath', $xpath);
$this
->assert(!empty($links[$index]), $message);
}