webdriver.remote.remote_connection

Module Contents

Classes

Request(self,url,data=None,method=None) Extends the url_request.Request to support all HTTP request types.
Response(self,fp,code,headers,url) Represents an HTTP response.
HttpErrorHandler() A custom HTTP error handler.
RemoteConnection(self,remote_server_addr,keep_alive=False,resolve_ip=True) A connection with the Remote WebDriver server.
class Request(url, data=None, method=None)

Extends the url_request.Request to support all HTTP request types.

__init__(url, data=None, method=None)

Initialise a new HTTP request.

Args:
  • url - String for the URL to send the request to.
  • data - Data to send with the request.
get_method()

Returns the HTTP method used by this request.

class Response(fp, code, headers, url)

Represents an HTTP response.

__init__(fp, code, headers, url)

Initialise a new Response.

Args:
  • fp - The response body file object.
  • code - The HTTP status code returned by the server.
  • headers - A dictionary of headers returned by the server.
  • url - URL of the retrieved resource represented by this Response.
close()

Close the response body file object.

info()

Returns the response headers.

geturl()

Returns the URL for the resource returned in this response.

class HttpErrorHandler

A custom HTTP error handler.

Used to return Response objects instead of raising an HTTPError exception.

http_error_default(req, fp, code, msg, headers)

Default HTTP error handler.

Args:
  • req - The original Request object.
  • fp - The response body file object.
  • code - The HTTP status code returned by the server.
  • msg - The HTTP status message returned by the server.
  • headers - The response headers.
Returns:

A new Response object.

class RemoteConnection(remote_server_addr, keep_alive=False, resolve_ip=True)

A connection with the Remote WebDriver server.

Communicates with the server using the WebDriver wire protocol: https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol

get_timeout()
Returns:

Timeout value in seconds for all http requests made to the Remote Connection

set_timeout(timeout)

Override the default timeout

Args:
  • timeout - timeout value for http requests in seconds
reset_timeout()

Reset the http request timeout to socket._GLOBAL_DEFAULT_TIMEOUT

get_remote_connection_headers(parsed_url, keep_alive=False)

Get headers for remote request.

Args:
  • parsed_url - The parsed url
  • keep_alive (Boolean) - Is this a keep-alive connection (default: False)
__init__(remote_server_addr, keep_alive=False, resolve_ip=True)
execute(command, params)

Send a command to the remote server.

Any path subtitutions required for the URL mapped to the command should be included in the command parameters.

Args:
  • command - A string specifying the command to execute.
  • params - A dictionary of named parameters to send with the command as its JSON payload.
_request(method, url, body=None)

Send an HTTP request to the remote server.

Args:
  • method - A string for the HTTP method to send the request with.
  • url - A string for the URL to send the request to.
  • body - A string for request body. Ignored unless method is POST or PUT.
Returns:

A dictionary with the server’s parsed JSON response.