Module: QAT::Web::Browser::Loader::Helper

Included in:
QAT::Web::Browser::Loader
Defined in:
lib/qat/web/browser/firefox/loader/helper.rb

Overview

Module with helper methods to load browsers and drivers from configuration files.

Since:

  • 2.0.1

Instance Method Summary collapse

Instance Method Details

#load_generic_driver(browser, controller, screen, driver, properties, addons, hooks) ⇒ Capybara::RackTest::Driver||Capybara::Selenium::Driver

Creates a generic Capybara driver

Parameters:

  • browser (String)

    Expected browser

  • controller (String)

    Expected controller

  • screen (String)

    Expected screen properties

  • driver (String)

    Expected driver

  • properties (String)

    Expected driver properties

  • addons (String)

    Expected driver/browser addons

  • hooks (String)

    Cucumber hooks to use

Returns:

  • (Capybara::RackTest::Driver||Capybara::Selenium::Driver)

Since:

  • 2.0.1



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
# File 'lib/qat/web/browser/firefox/loader/helper.rb', line 16

def load_generic_driver(browser, controller, screen, driver, properties, addons, hooks)
  Capybara.register_driver controller do |app|
    loaded_screen = QAT::Web::Screen::Factory.for screen
    loaded_driver = nil
    Retriable.retriable on:            [Net::ReadTimeout, ::Selenium::WebDriver::Error::WebDriverError],
                        tries:         3,
                        base_interval: 5,
                        multiplier:    1.0,
                        rand_factor:   0.0 do

      options = { browser: browser }
      if properties
        customized_profile = create_profile(driver, browser, properties, addons)
        options.merge!(customized_profile) if customized_profile
      end
      loaded_driver = Capybara.const_get(driver.capitalize)::Driver.new(app, **options)
      loaded_driver.browser
    end

    maximize_browser_window loaded_driver, loaded_screen

    require_hooks(hooks)

    loaded_driver
  end
end