Class: Capybara::Driver::Celerity

Inherits:
Base
  • Object
show all
Defined in:
lib/capybara/driver/celerity_driver.rb

Direct Known Subclasses

Culerity

Defined Under Namespace

Classes: Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#cleanup!, #has_shortcircuit_timeout?, #wait_until, #within_frame, #within_window

Constructor Details

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

Returns a new instance of Celerity.



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

def initialize(app, options={})
  @app = app
  @options = options
  @rack_server = Capybara::Server.new(@app)
  @rack_server.boot if Capybara.run_server
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



87
88
89
# File 'lib/capybara/driver/celerity_driver.rb', line 87

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



87
88
89
# File 'lib/capybara/driver/celerity_driver.rb', line 87

def options
  @options
end

#rack_serverObject (readonly)

Returns the value of attribute rack_server.



87
88
89
# File 'lib/capybara/driver/celerity_driver.rb', line 87

def rack_server
  @rack_server
end

Instance Method Details

#bodyObject



108
109
110
# File 'lib/capybara/driver/celerity_driver.rb', line 108

def body
  browser.document.as_xml
end

#browserObject



135
136
137
138
139
140
141
142
# File 'lib/capybara/driver/celerity_driver.rb', line 135

def browser
  unless @_browser
    require 'celerity'
    @_browser = ::Celerity::Browser.new(:browser => :firefox, :log_level => :off)
  end

  @_browser
end

#current_urlObject



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

def current_url
  browser.url
end

#evaluate_script(script) ⇒ Object



131
132
133
# File 'lib/capybara/driver/celerity_driver.rb', line 131

def evaluate_script(script)
  browser.execute_script "#{script}"
end

#execute_script(script) ⇒ Object



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

def execute_script(script)
  browser.execute_script script
  nil
end

#find(selector) ⇒ Object



120
121
122
# File 'lib/capybara/driver/celerity_driver.rb', line 120

def find(selector)
  browser.elements_by_xpath(selector).map { |node| Node.new(self, node) }
end

#reset!Object



144
145
146
# File 'lib/capybara/driver/celerity_driver.rb', line 144

def reset!
  browser.clear_cookies
end

#response_headersObject



112
113
114
# File 'lib/capybara/driver/celerity_driver.rb', line 112

def response_headers
  browser.response_headers
end

#sourceObject



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

def source
  browser.html
end

#status_codeObject



116
117
118
# File 'lib/capybara/driver/celerity_driver.rb', line 116

def status_code
  browser.status_code
end

#visit(path) ⇒ Object



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

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

#wait?Boolean

Returns:

  • (Boolean)


124
# File 'lib/capybara/driver/celerity_driver.rb', line 124

def wait?; true; end