Sha256: 87f68ef545bd23220dd55b6c1f9a13c845c1aa25910822a78c24e7692471a569

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

module Selenium
  module WebDriver
    module Chrome

      # @api private
      class Bridge < Remote::Bridge

        def initialize(opts = {})
          http_client = opts.delete(:http_client)
          switches    = opts.delete(:switches)

          unless opts.empty?
            raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
          end

          caps = Remote::Capabilities.chrome

          if switches
            unless switches.kind_of? Array
              raise ArgumentError, ":switches must be an Array of Strings"
            end

            caps.merge! 'chrome.switches' => switches.map { |e| e.to_s }
          end

          if Chrome.path
            caps.merge! 'chrome.binary' => Chrome.path
          end

          @service = Service.default_service
          @service.start

          remote_opts = {
            :url                  => @service.uri,
            :desired_capabilities => caps
          }

          remote_opts.merge!(:http_client => http_client) if http_client

          super(remote_opts)
        end

        def browser
          :chrome
        end

        def driver_extensions
          [
            DriverExtensions::TakesScreenshot,
            DriverExtensions::HasInputDevices
          ]
        end

        def capabilities
          @capabilities ||= Remote::Capabilities.chrome
        end

        def quit
          super
        ensure
          @service.stop
        end

      end # Bridge
    end # Chrome
  end # WebDriver
end # Selenium

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
selenium-webdriver-0.2.2 lib/selenium/webdriver/chrome/bridge.rb