module Symbiont module Evaluators # Visits a page via a specified URL. The URL can be specified as a domain # address or as a file-based link. # @param [String] url the full URL to navigate to def visit(url) @platform.visit(url) end # Returns the text of the current page. This is the text minus any # markup. def text @platform.text end # Returns the markup of the current page. def markup @platform.markup end alias :html :markup # Returns the title of the current page. def title @platform.title end # Returns the URL of the active page. def url @platform.url end # Save a snapshot of the current screen to a provided file location. # The file will be saved as a PNG file in the path specified or in the # location where the tests are being run from. # @param [String] file the file name to save the image as def screenshot(file) @platform.screenshot file end # Returns the web object that currently has focus. def focus @platform.focus end # Executes JavaScript against the browser instance. def run_script(script) @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 begin return if @browser.execute_script('return jQuery.active') == 0 rescue ReferenceError end sleep 0.5 end message = "Pending requests never indicated completion" unless message raise message end end # module: Evaluators end # module: Symbiont