Sha256: 93847e48b87a1d283e154645cd6fccb149212dd7713b3130fbcb5171de1ffd21

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

<% if automation == 'selenium' -%>
  def create_driver(*opts)
    @config = YAML.load_file('config/config.yml')
    browser = @config['browser'].to_sym
    Selenium::WebDriver.for(browser, options: create_webdriver_options(*opts))
  end

  def browser_arguments(*opts)
    opts.empty? ? @config['browser_arguments'][@config['browser']] : opts
  end

  def driver_options
    @config['driver_options']
  end

  # :reek:FeatureEnvy
  def create_webdriver_options(*opts)
    load_browser = @config['browser'].to_s
    browser = load_browser == 'ie' ? load_browser.upcase : load_browser.capitalize
    options = "Selenium::WebDriver::#{browser}::Options".constantize.new
    browser_arguments(*opts).each { |arg| options.add_argument(arg) }
    driver_options.each { |opt| options.add_option(opt.first, opt.last) }
    options
  end

<% elsif automation == 'cross_platform' -%>
  def create_driver
    platform = config['platform'].to_s
    @driver = Appium::Driver.new({ caps: caps[platform] })
  end

  def config
     YAML.load_file('config/config.yml')
  end
<% else -%>
  def create_driver
    @driver = Appium::Driver.new({ caps: caps })
  end
<% end -%>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_raider-0.8.6 lib/generators/templates/helpers/partials/driver_and_options.tt
ruby_raider-0.8.5 lib/generators/templates/helpers/partials/driver_and_options.tt
ruby_raider-0.8.3 lib/generators/templates/helpers/partials/driver_and_options.tt