【发布时间】:2015-11-11 11:24:32
【问题描述】:
我正在使用 Behat 测试第三方网店。我在购物车中有一个要删除的项目。一个确认弹出窗口显示询问我是否真的想这样做。该对话框的结构如下所示:
<div>
<strong class="title">Remove item from shoppingcart</strong>
<p>Are you sure you want to delete this product?</p>
<div class="button-container">
<span class="button" data-confirm="true">Yes</span>
<span class="button alt right" data-mfp-close-link="true">No</span>
</div>
</div>
我可以通过以下代码使用 xpath 选择跨度:
public function iConfirmTheWindow()
{
$session = $this->getSession();
$element = $session->getPage()->find(
'xpath',
$session->getSelectorsHandler()->selectorToXpath('css', 'span.button')
);
if (null === $element) {
throw new \InvalidArgumentException(sprintf('Could not find confirmation window'));
}
$element->click();
}
选择有效,但 Behat 似乎无法单击跨度。
supports clicking on links and submit or reset buttons only. But "span" provided
我需要点击这个项目,我该如何重写我的函数以便它可以被点击?
【问题讨论】:
标签: html testing click behat mink