Skip to content

Instantly share code, notes, and snippets.

@shivabhusal
Created February 18, 2016 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shivabhusal/512618a86a3102284a62 to your computer and use it in GitHub Desktop.
Save shivabhusal/512618a86a3102284a62 to your computer and use it in GitHub Desktop.
New updated Waitofrajax
# spec/support/wait_for_ajax.rb
# There is inbuild `wait_for_ajax` method in selinium WebDriver library
# This is for Capybara Webkit only
# #
module WaitForAjax
def wait_for_ajax(timeout = Capybara.default_wait_time)
Timeout.timeout(timeout) do
active = page.evaluate_script('jQuery.active')
until active == 0
active = page.evaluate_script('jQuery.active')
puts 'Checking if any AJAX requests going on.......'
end
puts 'Ajax finally completed!'
puts '@'* 100
end
end
end
RSpec.configure do |config|
config.include WaitForAjax, type: :feature
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment