Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tell Capybara to wait until iframe has loaded (is ready)

Is there an elegant way to do this? At the moment i just use a custom step "And wait 10 seconds" to be absolutely sure, there is enough time for the iframe to get ready. I don't want this feature to fail on my underpowered CI VM because of a small network issue or cpu spikes. But this means that the feature suite wastes a lot of time, and as you know, if the test suite takes a long time, one often doesn't bother to run it outside the CI server.

like image 996
Marian Theisen Avatar asked Sep 08 '11 10:09

Marian Theisen


1 Answers

If you know what's going to be in your iframe you could do:

within_frame 'iframe_selector' do
    wait_until(10) do
        page.should have_content("Content you're waiting for")
    end
end

The wait_until method will keep waiting for 10 seconds or until the condition page.should returns true.

like image 198
Mazuhl Avatar answered Oct 14 '22 03:10

Mazuhl