Module Selenium::Client::Protocol
In: lib/selenium/client/protocol.rb

Module in charge of handling Selenium over-the-wire HTTP protocol

Methods

Attributes

session_id  [R] 

Public Instance methods

[Source]

    # File lib/selenium/client/protocol.rb, line 59
59:       def boolean_array_command(verb, args)
60:         string_array_command(verb, args).collect {|value| parse_boolean_value(value)}
61:       end

[Source]

    # File lib/selenium/client/protocol.rb, line 55
55:       def boolean_command(verb, args=[])
56:         parse_boolean_value string_command(verb, args)
57:       end

[Source]

    # File lib/selenium/client/protocol.rb, line 51
51:       def number_array_command(verb, args)
52:         string_array_command verb, args
53:       end

[Source]

    # File lib/selenium/client/protocol.rb, line 47
47:       def number_command(verb, args)
48:         string_command verb, args
49:       end

[Source]

    # File lib/selenium/client/protocol.rb, line 10
10:       def remote_control_command(verb, args=[])
11:         timeout(@default_timeout_in_seconds) do
12:           status, response = http_post(http_request_for(verb, args))
13:           raise Selenium::CommandError, response unless status == "OK"          
14:           response
15:         end
16:       end

[Source]

    # File lib/selenium/client/protocol.rb, line 22
22:       def string_array_command(verb, args=[])
23:         csv = string_command(verb, args)
24:         token = ""
25:         tokens = []
26:         escape = false
27:         csv.split(//).each do |letter|
28:           if escape
29:             token += letter
30:             escape = false
31:             next
32:           end
33:           case letter
34:             when '\\'
35:               escape = true
36:             when ','
37:               tokens << token
38:               token = ""
39:             else
40:               token += letter
41:           end
42:         end
43:         tokens << token
44:         return tokens
45:       end

[Source]

    # File lib/selenium/client/protocol.rb, line 18
18:       def string_command(verb, args=[])
19:         remote_control_command(verb, args)
20:       end

Protected Instance methods

[Source]

    # File lib/selenium/client/protocol.rb, line 83
83:       def http_post(data)
84:         # puts "Requesting ---> #{data.inspect}"
85:         http = Net::HTTP.new(@host, @port)
86:         http.open_timeout = default_timeout_in_seconds
87:         http.read_timeout = default_timeout_in_seconds
88:         response = http.post('/selenium-server/driver/', data, HTTP_HEADERS)
89:         # puts "RESULT: #{response.body.inspect}\n"
90:         [ response.body[0..1], response.body[3..-1] ]
91:       end

[Source]

    # File lib/selenium/client/protocol.rb, line 74
74:       def http_request_for(verb, args)
75:         data = "cmd=#{CGI::escape(verb)}"
76:         args.each_with_index do |arg, index|
77:           data << "&#{index.succ}=#{CGI::escape(arg.to_s)}"
78:         end
79:         data << "&sessionId=#{session_id}" unless session_id.nil?
80:         data
81:       end

[Source]

    # File lib/selenium/client/protocol.rb, line 65
65:       def parse_boolean_value(value)
66:         if ("true" == value)
67:             return true
68:         elsif ("false" == value)
69:             return false
70:         end
71:         raise ProtocolError, "Invalid Selenese boolean value that is neither 'true' nor 'false': got '#{value}'"
72:       end

[Validate]