ruby on rails - Capybara does not waiting for ajax to finish -


i trying test signup flow using rspec , cpaybara within feature spec. signup happens via ajax , capybara doesn't wait request complete. using capybara matchers specified in documentation. if add sleep statement test succeeds

let(:user) { create(:user, email: 'test@example.com', password: 'password') }  scenario 'visitor can sign valid email address , password', js: true    sign_up_with('name', 'test@example.com', 'password')    expect(page).to have_content(i18n.t( 'devise.registrations.signed_up')) end 

helper method handle signup:

def sign_up_with(name, email, password)   visit root_path   find(:xpath,"//a[text()='join']").click    within("#sign_up_choices")     click_on "sign email"   end    within("#sign_up")     fill_in 'user[name]', with: name     fill_in 'user[email]', with: email     fill_in 'user[password]', with: password     click_button 'sign up'   end end 

when user clicks on signup form gets submitted via ajax.

error getting occasionally:

selenium::webdriver::error::staleelementreferenceerror: stale element reference: element not attached page document (session info: chrome=55.0.2883.95) (driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=mac os x 10.11.4 x86_64)

any appreciated!


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -