Sha256: 72ff32daaafb20712743a5d72a9c248e257e10c5b120dc90380aaa50abb71622

Contents?: true

Size: 1.11 KB

Versions: 46

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'active_support/core_ext/hash/indifferent_access'
require 'aranha/selenium/driver_factory/base'
require 'aranha/selenium/driver_factory/chrome'
require 'aranha/selenium/driver_factory/firefox'

module Aranha
  module Selenium
    class DriverFactory
      class << self
        def create_driver(options = {})
          new(options).create_driver
        end
      end

      attr_reader :options

      def initialize(options)
        @options = options.with_indifferent_access.freeze
      end

      def create_driver
        driver_class.new(driver_options).build
      end

      def driver_name
        (options[:driver] || default_driver_name).to_s
      end

      def driver_class
        Aranha::Selenium::DriverFactory.const_get(driver_name.classify)
      rescue NameError
        raise "Unknown Aranha Selenium driver: \"#{driver_name}\"" \
          " (Class \"Aranha::Selenium::DriverFactory::#{driver_name.classify}\" not found)"
      end

      def default_driver_name
        :firefox
      end

      def driver_options
        options.except(:driver)
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 3 rubygems

Version Path
aranha-selenium-0.6.0 lib/aranha/selenium/driver_factory.rb
aranha-selenium-0.5.0 lib/aranha/selenium/driver_factory.rb
aranha-selenium-0.4.2 lib/aranha/selenium/driver_factory.rb
aranha-selenium-0.4.1 lib/aranha/selenium/driver_factory.rb
aranha-selenium-0.4.0 lib/aranha/selenium/driver_factory.rb
aranha-selenium-0.3.0 lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.28.3 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.28.2 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.28.1 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.28.0 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.27.0 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.26.0 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.25.1 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.25.0 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.24.0 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
aranha-selenium-0.2.2 lib/aranha/selenium/driver_factory.rb
aranha-selenium-0.2.1 lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.23.1 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.23.0 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb
ehbrs-tools-0.22.0 vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb