Sha256: 92e45e685d32d61baa064436d1bef34fba0fa8056013bc6e6558a9939ac200db

Contents?: true

Size: 828 Bytes

Versions: 7

Compression:

Stored size: 828 Bytes

Contents

module Selenium
  module WebDriver
    module Remote

      # @private
      class Response

        attr_reader :code, :payload
        attr_writer :payload

        def initialize(code, payload = nil)
          @code    = code
          @payload = payload || {}

          assert_ok
        end

        def error
          Error.for_code @payload['status']
        end

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

        def [](key)
          @payload[key]
        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

7 entries across 7 versions & 1 rubygems

Version Path
selenium-webdriver-0.0.27 lib/selenium/webdriver/remote/response.rb
selenium-webdriver-0.0.26 lib/selenium/webdriver/remote/response.rb
selenium-webdriver-0.0.25 lib/selenium/webdriver/remote/response.rb
selenium-webdriver-0.0.24 remote/client/src/rb/lib/selenium/webdriver/remote/response.rb
selenium-webdriver-0.0.23 remote/client/src/rb/lib/selenium/webdriver/remote/response.rb
selenium-webdriver-0.0.22 remote/client/src/rb/lib/selenium/webdriver/remote/response.rb
selenium-webdriver-0.0.21 remote/client/src/rb/lib/selenium/webdriver/remote/response.rb