Create Client Cert Session

Create Session: create a HTTP session to a server

Arguments

Argument Type Default value Description
alias
url
headers{}
cookies{}
client_certsNone
timeoutNone
proxiesNone
verifyFalse
debug0
max_retries3
backoff_factor0.1
disable_warnings0
retry_status_list[]
retry_method_list['GET', 'OPTIONS', 'TRACE', 'HEAD', 'PUT', 'DELETE']

url Base url of the server

alias Robot Framework alias to identify the session

headers Dictionary of default headers

cookies Dictionary of cookies

client_certs ['client certificate', 'client key'] PEM files containing the client key and certificate

timeout Connection timeout

proxies Dictionary that contains proxy urls for HTTP and HTTPS communication

verify Whether the SSL cert will be verified. A CA_BUNDLE path can also be provided. Defaults to False.

debug Enable http verbosity option more information https://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel

max_retries Number of maximum retries each connection should attempt. By default it will retry 3 times in case of connection errors only. A 0 value will disable any kind of retries regardless of other retry settings. In case the number of retries is reached a retry exception is raised.

disable_warnings Disable requests warning useful when you have large number of testcases

backoff_factor Introduces a delay time between retries that is longer after each retry. eg. if backoff_factor is set to 0.1 the sleep between attemps will be: 0.0, 0.2, 0.4 More info here: https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html

retry_method_list List of uppercased HTTP method verbs where retries are allowed. By default retries are allowed only on HTTP requests methods that are considered to be idempotent (multiple requests with the same parameters end with the same state). eg. set to ['POST', 'GET'] to retry only those kind of requests.

retry_status_list List of integer HTTP status codes that, if returned, a retry is attempted. eg. set to [502, 503] to retry requests if those status are returned. Note that max_retries must be greater than 0.

Create Custom Session

Create Session: create a HTTP session to a server

Arguments

Argument Type Default value Description
alias
url
auth
headers{}
cookies{}
timeoutNone
proxiesNone
verifyFalse
debug0
max_retries3
backoff_factor0.1
disable_warnings0
retry_status_list[]
retry_method_list['GET', 'OPTIONS', 'TRACE', 'HEAD', 'PUT', 'DELETE']

url Base url of the server

alias Robot Framework alias to identify the session

headers Dictionary of default headers

cookies Dictionary of cookies

auth A Custom Authentication object to be passed on to the requests library. http://docs.python-requests.org/en/master/user/advanced/#custom-authentication

timeout Connection timeout

proxies Dictionary that contains proxy urls for HTTP and HTTPS communication

verify Whether the SSL cert will be verified. A CA_BUNDLE path can also be provided. Defaults to False.

debug Enable http verbosity option more information https://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel

max_retries Number of maximum retries each connection should attempt. By default it will retry 3 times in case of connection errors only. A 0 value will disable any kind of retries regardless of other retry settings. In case the number of retries is reached a retry exception is raised.

disable_warnings Disable requests warning useful when you have large number of testcases

backoff_factor Introduces a delay time between retries that is longer after each retry. eg. if backoff_factor is set to 0.1 the sleep between attemps will be: 0.0, 0.2, 0.4 More info here: https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html

retry_method_list List of uppercased HTTP method verbs where retries are allowed. By default retries are allowed only on HTTP requests methods that are considered to be idempotent (multiple requests with the same parameters end with the same state). eg. set to ['POST', 'GET'] to retry only those kind of requests.

retry_status_list List of integer HTTP status codes that, if returned, a retry is attempted. eg. set to [502, 503] to retry requests if those status are returned. Note that max_retries must be greater than 0.

Create Digest Session

Create Session: create a HTTP session to a server

Arguments

Argument Type Default value Description
alias
url
auth
headers{}
cookies{}
timeoutNone
proxiesNone
verifyFalse
debug0
max_retries3
backoff_factor0.1
disable_warnings0
retry_status_list[]
retry_method_list['GET', 'OPTIONS', 'TRACE', 'HEAD', 'PUT', 'DELETE']

url Base url of the server

alias Robot Framework alias to identify the session

headers Dictionary of default headers

cookies Dictionary of cookies

auth ['DOMAIN', 'username', 'password'] for NTLM Authentication

timeout Connection timeout

proxies Dictionary that contains proxy urls for HTTP and HTTPS communication

verify Whether the SSL cert will be verified. A CA_BUNDLE path can also be provided. Defaults to False.

debug Enable http verbosity option more information https://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel

max_retries Number of maximum retries each connection should attempt. By default it will retry 3 times in case of connection errors only. A 0 value will disable any kind of retries regardless of other retry settings. In case the number of retries is reached a retry exception is raised.

disable_warnings Disable requests warning useful when you have large number of testcases

backoff_factor Introduces a delay time between retries that is longer after each retry. eg. if backoff_factor is set to 0.1 the sleep between attemps will be: 0.0, 0.2, 0.4 More info here: https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html

retry_method_list List of uppercased HTTP method verbs where retries are allowed. By default retries are allowed only on HTTP requests methods that are considered to be idempotent (multiple requests with the same parameters end with the same state). eg. set to ['POST', 'GET'] to retry only those kind of requests.

retry_status_list List of integer HTTP status codes that, if returned, a retry is attempted. eg. set to [502, 503] to retry requests if those status are returned. Note that max_retries must be greater than 0.

Create Ntlm Session

Create Session: create a HTTP session to a server

Arguments

Argument Type Default value Description
alias
url
auth
headers{}
cookies{}
timeoutNone
proxiesNone
verifyFalse
debug0
max_retries3
backoff_factor0.1
disable_warnings0
retry_status_list[]
retry_method_list['GET', 'OPTIONS', 'TRACE', 'HEAD', 'PUT', 'DELETE']

url Base url of the server

alias Robot Framework alias to identify the session

headers Dictionary of default headers

cookies Dictionary of cookies

auth ['DOMAIN', 'username', 'password'] for NTLM Authentication

timeout Connection timeout

proxies Dictionary that contains proxy urls for HTTP and HTTPS communication

verify Whether the SSL cert will be verified. A CA_BUNDLE path can also be provided. Defaults to False.

debug Enable http verbosity option more information https://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel

max_retries Number of maximum retries each connection should attempt. By default it will retry 3 times in case of connection errors only. A 0 value will disable any kind of retries regardless of other retry settings. In case the number of retries is reached a retry exception is raised.

disable_warnings Disable requests warning useful when you have large number of testcases

backoff_factor Introduces a delay time between retries that is longer after each retry. eg. if backoff_factor is set to 0.1 the sleep between attemps will be: 0.0, 0.2, 0.4 More info here: https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html

retry_method_list List of uppercased HTTP method verbs where retries are allowed. By default retries are allowed only on HTTP requests methods that are considered to be idempotent (multiple requests with the same parameters end with the same state). eg. set to ['POST', 'GET'] to retry only those kind of requests.

retry_status_list List of integer HTTP status codes that, if returned, a retry is attempted. eg. set to [502, 503] to retry requests if those status are returned. Note that max_retries must be greater than 0.

Create Session

Create Session: create a HTTP session to a server

Arguments

Argument Type Default value Description
alias
url
headers{}
cookies{}
authNone
timeoutNone
proxiesNone
verifyFalse
debug0
max_retries3
backoff_factor0.1
disable_warnings0
retry_status_list[]
retry_method_list['GET', 'OPTIONS', 'TRACE', 'HEAD', 'PUT', 'DELETE']

alias Robot Framework alias to identify the session

url Base url of the server

headers Dictionary of default headers

cookies Dictionary of cookies

auth List of username & password for HTTP Basic Auth

timeout Connection timeout

proxies Dictionary that contains proxy urls for HTTP and HTTPS communication

verify Whether the SSL cert will be verified. A CA_BUNDLE path can also be provided.

debug Enable http verbosity option more information https://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel

max_retries Number of maximum retries each connection should attempt. By default it will retry 3 times in case of connection errors only. A 0 value will disable any kind of retries regardless of other retry settings. In case the number of retries is reached a retry exception is raised.

disable_warnings Disable requests warning useful when you have large number of testcases

backoff_factor Introduces a delay time between retries that is longer after each retry. eg. if backoff_factor is set to 0.1 the sleep between attemps will be: 0.0, 0.2, 0.4 More info here: https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html

retry_method_list List of uppercased HTTP method verbs where retries are allowed. By default retries are allowed only on HTTP requests methods that are considered to be idempotent (multiple requests with the same parameters end with the same state). eg. set to ['POST', 'GET'] to retry only those kind of requests.

retry_status_list List of integer HTTP status codes that, if returned, a retry is attempted. eg. set to [502, 503] to retry requests if those status are returned. Note that max_retries must be greater than 0.

Delete All Sessions

Removes all the session objects

Delete Request

Send a DELETE request on the session object found using the given alias

Arguments

Argument Type Default value Description
alias
uri
dataNone
jsonNone
paramsNone
headersNone
allow_redirectsNone
timeoutNone

alias that will be used to identify the Session object in the cache

uri to send the DELETE request to

json a value that will be json encoded and sent as request data if data is not specified

headers a dictionary of headers to use with the request

allow_redirects Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.

timeout connection timeout

Download

An alias for the HTTP Get keyword.

Arguments

Argument Type Default value Description
url str
target_file str None
binary bool True
verify bool True
force_new_session bool False
overwrite bool False

The difference in use is that the URL is always downloaded based on the URL path (even without target_file). If there is a filename in the path, then that is used as target_file to save to. By default, the filename will be "downloaded.html".

url target URL for GET request

target_file filepath to save request content, default None

binary if file is saved as binary, default True

verify if SSL verification should be done, default True

force_new_session if new HTTP session should be created, default False

overwrite used together with target_file, if True will overwrite the target file, default False

Get Current Session Alias

Get request session alias that was used with the HTTP Get keyword.

Return name of session alias.

Get Request

Send a GET request on the session object found using the given alias

Arguments

Argument Type Default value Description
alias
uri
headersNone
dataNone
jsonNone
paramsNone
allow_redirectsNone
timeoutNone

alias that will be used to identify the Session object in the cache

uri to send the GET request to

params url parameters to append to the uri

headers a dictionary of headers to use with the request

data a dictionary of key-value pairs that will be urlencoded and sent as GET data or binary data that is sent as the raw body content

json a value that will be json encoded and sent as GET data if data is not specified

allow_redirects Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.

timeout connection timeout

Head Request

Send a HEAD request on the session object found using the given alias

Arguments

Argument Type Default value Description
alias
uri
headersNone
allow_redirectsNone
timeoutNone

alias that will be used to identify the Session object in the cache

uri to send the HEAD request to

allow_redirects Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.

headers a dictionary of headers to use with the request

timeout connection timeout

Http Get

A helper method for Get Request that will create a session, perform GET request, and store the target file, if set by the target_file parameter.

Arguments

Argument Type Default value Description
url str
target_file str None
binary bool True
verify bool True
force_new_session bool False
overwrite bool False

The old session will be used if the URL scheme and the host are the same as previously, e.g., 'https://www.google.fi' part of the URL.

url target URL for GET request

target_file filepath to save request content, default None

binary if file is saved as binary, default True

verify if SSL verification should be done, default True

force_new_session if new HTTP session should be created, default False

overwrite used together with target_file, if True will overwrite the target file, default False

Returns request response.

Options Request

Send an OPTIONS request on the session object found using the given alias

Arguments

Argument Type Default value Description
alias
uri
headersNone
allow_redirectsNone
timeoutNone

alias that will be used to identify the Session object in the cache

uri to send the OPTIONS request to

allow_redirects Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.

headers a dictionary of headers to use with the request

timeout connection timeout

Patch Request

Send a PATCH request on the session object found using the given alias

Arguments

Argument Type Default value Description
alias
uri
dataNone
jsonNone
paramsNone
headersNone
filesNone
allow_redirectsNone
timeoutNone

alias that will be used to identify the Session object in the cache

uri to send the PATCH request to

data a dictionary of key-value pairs that will be urlencoded and sent as PATCH data or binary data that is sent as the raw body content

json a value that will be json encoded and sent as PATCH data if data is not specified

headers a dictionary of headers to use with the request

files a dictionary of file names containing file data to PATCH to the server

allow_redirects Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.

params url parameters to append to the uri

timeout connection timeout

Post Request

Send a POST request on the session object found using the given alias

Arguments

Argument Type Default value Description
alias
uri
dataNone
jsonNone
paramsNone
headersNone
filesNone
allow_redirectsNone
timeoutNone

alias that will be used to identify the Session object in the cache

uri to send the POST request to

data a dictionary of key-value pairs that will be urlencoded and sent as POST data or binary data that is sent as the raw body content or passed as such for multipart form data if files is also defined

json a value that will be json encoded and sent as POST data if files or data is not specified

params url parameters to append to the uri

headers a dictionary of headers to use with the request

files a dictionary of file names containing file data to POST to the server

allow_redirects Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.

timeout connection timeout

Put Request

Send a PUT request on the session object found using the given alias

Arguments

Argument Type Default value Description
alias
uri
dataNone
jsonNone
paramsNone
filesNone
headersNone
allow_redirectsNone
timeoutNone

alias that will be used to identify the Session object in the cache

uri to send the PUT request to

data a dictionary of key-value pairs that will be urlencoded and sent as PUT data or binary data that is sent as the raw body content

json a value that will be json encoded and sent as PUT data if data is not specified

headers a dictionary of headers to use with the request

allow_redirects Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.

params url parameters to append to the uri

timeout connection timeout

Request Should Be Successful

Fails if response status code is a client or server error (4xx, 5xx).

Arguments

Argument Type Default value Description
response

The response is the output of other requests keywords like Get Request.

In case of failure an HTTPError will be automatically raised.

Session Exists

Return True if the session has been already created

Arguments

Argument Type Default value Description
alias

alias that has been used to identify the Session object in the cache

Status Should Be

Fails if response status code is different than the expected.

Arguments

Argument Type Default value Description
expected_status
response
msgNone

expected_status could be the code number as an integer or as string. But it could also be a named status code like 'ok', 'created', 'accepted' or 'bad request', 'not found' etc.

The response is the output of other requests keywords like Get Request.

A custom message msg can be added to work like built in keywords.

To Json

Convert a string to a JSON object

Arguments

Argument Type Default value Description
content
pretty_printFalse

content String content to convert into JSON

pretty_print If defined, will output JSON is pretty print format

Update Session

Update Session Headers: update a HTTP Session Headers

Arguments

Argument Type Default value Description
alias
headersNone
cookiesNone

alias Robot Framework alias to identify the session

headers Dictionary of headers merge into session