Module: Capybara

Extended by:
Capybara
Included in:
Capybara
Defined in:
lib/capybara.rb,
lib/capybara/dsl.rb,
lib/capybara/node.rb,
lib/capybara/xpath.rb,
lib/capybara/session.rb,
lib/capybara/searchable.rb,
lib/capybara/wait_until.rb,
lib/capybara/save_and_open_page.rb

Defined Under Namespace

Modules: Driver, SaveAndOpenPage, Searchable Classes: CapybaraError, DriverNotFoundError, ElementNotFound, InfiniteRedirectError, LocateHiddenElementError, Node, NotSupportedByDriverError, OptionNotFound, Server, Session, TimeoutError, UnselectNotAllowed, WaitUntil, XPath

Constant Summary collapse

VERSION =
'0.3.2'

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.appObject

Returns the value of attribute app.



7
8
9
# File 'lib/capybara/dsl.rb', line 7

def app
  @app
end

.app_hostObject

Returns the value of attribute app_host.



18
19
20
# File 'lib/capybara.rb', line 18

def app_host
  @app_host
end

.asset_rootObject

Returns the value of attribute asset_root.



18
19
20
# File 'lib/capybara.rb', line 18

def asset_root
  @asset_root
end

.current_driverObject Also known as: mode



13
14
15
# File 'lib/capybara/dsl.rb', line 13

def current_driver
  @current_driver || default_driver
end

.debugObject

Returns the value of attribute debug.



18
19
20
# File 'lib/capybara.rb', line 18

def debug
  @debug
end

.default_driverObject



9
10
11
# File 'lib/capybara/dsl.rb', line 9

def default_driver
  @default_driver || :rack_test
end

.default_selectorObject

Returns the value of attribute default_selector.



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

def default_selector
  @default_selector
end

.default_wait_timeObject

Returns the value of attribute default_wait_time.



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

def default_wait_time
  @default_wait_time
end

.ignore_hidden_elementsObject

Returns the value of attribute ignore_hidden_elements.



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

def ignore_hidden_elements
  @ignore_hidden_elements
end

.javascript_driverObject



18
19
20
# File 'lib/capybara/dsl.rb', line 18

def javascript_driver
  @javascript_driver || :selenium
end

.run_serverObject

Returns the value of attribute run_server.



18
19
20
# File 'lib/capybara.rb', line 18

def run_server
  @run_server
end

Class Method Details

.current_sessionObject



26
27
28
# File 'lib/capybara/dsl.rb', line 26

def current_session
  session_pool["#{current_driver}#{app.object_id}"] ||= Capybara::Session.new(current_driver, app)
end

.current_session?Boolean

Returns:

  • (Boolean)


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

def current_session?
  session_pool.has_key?("#{current_driver}#{app.object_id}")
end

.log(message) ⇒ Object



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

def log(message)
  puts "[capybara] #{message}" if debug
  true
end

.reset_sessions!Object



34
35
36
37
# File 'lib/capybara/dsl.rb', line 34

def reset_sessions!
  session_pool.each { |mode, session| session.cleanup! }
  @session_pool = nil
end

.use_default_driverObject



22
23
24
# File 'lib/capybara/dsl.rb', line 22

def use_default_driver
  @current_driver = nil
end

Instance Method Details

#pageObject



48
49
50
# File 'lib/capybara/dsl.rb', line 48

def page
  Capybara.current_session
end