Created
February 18, 2016 03:39
-
-
Save shivabhusal/512618a86a3102284a62 to your computer and use it in GitHub Desktop.
New updated Waitofrajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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