Module | Selenium::Client::Protocol |
In: |
lib/selenium/client/protocol.rb
|
Module in charge of handling Selenium over-the-wire HTTP protocol
session_id | [R] |
# 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
# File lib/selenium/client/protocol.rb, line 55 55: def boolean_command(verb, args=[]) 56: parse_boolean_value string_command(verb, args) 57: end
# File lib/selenium/client/protocol.rb, line 63 63: def default_timeout_in_seconds 64: @timeout 65: end
# File lib/selenium/client/protocol.rb, line 51 51: def number_array_command(verb, args) 52: string_array_command verb, args 53: end
# File lib/selenium/client/protocol.rb, line 47 47: def number_command(verb, args) 48: string_command verb, args 49: end
# 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
# 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
# File lib/selenium/client/protocol.rb, line 18 18: def string_command(verb, args=[]) 19: remote_control_command(verb, args) 20: end
# File lib/selenium/client/protocol.rb, line 87 87: def http_post(data) 88: # puts "Requesting ---> #{data.inspect}" 89: http = Net::HTTP.new(@server_host, @server_port) 90: response = http.post('/selenium-server/driver/', data, HTTP_HEADERS) 91: # puts "RESULT: #{response.inspect}\n" 92: [ response.body[0..1], response.body[3..-1] ] 93: end
# File lib/selenium/client/protocol.rb, line 78 78: def http_request_for(verb, args) 79: data = "cmd=#{CGI::escape(verb)}" 80: args.each_with_index do |arg, index| 81: data << "&#{index.succ}=#{CGI::escape(arg.to_s)}" 82: end 83: data << "&sessionId=#{session_id}" unless session_id.nil? 84: data 85: end