mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
14 lines
439 B
Ruby
14 lines
439 B
Ruby
# frozen_string_literal: true
|
|
|
|
module JQueryMacros
|
|
# Wait for one jQuery Ajax request during the block
|
|
def wait_for_ajax
|
|
flag = "window.ajax_#{SecureRandom.alphanumeric(16)}"
|
|
page.execute_script "#{flag} = false; $(document).one('ajaxComplete', () => #{flag} = true);"
|
|
|
|
yield
|
|
|
|
Timeout.timeout(Capybara.default_max_wait_time) { loop until page.evaluate_script(flag) }
|
|
page.execute_script "delete #{flag};"
|
|
end
|
|
end
|