Class: CapybaraSetup
- Inherits:
-
Object
- Object
- CapybaraSetup
- Defined in:
- lib/frameworks/capybara.rb
Constant Summary collapse
- ERROR_MSG1 =
'Please ensure following environment variables are set ENVIRONMENT [int|test|stage|live], BROWSER[headless|ie|chrome|firefox] and PROXY_URL'
- ERROR_MSG2 =
'Please ensure the following environment variables are set PLATFORM, REMOTE_URL, REMOTE_BROWSER (browser to use on remote machine), PROXY_URL (if required), REMOTE_BROWSER_PROXY (if required) and BROWSER_VERSION (if required)'
Instance Attribute Summary collapse
-
#driver ⇒ Object
Returns the value of attribute driver.
Instance Method Summary collapse
-
#initialize ⇒ CapybaraSetup
constructor
A new instance of CapybaraSetup.
Constructor Details
#initialize ⇒ CapybaraSetup
Returns a new instance of CapybaraSetup.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/frameworks/capybara.rb', line 18 def initialize = {:environment => ENV['ENVIRONMENT'], :proxy => ENV['PROXY_URL'], :remote_browser_proxy_url => ENV['REMOTE_BROWSER_PROXY_URL'], :platform => ENV['PLATFORM'], :browser_name => ENV['REMOTE_BROWSER'], :version => ENV['REMOTE_BROWSER_VERSION'], :url => ENV['REMOTE_URL'], :profile => ENV['FIREFOX_PROFILE'], :browser => ENV['BROWSER'], :javascript_enabled => ENV['CELERITY_JS_ENABLED'], :job_name => ENV['SAUCE_JOB_NAME'], :max_duration => ENV['SAUCE_MAX_DURATION'], :proxy_on => ENV['PROXY_ON']} validate_env_vars() #validate environment variables set using cucumber.yml or passed via command line @proxy_host = [:proxy].gsub(/http:\/\//,'').gsub(/:80/,'') unless [:proxy].nil? [:browser] = [:browser].intern #update :browser value to be a symbol, required for Selenium [:browser_name] = [:browser_name].intern if [:browser_name] Capybara.run_server = false #Disable rack server .delete_if {|k,v| v.nil?} case [:browser] when :headless then @driver = register_celerity_driver() when :mechanize then @driver = register_mechanize_driver() else @driver = register_selenium_driver() end Capybara.default_driver = @driver if [:browser] == :mechanize Capybara.current_session.driver.agent.set_proxy(@proxy_host, 80) if [:proxy] Capybara.current_session.driver.agent.set_ssl_client_certification(ENV['CERT_LOCATION'], ENV['CERT_LOCATION'], ENV['CA_CERT_LOCATION']) if ENV['CERT_LOCATION'] end end |
Instance Attribute Details
#driver ⇒ Object
Returns the value of attribute driver.
16 17 18 |
# File 'lib/frameworks/capybara.rb', line 16 def driver @driver end |