Sha256: ddf7d36f05c8394b1765616de075baf48ee8e0b5c42b05af6cc9067fdabf5bc8

Contents?: true

Size: 1.72 KB

Versions: 4

Compression:

Stored size: 1.72 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)
          native_events = opts.delete(:native_events)
          verbose       = opts.delete(:verbose)

          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

          caps.merge! 'chrome.binary'       => Chrome.path if Chrome.path
          caps.merge! 'chrome.nativeEvents' => true if native_events
          caps.merge! 'chrome.verbose'      => true if verbose

          @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

4 entries across 4 versions & 1 rubygems

Version Path
selenium-webdriver-2.2.0 lib/selenium/webdriver/chrome/bridge.rb
selenium-webdriver-2.1.0 lib/selenium/webdriver/chrome/bridge.rb
selenium-webdriver-2.0.1 lib/selenium/webdriver/chrome/bridge.rb
selenium-webdriver-2.0.0 lib/selenium/webdriver/chrome/bridge.rb