title: Rails 5 Capybara not founding already clicked button
body: <p>I have the following test:</p>
  
  <pre><code>  it 'shows the current quantity of items inside cart' do
      item = create(:item)
      visit root_path
      click_link("add-item-#{item.id}")
      wait_for_ajax
      page.find('#notice-modal-ok').click
      click_link("add-item-#{item.id}")
      wait_for_ajax
      page.find('#notice-modal-ok').click
      expect(page).to have_selector('#cart-item-count', text: '2')
    end
  </code></pre>
  
  <p>It's basically a button with ajax thats show a success modal when return status 200. But, when the second ajax happens, for reason that I can't understand, the modal doesn't shows up. I can do this normally in dev environment.
  Thanks for help!</p>
  
  <hr>
  
  <p>Edit #1</p>
  
  <p>I added a <code>save_and_open_screenshot</code> to try to debug this. The code in the end looked this way:</p>
  
  <pre><code>  it 'shows the current quantity of items inside cart' do
      item = create(:item)
      visit root_path
      click_link("add-item-#{item.id}")
      page.find('#notice-modal-ok', wait: 10).click
      expect(page).not_to have_selector('#notice-modal-ok')
      click_link("add-item-#{item.id}")
      save_and_open_screenshot # image
      page.find('#notice-modal-ok', wait: 10).click # this fails
      expect(page).to have_selector('#cart-item-count', text: '2', wait: 10)
    end
  </code></pre>
  
  <p><img src="https://i.imgur.com/ui1x6u5.png" alt="Imgur">
  Imagem number 1</p>
  
  <p>As the images shows, the modal isn't appering on the second call. Here is the javascript thats shows it:</p>
  
  <pre><code>  $(document).ready(function() {
      $("a:regex(id,add-item-[0-9]+)").click(function(event) {
        event.preventDefault();
        var link = $(this).attr("href");
  
        $.ajax({
          url: link,
          method: "GET",
          dataType: "json",
          success: function(data) {
            $('#notice-modal').modal('show');
            if(data.quantity) {
              $("#cart-item-count").css('display', 'block');
              $("#cart-item-count").html(data.quantity);
            } else {
              $("#cart-item-count").hide()
            }
          }
        });
      })
    });
  </code></pre>
  
  <p>And in development mode, it works normally. Hope this new infos help!</p>