lib/symbiont/evaluators.rb in symbiont-0.1.5 vs lib/symbiont/evaluators.rb in symbiont-0.1.6
- old
+ new
@@ -49,7 +49,22 @@
@platform.run_script(script)
end
alias :execute_script :run_script
+ # Provides an evaluator that attempts to wait for any pending AJAX
+ # requests from the jQuery library.
+ #
+ # @param [Numeric] timeout amount of time to wait
+ # @param [String] message text to print if timeout period is exceeded
+ def wait_for_pending_requests(timeout=30, message=nil)
+ end_time = ::Time.now + timeout
+ until ::Time.now > end_time
+ return if @browser.run_script('return jQuery.active') == 0
+ sleep 0.5
+ end
+ message = "Pending requests never indicated completion" unless message
+ raise message
+ end
+
end # module: Evaluators
end # module: Symbiont