Search code examples
javascriptcucumbercapybarapoltergeisttwitter-bootstrap-4

Capybara Poltergeist doesn't toggle dropdowns after click


I have a bootstrap website and for some reason the dropdowns stopped working.

My dropdown

<li class="dropdown nav-item">
    <a id="toggle-link">Click to reveal </a>
    <div class="dropdown-menu dropdown-menu-right">
        <a id="inside-dropdown" href="/profile/edit">Mon compte</a>
    </div>
</li>

Capybara does

find('a#toggle-link').click

But nothing happens on Poltergeist, the dropdown menu isn't beng revealed anymore (fine with selenium on safari). When looking at the html screenshot, it would seem the javascript failed to add the "open" class" on the dropdown

I am unsure what changed from before, apart from a gem update that boosted several gems. Poltergeist was untouched, Capybara bumped from 2.7.1 (but I tried rolling back, didn't change anything)

Anyone experienced such problems ?

Capybara 2.10.1 Poltergeist 1.10.0 Cucumber 2.4.0 Rails5

EDIT : after my gem upgrades, notable changes

  • Capybara 2.7.1 -> 2.10.1
  • Bootstrap 4.0.0.alpha3.1 -> 4.0.0alpha4
  • 5.0.0.rc1 -> 5.0.0.1

Solution

  • We experienced the same kind of problems. In our case, phantomjs was unable to parse js sources due to an unsupported ES6 keyword. But it does not raise an exception and just silently fails. The entire js stack wasn't loaded, including the code which handle clicks on dropdowns.