Class: Capybara::Driver::Webkit

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/driver/webkit/socket_debugger.rb,
lib/capybara/driver/webkit/version.rb,
lib/capybara/driver/webkit/connection.rb,
lib/capybara/driver/webkit/browser.rb,
lib/capybara/driver/webkit/node.rb,
lib/capybara/driver/webkit.rb

Overview

Wraps the TCP socket and prints data sent and received. Used for debugging the wire protocol. You can use this by passing a :socket_class to Browser.

Defined Under Namespace

Classes: Browser, Connection, CookieJar, Node, NodeNotAttachedError, SocketDebugger, WebkitInvalidResponseError, WebkitNoResponseError

Constant Summary

VERSION =
'0.12.1'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Webkit

Returns a new instance of Webkit



21
22
23
24
25
26
27
28
# File 'lib/capybara/driver/webkit.rb', line 21

def initialize(app, options={})
  @app = app
  @options = options
  @rack_server = Capybara::Server.new(@app)
  @rack_server.boot if Capybara.run_server
  @browser = options[:browser] || Browser.new(Connection.new(options))
  @browser.ignore_ssl_errors if options[:ignore_ssl_errors]
end

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser



19
20
21
# File 'lib/capybara/driver/webkit.rb', line 19

def browser
  @browser
end

Instance Method Details

#bodyObject



50
51
52
# File 'lib/capybara/driver/webkit.rb', line 50

def body
  browser.body
end

#console_messagesObject



67
68
69
# File 'lib/capybara/driver/webkit.rb', line 67

def console_messages
  browser.console_messages
end

#cookiesObject



126
127
128
# File 'lib/capybara/driver/webkit.rb', line 126

def cookies
  @cookie_jar ||= CookieJar.new(browser)
end

#current_urlObject



30
31
32
# File 'lib/capybara/driver/webkit.rb', line 30

def current_url
  browser.current_url
end

#error_messagesObject



71
72
73
# File 'lib/capybara/driver/webkit.rb', line 71

def error_messages
  browser.error_messages
end

#evaluate_script(script) ⇒ Object



63
64
65
# File 'lib/capybara/driver/webkit.rb', line 63

def evaluate_script(script)
  browser.evaluate_script script
end

#execute_script(script) ⇒ Object



58
59
60
61
# File 'lib/capybara/driver/webkit.rb', line 58

def execute_script(script)
  value = browser.execute_script script
  value.empty? ? nil : value
end

#find(query) ⇒ Object



42
43
44
# File 'lib/capybara/driver/webkit.rb', line 42

def find(query)
  browser.find(query).map { |native| Node.new(self, native) }
end

#has_shortcircuit_timeout?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/capybara/driver/webkit.rb', line 111

def has_shortcircuit_timeout?
  false
end

#header(key, value) ⇒ Object



54
55
56
# File 'lib/capybara/driver/webkit.rb', line 54

def header(key, value)
  browser.header(key, value)
end

#render(path, options = {}) ⇒ Object



115
116
117
118
119
120
# File 'lib/capybara/driver/webkit.rb', line 115

def render(path, options={})
  options[:width]  ||= 1000
  options[:height] ||= 10

  browser.render path, options[:width], options[:height]
end

#requested_urlObject



34
35
36
# File 'lib/capybara/driver/webkit.rb', line 34

def requested_url
  browser.requested_url
end

#reset!Object



107
108
109
# File 'lib/capybara/driver/webkit.rb', line 107

def reset!
  browser.reset!
end

#resize_window(width, height) ⇒ Object



83
84
85
# File 'lib/capybara/driver/webkit.rb', line 83

def resize_window(width, height)
  browser.resize_window(width, height)
end

#response_headersObject



75
76
77
# File 'lib/capybara/driver/webkit.rb', line 75

def response_headers
  browser.response_headers
end

#server_portObject



122
123
124
# File 'lib/capybara/driver/webkit.rb', line 122

def server_port
  @rack_server.port
end

#sourceObject



46
47
48
# File 'lib/capybara/driver/webkit.rb', line 46

def source
  browser.source
end

#status_codeObject



79
80
81
# File 'lib/capybara/driver/webkit.rb', line 79

def status_code
  browser.status_code
end

#visit(path) ⇒ Object



38
39
40
# File 'lib/capybara/driver/webkit.rb', line 38

def visit(path)
  browser.visit(url(path))
end

#wait?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/capybara/driver/webkit.rb', line 100

def wait?
  true
end

#wait_until(*args) ⇒ Object



104
105
# File 'lib/capybara/driver/webkit.rb', line 104

def wait_until(*args)
end

#within_frame(frame_id_or_index) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/capybara/driver/webkit.rb', line 87

def within_frame(frame_id_or_index)
  browser.frame_focus(frame_id_or_index)
  begin
    yield
  ensure
    browser.frame_focus
  end
end

#within_window(handle) ⇒ Object

Raises:

  • (Capybara::NotSupportedByDriverError)


96
97
98
# File 'lib/capybara/driver/webkit.rb', line 96

def within_window(handle)
  raise Capybara::NotSupportedByDriverError
end