How to wait for an element to appear after an AJAX call using capybara-webkit?

The capybara method wait_untildoes not seem to work for capybara-webkit. Is there an alternative solution for this or any Javascript implementations?

Intentionally need a replacement for sleepexample. sleep 2.

enter image description here

+4
source share
3 answers

You can take a look at this solution wrapped by Thoughtbot: here

I found this very helpful.

+6
source

If your AJAX call causes the DOM to change, Capybara will wait for it if you do

page.should have_selector?("some selector")

Capybara, ( Capybara.default_wait_time) have_selector? , .

AJAX DOM, Capybara. , , AJAX Javascript - Capybara, . AJAX ( , ..). Capybara , .

Capybara 1 Capybara wait_until . wait_until Capybara 2. wait_until " 1" Rspec/Capybara ?

+4

, - :

# AJAX BEGIN
  expect(page).to have_selector('form#new_user_video .submit > .throbber')
  expect(page).to_not have_selector('form#new_user_video .submit > .throbber')
  # AJAX END

js- 'ajax: send' ( throbber) 'ajax: success' ( throbber). , .

ajax:

Capybara.default_wait_time = 5
0

Source: https://habr.com/ru/post/1547706/


All Articles