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/version.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.9'

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.



16
17
18
# File 'lib/capybara.rb', line 16

def app_host
  @app_host
end

.asset_rootObject

Returns the value of attribute asset_root.



16
17
18
# File 'lib/capybara.rb', line 16

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.



16
17
18
# File 'lib/capybara.rb', line 16

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_hostObject

Returns the value of attribute default_host.



16
17
18
# File 'lib/capybara.rb', line 16

def default_host
  @default_host
end

.default_selectorObject

Returns the value of attribute default_selector.



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

def default_selector
  @default_selector
end

.default_wait_timeObject

Returns the value of attribute default_wait_time.



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

def default_wait_time
  @default_wait_time
end

.ignore_hidden_elementsObject

Returns the value of attribute ignore_hidden_elements.



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

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.



16
17
18
# File 'lib/capybara.rb', line 16

def run_server
  @run_server
end

.save_and_open_page_pathObject

Returns the value of attribute save_and_open_page_path.



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

def save_and_open_page_path
  @save_and_open_page_path
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



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

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