Class: Selenium::WebDriver::Remote::Response Private

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/remote/response.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, payload = nil) ⇒ Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Response


28
29
30
31
32
33
# File 'lib/selenium/webdriver/remote/response.rb', line 28

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

  assert_ok
end

Instance Attribute Details

#codeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


25
26
27
# File 'lib/selenium/webdriver/remote/response.rb', line 25

def code
  @code
end

#payloadObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


25
26
27
# File 'lib/selenium/webdriver/remote/response.rb', line 25

def payload
  @payload
end

Instance Method Details

#[](key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


62
63
64
# File 'lib/selenium/webdriver/remote/response.rb', line 62

def [](key)
  @payload[key]
end

#errorObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


35
36
37
38
39
40
41
42
43
# File 'lib/selenium/webdriver/remote/response.rb', line 35

def error
  klass = Error.for_code(status) || return

  ex = klass.new(error_message)
  ex.set_backtrace(caller)
  add_backtrace ex

  ex
end

#error_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/selenium/webdriver/remote/response.rb', line 45

def error_message
  val = value

  case val
  when Hash
    msg = val['message']
    return 'unknown error' unless msg
    msg << ": #{val['alert']['text'].inspect}" if val['alert'].is_a?(Hash) && val['alert']['text']
    msg << " (#{val['class']})" if val['class']
    msg
  when String
    val
  else
    "unknown error, status=#{status}: #{val.inspect}"
  end
end