Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble interacting with Bootstrap modals via Capybara (v2)
    text
    copied!<p>In a Rails application I'm trying to test a <a href="https://getbootstrap.com/javascript/#modals" rel="nofollow">Bootstrap modal</a> with a <a href="http://loopj.com/jquery-tokeninput/" rel="nofollow">jQuery TokenInput field</a> in Rspec using Capybara with the <code>capybara-webkit</code> driver. The portion in question is as follows:</p> <pre><code>click_link 'Create Team Modal' sleep 1 within('div#modal_popup') do fill_in 'input#token-input-team_name', with: 'Fancy team name' sleep 1 fill_in 'input#token-input-team_name', with: '\t' sleep 1 click_button 'Create Team' end page.should have_content('Fancy team name') </code></pre> <ul> <li>Click button to get modal</li> <li>Fill in TokenInput with a team name</li> <li>Simulate a Tab key-press to get it selected</li> <li>Create the team</li> <li>Verify the name shows up on the page</li> </ul> <p>This will only work with all those <code>sleep 1</code>s in place; otherwise Capybara crashes at <code>have_content</code>, eventually resulting in a server error because the team name was never able to be selected properly. Other Bootstrap modals <em>without</em> a TokenInput field do not require a <code>sleep 1</code> before they load, however.</p> <p>With all that said, is there any way to get rid of the sleeps and have this proceed as normal? Capybara 2 took out <code>wait_until</code> (with good reason) since it will wait within the default wait time to test for something...but that doesn't seem to be reflected in my above test; it's as if Capybara does not engage in that wait period upon entering/exiting this modal. Anyone have any experience with this? Using Rails 3.2.10, Rspec 2.12, Capybara 2, capybara-webkit 0.14.0, TokenInput 1.6.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload