Module: TestCentricity::WebDriverConnect

Includes:
Capybara::DSL
Defined in:
lib/testcentricity_web/webdriver_helper.rb

Class Method Summary collapse

Class Method Details

.initialize_web_driver(app_host = nil) ⇒ Object



8
9
10
11
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
# File 'lib/testcentricity_web/webdriver_helper.rb', line 8

def self.initialize_web_driver(app_host = nil)
  browser = ENV['WEB_BROWSER']

  # assume that we're testing within a local desktop web browser
  Environ.set_platform(:desktop)
  Environ.set_browser(browser)
  Environ.set_device(false)
  Environ.set_device_type('browser')

  case browser.downcase.to_sym
    when :browserstack
      initialize_browserstack
    when :crossbrowser
      initialize_crossbrowser
    when :poltergeist
      initialize_poltergeist
    when :saucelabs
      initialize_saucelabs
    when :testingbot
      initialize_testingbot
    else
      initialize_local_browser(browser)
  end

  Capybara.app_host = app_host unless app_host.nil?

  # set browser window size only if testing with a desktop web browser
  unless Capybara.current_driver == :poltergeist
    if Environ.is_desktop?
      (ENV['BROWSER_SIZE'] == 'max') ?
          Browsers.maximize_browser :
          Browsers.set_browser_window_size(Browsers.browser_size(browser, ENV['ORIENTATION']))
    end
  end

  puts "Using #{Environ.browser.to_s} browser"
end