【发布时间】:2020-07-16 05:27:36
【问题描述】:
我对我的 Drupal 8 站点的 Behat 测试不熟悉,并尝试编写一个场景来测试页面上不存在 URL,但我似乎无法让它工作。 body 字段有一个<a href="www.google.com"> cool</a> 元素。
@api
功能:网址 场景:查找 URL 鉴于我在“/你好” 那么我不应该看到链接“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);
}
【问题讨论】: