【发布时间】:2016-05-14 21:39:34
【问题描述】:
我无法使用 Behat/Mink 点击链接。 <span> 标签中有所需的文本,所以这可能是原因?
这是我的*.feature 文件的一部分:
Scenario: Tryin' to make it freakin' workin' yo!
Given I am on "/home/"
And I follow "Test"
Then I should be on "/test/"
这是我试图关注的页面的一部分:
<li id="ApplicationItem_test" class=" " data-placement="right" rel="popover" data-offset="-6" data-content="" data-original-title="test">
<a href="/app/tests/e76ee2a8d9094e11b6bb9c928c5d61e3/" data-subscription-id="e76ee2a8-d909-4e11-b6bb-9c928c5d61e3">
<i class="picon-money-icon-16"></i>
<span class="expand-element">test
</span>
<div id="nodeCounter_c592e0ce62c849fab427fc9f2a04b557" style="display:inline-block">
</div> </a>
</li>
<script type="text/javascript">
var node = { id: '#nodeCounter_c592e0ce62c849fab427fc9f2a04b557', action: '/app/tests/e76ee2a8d9094e11b6bb9c928c5d61e3/GetSidebarActionCount' };
Access.SideBar.nodesWithCounters.push(node);
</script>
这是我得到的错误:
And I follow "Test"
FeatureContext::clickLink()
Link with id|title|alt|text "Test" not found. (Behat\Mink\Exception\ElementNotFoundException)
尝试了互联网上所有可能的 CSS 选择器功能。我也想知道我是否不应该在这里为 Behat 使用 Selenium 扩展(因为 JS?)
【问题讨论】:
-
当我遇到这个问题时,是因为前面的步骤出错。只需确保
Given I am on "/home/"确实显示了您的期望,调试并在步骤上下文中添加$this->getSession()->getPage()->getHtml()以确保 html 正确且没有错误。 -
太棒了,你是对的!谢谢老兄,哟!