Capybara not waiting for ajax request to complete

I am trying to check the selection of an option from a select tag (these parameters are selected from a remote database server). During normal interaction with the website, filling out this drop-down list takes no more than one second. However, when I run the next test,



    When /^(?:|I )select "([^"]*)" from "([^"]*)" in search form$/ do |value, field|
      within "#select_container" do
        save_and_open_page
        page.should have_css("#criteria_div_code > option:nth-child(10)")
        select(value, :from => field)
      end 
    end


I get the following error:

expected css "#criteria_div_code > option:nth-child(10)" to return something (RSpec::Expectations::ExpectationNotMetError)

At least 20 parameters are indicated in the drop-down list, so I just check for the 10th option (at the moment).

save_and_open_page indicates that there is only one option (the default option) instead of at least 10 and, therefore, "ExpectionNotMetError" appears.

Capybara.default_wait_time = 30 - Easy time to populate lists.

Doesn't capybara wait for the ajax call to complete?

Did I miss something?

+5
2

, - ajax Capybara AJAX. - 10 , , , : resynchronize to false . - , -

 Capybara.register_driver :selenium do |app|
   Capybara::Selenium::Driver.new(app, :browser => :firefox, :resynchronization_timeout => 1000)
 end

. : resynchronize to false, true.

+2

, js- ajax-,

describe 'some stuff which requires js', :js => true do
  it 'will use the default js driver'
  it 'will switch to one specific driver', :driver => :celerity
end

: Capybara Ajax- , . , : resynchronize driver true.

0

All Articles