diff --git a/lib/capybara/spec/views/with_jquery_animation.erb b/lib/capybara/spec/views/with_jquery_animation.erb new file mode 100644 index 000000000..434384f4b --- /dev/null +++ b/lib/capybara/spec/views/with_jquery_animation.erb @@ -0,0 +1,24 @@ + + + + + with_jquery_animation + + + + + scroll top 500 + + + + + diff --git a/spec/shared_selenium_session.rb b/spec/shared_selenium_session.rb index 41db9d20a..670d10b49 100644 --- a/spec/shared_selenium_session.rb +++ b/spec/shared_selenium_session.rb @@ -411,6 +411,13 @@ JS expect(scroll_y).to eq 500 end + + it 'should scroll the page instantly without jquery animation', requires: [:js] do + @animation_session.visit('with_jquery_animation') + @animation_session.click_link('scroll top 500') + scroll_y = @animation_session.evaluate_script('window.scrollY') + expect(scroll_y).to eq 500 + end end context 'when set to `false`' do @@ -433,6 +440,13 @@ # measured over 0.5 seconds: 0, 75, 282, 478, 500 expect(scroll_y).to be < 500 end + + it 'should scroll the page with jquery animation', requires: [:js] do + @animation_session.visit('with_jquery_animation') + @animation_session.click_link('scroll top 500') + scroll_y = @animation_session.evaluate_script('window.scrollY') + expect(scroll_y).to be < 500 + end end context 'if we pass in css that matches elements' do