Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KG - Force WaitHelpers to wait until jQuery loaded on page #390

Merged
merged 1 commit into from Dec 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions spec/support/features/wait_helpers.rb
Expand Up @@ -26,10 +26,15 @@ def wait_for_page(path)

def wait_for_ajax
Timeout.timeout(Capybara.default_max_wait_time) do
loop until jquery_defined?
loop until finished_all_ajax_requests? && finished_all_animations?
end
end

def jquery_defined?
page.evaluate_script(%Q{typeof jQuery !== 'undefined'}) && page.evaluate_script(%Q{typeof $ !== 'undefined'})
end

def finished_all_ajax_requests?
page.evaluate_script('jQuery.active') == 0
end
Expand Down