In Capybara, you can implicitly wait for an element to appear with
find('.slide', visible: true)
How can I detect that I new/different slide is visible? So I can do something like this which currently doesn't work (Capybara finds the current .slide before it is hidden instead of waiting for the current slide to hide and new slide to show):
3.times do
find('.slide').fill_in('image[description]', with: 'foo')
click_link 'Next slide'
end
For example
I have markup like this:
<ul>
<li class="slide active" style="background: green;">
</li>
<li class="slide" style="background: blue;">
</li>
<li class="slide" style="background: pink;">
</li>
</ul>
<a href="#" class="next-slide">Next slide</a>
I have some javascript to hide the active slide and fade in the next slide:
$(document).ready(function() {
$('.next-slide').click(function(evt) {
evt.preventDefault();
var $activeSlide = $('.slide.active');
$activeSlide.next().addClass('active');
$activeSlide.hide().removeClass('active');
});
});
Complete JSFiddle: http://jsfiddle.net/epylinkn/fQHmf/1/