Class: Capybara::Driver::Grope

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

Defined Under Namespace

Classes: Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Grope

Returns a new instance of Grope.



119
120
121
122
123
124
# File 'lib/capybara/driver/grope_driver.rb', line 119

def initialize(app)
  @app = app
  @rack_server = Capybara::Server.new(@app)
  @rack_server.boot if Capybara.run_server
  @grope = Grope::Env.new
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



117
118
119
# File 'lib/capybara/driver/grope_driver.rb', line 117

def app
  @app
end

#gropeObject (readonly)

Returns the value of attribute grope.



117
118
119
# File 'lib/capybara/driver/grope_driver.rb', line 117

def grope
  @grope
end

#rack_serverObject (readonly)

Returns the value of attribute rack_server.



117
118
119
# File 'lib/capybara/driver/grope_driver.rb', line 117

def rack_server
  @rack_server
end

Instance Method Details

#bodyObject



139
140
141
# File 'lib/capybara/driver/grope_driver.rb', line 139

def body
  @grope.document.body.outerHTML
end

#current_urlObject



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

def current_url
  @grope.document.URL
end

#evaluate_script(script) ⇒ Object



153
154
155
# File 'lib/capybara/driver/grope_driver.rb', line 153

def evaluate_script(script)
  @grope.eval('return %s' % script)
end

#find(selector) ⇒ Object



147
148
149
# File 'lib/capybara/driver/grope_driver.rb', line 147

def find(selector)
  @grope.all(selector).map { |node| Node.new(self, node) }
end

#response_headersObject



143
144
145
# File 'lib/capybara/driver/grope_driver.rb', line 143

def response_headers
  response.headers
end

#sourceObject



135
136
137
# File 'lib/capybara/driver/grope_driver.rb', line 135

def source
  @grope.document.documentElement.outerHTML
end

#visit(path) ⇒ Object



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

def visit(path)
  @grope.load(url(path))
  @grope.wait
end

#wait?Boolean

Returns:

  • (Boolean)


151
# File 'lib/capybara/driver/grope_driver.rb', line 151

def wait?; true; end