我正在使用Mink和Selenium 2驱动程序和Behat进行一些验收测试,在大多数情况下,一切都进行得很顺利。
但是,我试图使用 XPath 将基于 data-* 属性的元素作为目标,结果测试无法使用该元素。
我在这两个扩展中使用了XPathHelper和FirePath以及XPath签出:
//html//@data-search-id='images'
这似乎是只能针对特定“正确”的元素。
但是,当我向FeatureContext.php添加以下内容时:
$el = $this->getSession()->getPage()->find('xpath', $this->getSession()->getSelectorsHandler()->selectorToXpath('xpath', "//@data-search-id='images'"));
$el->click();
我从Behat得到了以下错误:
invalid selector: Unable to locate an element with the xpath expression
//html//@data-search-id='images' because of the following error:
TypeError: Failed to execute 'evaluate' on 'Document':
The result is not a node set, and therefore cannot be converted
to the desired type.