class Undead::Browser
Constants
- ERROR_MAPPINGS
Attributes
client[R]
logger[R]
server[R]
Public Class Methods
new(server, client, logger = nil)
click to toggle source
# File lib/undead/browser.rb, line 18 def initialize(server, client, logger = nil) @server = server @client = client @logger = logger end
Public Instance Methods
body()
click to toggle source
# File lib/undead/browser.rb, line 28 def body command 'body' end
command(name, *args)
click to toggle source
# File lib/undead/browser.rb, line 42 def command(name, *args) cmd = Undead::Command.new(name, *args) log cmd.message response = server.send(cmd) log response json = JSON.load(response) if json['error'] klass = ERROR_MAPPINGS[json['error']['name']] || Undead::BrowserError raise klass.new(json['error']) else json['response'] end rescue Undead::DeadClient restart raise end
debug=(val)
click to toggle source
# File lib/undead/browser.rb, line 37 def debug=(val) @debug = val command 'set_debug', !!val end
js_errors=(val)
click to toggle source
# File lib/undead/browser.rb, line 32 def js_errors=(val) @js_errors = val command 'set_js_errors', !!val end
visit(url)
click to toggle source
# File lib/undead/browser.rb, line 24 def visit(url) command 'visit', url end
Private Instance Methods
log(message)
click to toggle source
# File lib/undead/browser.rb, line 64 def log(message) logger.puts message if logger end