Search code examples
bddbehatmink

Not able to follow link | Behat/Mink


Am not able to click on links using Behat/Mink. There's a desired text in <span> tags so maybe this could be the reason? This is part of my *.feature file:

Scenario: Tryin' to make it freakin' workin' yo!
Given I am on "/home/"
And I follow "Test"
Then I should be on "/test/"

And this is part of the page am trying to focus on:

<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 this is the error I'm getting:

And I follow "Test"
FeatureContext::clickLink()
Link with id|title|alt|text "Test" not found. (Behat\Mink\Exception\ElementNotFoundException)

Have tried all possible CSS selector functions found on the internet. Also am wondering if I shouldn't use the Selenium extension for Behat here (because of the JS?)


Solution

  • So answer is: I wasn't on the right page. Basically Scenarios should be independent - that means my previous session was burnt and I missed some previous steps (login, for example.)