Skip to content

Commit

Permalink
Merge pull request #390 from sparc-request/kg-replace_capybara_webkit
Browse files Browse the repository at this point in the history
KG - Force WaitHelpers to wait until jQuery loaded on page
  • Loading branch information
Stuart-Johnson committed Dec 7, 2018
2 parents 9d4c17c + 2d8fa40 commit a4086cf
Showing 1 changed file with 5 additions and 0 deletions.
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

0 comments on commit a4086cf

Please sign in to comment.