2009-12-20 15:22:47 +00:00
|
|
|
require 'timeout'
|
2009-11-16 21:02:16 +00:00
|
|
|
require 'nokogiri'
|
|
|
|
|
|
|
|
module Capybara
|
|
|
|
class CapybaraError < StandardError; end
|
|
|
|
class DriverNotFoundError < CapybaraError; end
|
|
|
|
class ElementNotFound < CapybaraError; end
|
2010-01-30 00:02:26 +00:00
|
|
|
class OptionNotFound < ElementNotFound; end
|
2010-02-19 20:37:46 +00:00
|
|
|
class UnselectNotAllowed < CapybaraError; end
|
2009-12-12 12:33:00 +00:00
|
|
|
class NotSupportedByDriverError < CapybaraError; end
|
2009-12-31 18:51:22 +00:00
|
|
|
class TimeoutError < CapybaraError; end
|
2010-01-11 13:45:36 +00:00
|
|
|
class LocateHiddenElementError < CapybaraError; end
|
2010-01-11 20:30:58 +00:00
|
|
|
class InfiniteRedirectError < TimeoutError; end
|
2010-06-27 00:36:25 +00:00
|
|
|
|
2009-11-16 21:02:16 +00:00
|
|
|
class << self
|
2010-02-26 17:39:23 +00:00
|
|
|
attr_accessor :debug, :asset_root, :app_host, :run_server, :default_host
|
2010-01-30 18:07:54 +00:00
|
|
|
attr_accessor :default_selector, :default_wait_time, :ignore_hidden_elements
|
2010-06-27 00:36:25 +00:00
|
|
|
attr_accessor :save_and_open_page_path
|
2009-12-03 17:50:03 +00:00
|
|
|
|
|
|
|
def default_selector
|
|
|
|
@default_selector ||= :xpath
|
|
|
|
end
|
2010-06-27 00:36:25 +00:00
|
|
|
|
2009-12-31 18:51:22 +00:00
|
|
|
def default_wait_time
|
|
|
|
@default_wait_time ||= 2
|
|
|
|
end
|
2009-12-12 12:33:00 +00:00
|
|
|
|
2009-11-16 21:02:16 +00:00
|
|
|
def log(message)
|
|
|
|
puts "[capybara] #{message}" if debug
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
2010-06-27 00:36:25 +00:00
|
|
|
|
2009-12-24 05:41:34 +00:00
|
|
|
autoload :Server, 'capybara/server'
|
|
|
|
autoload :Session, 'capybara/session'
|
|
|
|
autoload :XPath, 'capybara/xpath'
|
2010-07-09 23:19:09 +00:00
|
|
|
autoload :Node, 'capybara/node'
|
2010-07-09 23:38:57 +00:00
|
|
|
autoload :Document, 'capybara/document'
|
2010-07-09 23:49:32 +00:00
|
|
|
autoload :Element, 'capybara/element'
|
2010-04-09 15:08:06 +00:00
|
|
|
autoload :VERSION, 'capybara/version'
|
2010-06-27 00:36:25 +00:00
|
|
|
|
2009-11-16 21:02:16 +00:00
|
|
|
module Driver
|
2009-12-09 20:43:40 +00:00
|
|
|
autoload :Base, 'capybara/driver/base'
|
2010-07-09 18:08:33 +00:00
|
|
|
autoload :Node, 'capybara/driver/node'
|
2009-11-16 21:02:16 +00:00
|
|
|
autoload :RackTest, 'capybara/driver/rack_test_driver'
|
2009-12-16 20:42:37 +00:00
|
|
|
autoload :Celerity, 'capybara/driver/celerity_driver'
|
2009-12-18 16:40:51 +00:00
|
|
|
autoload :Culerity, 'capybara/driver/culerity_driver'
|
2009-11-16 21:02:16 +00:00
|
|
|
autoload :Selenium, 'capybara/driver/selenium_driver'
|
|
|
|
end
|
|
|
|
end
|
2010-01-17 16:40:26 +00:00
|
|
|
|
|
|
|
Capybara.run_server = true
|
2010-07-09 18:38:59 +00:00
|
|
|
Capybara.default_selector = :css
|
2010-01-17 16:40:26 +00:00
|
|
|
Capybara.default_wait_time = 2
|
2010-01-30 18:07:54 +00:00
|
|
|
Capybara.ignore_hidden_elements = false
|