ruby wait_until并等待ajax

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby wait_until并等待ajax相关的知识,希望对你有一定的参考价值。

# add this file capybara_wait_until.rb to your /test directory

module Capybara
  class Session
    ##
    #
    # Retry executing the block until a truthy result is returned or the timeout time is exceeded
    #
    # @param [Integer] timeout   The amount of seconds to retry executing the given block
    #
    # this method was removed in Capybara v2 so adding it back if not already defined
    #
    unless defined?(wait_until)
      def wait_until(timeout = Capybara.default_wait_time)
        Capybara.send(:timeout, timeout, driver) { yield }
      end
    end
  end
end

# Use it this way in /test/integration_test_helper.rb:

require 'capybara_wait_until'
module ActionController
  class IntegrationTest
    def wait_for_ajax_to_complete
      # pass timeout in seconds if you need to override default_wait_time
      page.wait_until { page.evaluate_script('jQuery.active === 0') }
    end
  end
end

以上是关于ruby wait_until并等待ajax的主要内容,如果未能解决你的问题,请参考以下文章

条件变量wait_until timeout_time过去了?

sh wait_until.sh

RUBY 脚本:连接到 Telnet 会话时等待任何输出

ajax导出excel文件并增加等待动画效果

conditon_variable(条件变量)用于线程间同步

使用 AJAX 请求下载文件数据 - ruby​​ on rails 3