Culerity::RemoteBrowserProxy

Public Class Methods

new(io, browser_options = {}) click to toggle source
# File lib/culerity/remote_browser_proxy.rb, line 3
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

Public Instance Methods

confirm(bool, &block) click to toggle source

Specify whether to accept or reject all confirm js dialogs for the code in the block that’s run.

# File lib/culerity/remote_browser_proxy.rb, line 48
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
wait_until(time_to_wait=30, &block) click to toggle source

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.

# File lib/culerity/remote_browser_proxy.rb, line 18
def wait_until time_to_wait=30, &block
  Timeout.timeout(time_to_wait) do
    until block.call
      sleep 0.1
    end
  end
  true
end
wait_while(time_to_wait=30, &block) click to toggle source

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.

# File lib/culerity/remote_browser_proxy.rb, line 34
def wait_while time_to_wait=30, &block
  Timeout.timeout(time_to_wait) do
    while block.call
      sleep 0.1
    end
  end
  true
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.