Sha256: 6d38d5da156681317fe5cf244fb1ccc6b3c1547ea1b5ad0ec6cce52171b24a01

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

module Symbiont
  module Evaluators

    ## Browser-Level Actions ##

    def visit(url)
      platform.visit(url)
    end

    alias_method :navigate_to, :visit

    def url
      platform.url
    end

    alias_method :current_url, :url

    # 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.
    def screenshot(file)
      platform.screenshot file
    end

    alias_method :save_screenshot, :screenshot

    # Executes JavaScript against the browser instance.
    def run_script(script)
      platform.run_script(script)
    end

    alias_method :execute_script, :run_script

    def back
      platform.back
    end

    def forward
      platform.forward
    end

    def refresh
      platform.refresh
    end

    def remove_cookies
      platform.remove_cookies
    end

    alias_method :clear_cookies, :remove_cookies

    ## Page-Level Actions ##

    def text
      platform.text
    end
    
    def markup
      platform.markup
    end
    
    alias_method :html, :markup
    
    def title
      platform.title
    end

    # Returns the element on a page that has the focus.
    def focus
      platform.focus
    end

    alias_method :what_has_focus?, :focus

    def wait_for_app(value=1)
      sleep value
    end

    # Provides an evaluator that attempts to wait for any pending AJAX
    # requests from the jQuery library.
    def wait_for_pending_requests(time_limit=30, message_if_timeout=nil)
      end_time = ::Time.now + time_limit
      until ::Time.now > end_time
        return if @browser.execute_script('return jQuery.active') == 0
        sleep 0.5
      end
      message = "Pending jQuery requests never indicated completion." unless message_if_timeout
      raise message
    end
    
  end # module: Evaluators
end # module: Symbiont

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
symbiont-0.2.1 lib/symbiont/evaluators.rb
symbiont-0.2.0 lib/symbiont/evaluators.rb