Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

161 lines (125 sloc) 2.711 kB
require "capybara"
require "capybara/driver/webkit/version"
require "capybara/driver/webkit/node"
require "capybara/driver/webkit/browser"
require "capybara/driver/webkit/socket_debugger"
require "capybara/driver/webkit/cookie_jar"
class Capybara::Driver::Webkit
class WebkitInvalidResponseError < StandardError
end
class WebkitNoResponseError < StandardError
end
class NodeNotAttachedError < Capybara::ElementNotFound
end
def initialize(app, options={})
@app = ErrorTrapper.new(app)
@options = options
@rack_server = Capybara::Server.new(@app)
@rack_server.boot if Capybara.run_server
@browser = options[:browser] || Browser.new(
:ignore_ssl_errors => options[:ignore_ssl_errors])
end
def current_url
browser.url
end
def requested_url
browser.requested_url
end
def visit(path)
browser.visit(url(path))
end
def find(query)
browser.find(query).map { |native| Node.new(self, native) }
end
def source
browser.source
end
def body
browser.body
end
def header(key, value)
browser.header(key, value)
end
def execute_script(script)
value = browser.execute_script script
value.empty? ? nil : value
end
def evaluate_script(script)
browser.evaluate_script script
end
def console_messages
browser.console_messages
end
def error_messages
browser.error_messages
end
def response_headers
browser.response_headers
end
def status_code
browser.status_code
end
def within_frame(frame_id_or_index)
browser.frame_focus(frame_id_or_index)
begin
yield
ensure
browser.frame_focus
end
end
def within_window(handle)
raise Capybara::NotSupportedByDriverError
end
def wait?
true
end
def wait_until(*args)
end
def reset!
@app.reset
browser.reset!
end
def has_shortcircuit_timeout?
false
end
def render(path, options={})
options[:width] ||= 1000
options[:height] ||= 10
browser.render path, options[:width], options[:height]
end
def server_port
@rack_server.port
end
def cookies
@cookie_jar ||= CookieJar.new(browser)
end
def browser
@app.raise_exception_from_server_thread
@browser
end
private
def url(path)
@rack_server.url(path)
end
class ErrorTrapper
def initialize(app)
@app = app
end
def raise_exception_from_server_thread
if @exception
raise @exception
end
end
def reset
@exception = nil
end
def call(env)
begin
@app.call(env)
rescue Exception => exception
@exception = exception
raise exception
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.