lib/symbiont/evaluators.rb in symbiont-0.1.7 vs lib/symbiont/evaluators.rb in symbiont-0.1.8
- old
+ new
@@ -1,72 +1,65 @@
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)
+ platform.visit(url)
end
- # Returns the text of the current page. This is the text minus any
- # markup.
def text
- @platform.text
+ platform.text
end
- # Returns the markup of the current page.
def markup
- @platform.markup
+ platform.markup
end
- alias :html :markup
+ alias_method :html, :markup
- # Returns the title of the current page.
def title
- @platform.title
+ platform.title
end
- # Returns the URL of the active page.
def url
- @platform.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
+ platform.screenshot file
end
- # Returns the web object that currently has focus.
def focus
- @platform.focus
+ platform.focus
end
-
+
+ alias_method :what_has_focus?, :focus
+
# Executes JavaScript against the browser instance.
def run_script(script)
- @platform.run_script(script)
+ platform.run_script(script)
end
- alias :execute_script :run_script
-
+ alias_method :execute_script, :run_script
+
+ def back
+ platform.back
+ end
+
# 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
+ def wait_for_pending_requests(time_limit=30, message_if_timeout=nil)
+ end_time = ::Time.now + time_limit
until ::Time.now > end_time
begin
- return if @browser.execute_script('return jQuery.active') == 0
+ return if browser.execute_script('return jQuery.active') == 0
rescue ReferenceError
end
sleep 0.5
end
- message = "Pending requests never indicated completion" unless message
+ message = "Pending jQuery requests never indicated completion." unless message_if_timeout
raise message
end
end # module: Evaluators
end # module: Symbiont