Sha256: 4d07c88c0b6f068239274dee5a21297b5c11f611e316c40b6fa39d3c4313058a

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

module Selenium
  module WebDriver
    module Remote

      # @private
      class Response

        attr_accessor :code
        attr_writer   :payload

        def initialize
          yield self if block_given?
          assert_ok
        end

        def error
          Error.for_code(payload['status'])
        end

        def error_message
          payload['value']['message']
        end

        def [](key)
          payload[key]
        end

        def payload
          @payload ||= {}
        end

        private

        def assert_ok
          if @code.nil? || @code >= 400
            if e = error()
              raise(e, error_message)
            else
              raise Error::ServerError, self
            end
          end
        end

      end # Response
    end # Remote
  end # WebDriver
end # Selenium

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
selenium-webdriver-0.0.20 remote/client/src/rb/lib/selenium/webdriver/remote/response.rb
selenium-webdriver-0.0.19 remote/client/src/rb/lib/selenium/webdriver/remote/response.rb
selenium-webdriver-0.0.18 remote/client/src/rb/lib/selenium/webdriver/remote/response.rb