Class: CapybaraSetup
- Inherits:
-
Object
- Object
- CapybaraSetup
- Defined in:
- lib/frameworks/capybara.rb
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
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.
12 13 14 15 16 17 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/frameworks/capybara.rb', line 12 def initialize http_proxy = ENV['HTTP_PROXY'] || ENV['http_proxy'] browser_cli_args = ENV['BROWSER_CLI_ARGS'].split(/\s+/).compact if ENV['BROWSER_CLI_ARGS'] = {:environment => ENV['ENVIRONMENT'], :http_proxy => http_proxy, :profile => ENV['FIREFOX_PROFILE'], :browser => ENV['BROWSER'], :webdriver_proxy_on => ENV['PROXY_ON'], :url => ENV['REMOTE_URL'], :chrome_switches => ENV['CHROME_SWITCHES'], :firefox_prefs => ENV['FIREFOX_PREFS'], :args => browser_cli_args } selenium_remote_opts = {:os => ENV['PLATFORM'], :os_version => ENV['PLATFORM_VERSION'], :browser_name => ENV['REMOTE_BROWSER'], :browser_version => ENV['REMOTE_BROWSER_VERSION'], :url => ENV['REMOTE_URL'] } custom_opts = {:job_name => ENV['SAUCE_JOB_NAME'], :max_duration => ENV['SAUCE_MAX_DURATION'], :firefox_cert_path => ENV['FIREFOX_CERT_PATH'], :firefox_cert_prefix => ENV['FIREFOX_CERT_PREFIX'], :browserstack_build => ENV['BS_BUILD'], :browserstack_debug => ENV['BS_DEBUG'] || 'true', # BrowserStack debug mode on by default :browserstack_device => ENV['BS_DEVICE'], :browserstack_device_orientation => ENV['BS_DEVICE_ORIENTATION'], :browserstack_project => ENV['BS_PROJECT'], :browserstack_resolution => ENV['BS_RESOLUTION'] } validate_env_vars(.merge(selenium_remote_opts)) #validate environment variables set using cucumber.yml or passed via command line if([:http_proxy]) proxy_uri = URI([:http_proxy]) @proxy_host = proxy_uri.host @proxy_port = proxy_uri.port end [:browser] = [:browser].intern #update :browser value to be a symbol, required for Selenium selenium_remote_opts[:browser_name] = selenium_remote_opts[:browser_name].intern if selenium_remote_opts[:browser_name]#update :browser value to be a symbol, required for Selenium .run_server = false #Disable rack server .ignore_hidden_elements = false [, selenium_remote_opts, custom_opts].each do |opts| #delete nil options and environment (which is only used for validation) opts.delete_if {|k,v| (v.nil? or k == :environment)} end case [:browser] when :mechanize then @driver = register_mechanize_driver() else @driver = register_selenium_driver(, selenium_remote_opts, custom_opts) end .default_driver = @driver end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
10 11 12 |
# File 'lib/frameworks/capybara.rb', line 10 def driver @driver end |