lib/capybara/poltergeist/browser.rb in poltergeist-0.7.0 vs lib/capybara/poltergeist/browser.rb in poltergeist-1.0.0
- old
+ new
@@ -1,6 +1,7 @@
require 'multi_json'
+require 'time'
module Capybara::Poltergeist
class Browser
attr_reader :server, :client, :logger, :js_errors
@@ -14,12 +15,12 @@
def restart
server.restart
client.restart
end
- def visit(url, headers)
- command 'visit', url, headers
+ def visit(url)
+ command 'visit', url
end
def current_url
command 'current_url'
end
@@ -79,17 +80,24 @@
def execute(script)
command 'execute', script
end
- def within_frame(id, &block)
- command 'push_frame', id
+ def within_frame(name, &block)
+ command 'push_frame', name
yield
ensure
command 'pop_frame'
end
+ def within_window(name, &block)
+ command 'push_window', name
+ yield
+ ensure
+ command 'pop_window'
+ end
+
def click(page_id, id)
command 'click', page_id, id
end
def drag(page_id, id, other_id)
@@ -125,9 +133,33 @@
end
end
def equals(page_id, id, other_id)
command('equals', page_id, id, other_id)
+ end
+
+ def set_headers(headers)
+ command 'set_headers', headers
+ end
+
+ def response_headers
+ command 'response_headers'
+ end
+
+ def cookies
+ Hash[command('cookies').map { |cookie| [cookie['name'], Cookie.new(cookie)] }]
+ end
+
+ def set_cookie(cookie)
+ if cookie[:expires].respond_to?(:httpdate)
+ cookie[:expires] = cookie[:expires].httpdate
+ end
+
+ command 'set_cookie', cookie
+ end
+
+ def remove_cookie(name)
+ command 'remove_cookie', name
end
def command(name, *args)
message = { 'name' => name, 'args' => args }
log message.inspect