Sha256: a6834ac6047e8e26da68c829607e614144494e5454b25af7bbe93bc8196b43aa

Contents?: true

Size: 1.56 KB

Versions: 6

Compression:

Stored size: 1.56 KB

Contents

module Culerity
  class RemoteBrowserProxy < RemoteObjectProxy
    def initialize(io, browser_options = {})
      @io = io
      #sets the remote receiver to celerity for the new_browser message.
      @remote_object_id = "celerity".inspect 
      #celerity server will create a new browser which shall receive the remote calls from now on.
      @remote_object_id = new_browser(browser_options).inspect
    end
    
    # 
    # Calls the block until it returns true or +time_to_wait+ is reached.
    # +time_to_wait+ is 30 seconds by default
    # 
    # Returns true upon success
    # Raises Timeout::Error when +time_to_wait+ is reached.
    # 
    def wait_until time_to_wait=30, &block
      Timeout.timeout(time_to_wait) do
        until block.call
          sleep 0.1
        end
      end
      true
    end
    
    # 
    # Calls the block until it doesn't return true or +time_to_wait+ is reached.
    # +time_to_wait+ is 30 seconds by default
    # 
    # Returns true upon success
    # Raises Timeout::Error when +time_to_wait+ is reached.
    # 
    def wait_while time_to_wait=30, &block
      Timeout.timeout(time_to_wait) do
        while block.call
          sleep 0.1
        end
      end
      true
    end
    
    
    #
    # Specify whether to accept or reject all confirm js dialogs
    # for the code in the block that's run.
    # 
    def confirm(bool, &block)
      blk = "lambda { #{bool} }"
      
      self.send_remote(:add_listener, :confirm) { blk }
      block.call
      self.send_remote(:remove_listener, :confirm, lambda {blk})
    end
    
  end
  
  
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
culerity-0.2.12 lib/culerity/remote_browser_proxy.rb
culerity-0.2.10 lib/culerity/remote_browser_proxy.rb
fletcherm-culerity-0.2.9 lib/culerity/remote_browser_proxy.rb
culerity-0.2.9 lib/culerity/remote_browser_proxy.rb
fletcherm-culerity-0.2.8 lib/culerity/remote_browser_proxy.rb
culerity-0.2.8 lib/culerity/remote_browser_proxy.rb