Python API
HTTP
- class RPA.HTTP.HTTP(*args, **kwargs)
The RPA.HTTP library extends functionality of the RequestsLibrary. See that documentation for several examples of how to issue
GETrequests and utilize the returnedresultobjects.This extension provides helper keywords to get an HTTP resource on a session. The
HTTP GetandDownloadkeywords will initiate a session if one does not exist for the provided URL, or use an existing session. When using these keywords, you do not need to manage sessions withCreate Session. Session management is still required if you use the underlying session keywords, e.g.,* On Session.- DEFAULT_RETRY_METHOD_LIST = ['HEAD', 'TRACE', 'OPTIONS', 'PUT', 'DELETE', 'GET']
- ROBOT_LIBRARY_DOC_FORMAT = 'reST'
- ROBOT_LIBRARY_SCOPE = 'GLOBAL'
- check_vulnerabilities() List
Check for possible vulnerabilities in the installed runtime environment packages.
Currently will check only for OpenSSL version and outputs warning message on any discovered vulnerability.
- Returns:
list of all check results
*** Tasks *** Vulnerability Check ${results}= Check Vulnerabilities FOR ${result} IN @{results} Log To Console TYPE: ${result}[type] Log To Console VULNERABLE: ${result}[vulnerable] Log To Console MESSAGE: ${result}[message] END
- create_client_cert_session(alias, url, headers={}, cookies={}, client_certs=None, timeout=None, proxies=None, verify=False, debug=0, max_retries=3, backoff_factor=0.1, disable_warnings=0, retry_status_list=[], retry_method_list=['HEAD', 'TRACE', 'OPTIONS', 'PUT', 'DELETE', 'GET'])
Create Session: create a HTTP session to a server
urlBase url of the serveraliasRobot Framework alias to identify the sessionheadersDictionary of default headerscookiesDictionary of cookiesclient_certs[‘client certificate’, ‘client key’] PEM files containing the client key and certificatetimeoutConnection timeoutproxiesDictionary mapping protocol or protocol and host to the URL of the proxy(e.g. {‘http’: ‘foo.bar:3128’, ‘http://host.name’: ‘foo.bar:4012’})
verifyWhether the SSL cert will be verified. A CA_BUNDLE path can also be provided.Defaults to False.
debugEnable http verbosity option more informationhttps://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel
max_retriesNumber 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_warningsDisable requests warning useful when you have large number of testcasesbackoff_factorIntroduces 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_listList 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_listList 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(alias, url, auth, headers={}, cookies={}, timeout=None, proxies=None, verify=False, debug=0, max_retries=3, backoff_factor=0.1, disable_warnings=0, retry_status_list=[], retry_method_list=['HEAD', 'TRACE', 'OPTIONS', 'PUT', 'DELETE', 'GET'])
Create Session: create a HTTP session to a server
urlBase url of the serveraliasRobot Framework alias to identify the sessionheadersDictionary of default headerscookiesDictionary of cookiesauthA Custom Authentication object to be passed on to the requests library.http://docs.python-requests.org/en/master/user/advanced/#custom-authentication
timeoutConnection timeoutproxiesDictionary mapping protocol or protocol and host to the URL of the proxy(e.g. {‘http’: ‘foo.bar:3128’, ‘http://host.name’: ‘foo.bar:4012’})
verifyWhether the SSL cert will be verified. A CA_BUNDLE path can also be provided.Defaults to False.
debugEnable http verbosity option more informationhttps://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel
max_retriesNumber 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_warningsDisable requests warning useful when you have large number of testcasesbackoff_factorIntroduces 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_listList 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_listList 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(alias, url, auth, headers={}, cookies={}, timeout=None, proxies=None, verify=False, debug=0, max_retries=3, backoff_factor=0.1, disable_warnings=0, retry_status_list=[], retry_method_list=['HEAD', 'TRACE', 'OPTIONS', 'PUT', 'DELETE', 'GET'])
Create Session: create a HTTP session to a server
urlBase url of the serveraliasRobot Framework alias to identify the sessionheadersDictionary of default headerscookiesDictionary of cookiesauth[‘DOMAIN’, ‘username’, ‘password’] for NTLM AuthenticationtimeoutConnection timeoutproxiesDictionary mapping protocol or protocol and host to the URL of the proxy(e.g. {‘http’: ‘foo.bar:3128’, ‘http://host.name’: ‘foo.bar:4012’})
verifyWhether the SSL cert will be verified. A CA_BUNDLE path can also be provided.Defaults to False.
debugEnable http verbosity option more informationhttps://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel
max_retriesNumber 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_warningsDisable requests warning useful when you have large number of testcasesbackoff_factorIntroduces 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_listList 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_listList 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(alias, url, auth, headers={}, cookies={}, timeout=None, proxies=None, verify=False, debug=0, max_retries=3, backoff_factor=0.1, disable_warnings=0, retry_status_list=[], retry_method_list=['HEAD', 'TRACE', 'OPTIONS', 'PUT', 'DELETE', 'GET'])
Create Session: create a HTTP session to a server
urlBase url of the serveraliasRobot Framework alias to identify the sessionheadersDictionary of default headerscookiesDictionary of cookiesauth[‘DOMAIN’, ‘username’, ‘password’] for NTLM AuthenticationtimeoutConnection timeoutproxiesDictionary mapping protocol or protocol and host to the URL of the proxy(e.g. {‘http’: ‘foo.bar:3128’, ‘http://host.name’: ‘foo.bar:4012’})
verifyWhether the SSL cert will be verified. A CA_BUNDLE path can also be provided.Defaults to False.
debugEnable http verbosity option more informationhttps://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel
max_retriesNumber 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_warningsDisable requests warning useful when you have large number of testcasesbackoff_factorIntroduces 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_listList 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_listList 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(alias, url, headers={}, cookies={}, auth=None, timeout=None, proxies=None, verify=False, debug=0, max_retries=3, backoff_factor=0.1, disable_warnings=0, retry_status_list=[], retry_method_list=['HEAD', 'TRACE', 'OPTIONS', 'PUT', 'DELETE', 'GET'])
Create Session: create a HTTP session to a server
aliasRobot Framework alias to identify the sessionurlBase url of the serverheadersDictionary of default headerscookiesDictionary of cookiesauthList of username & password for HTTP Basic AuthtimeoutConnection timeoutproxiesDictionary mapping protocol or protocol and host to the URL of the proxy(e.g. {‘http’: ‘foo.bar:3128’, ‘http://host.name’: ‘foo.bar:4012’})
verifyWhether the SSL cert will be verified. A CA_BUNDLE path can also be provided.debugEnable http verbosity option more informationhttps://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel
max_retriesNumber 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_warningsDisable requests warning useful when you have large number of testcasesbackoff_factorIntroduces 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_listList 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_listList 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_on_session(**kwargs)
Sends a DELETE request on a previously created HTTP Session.
Session will be identified using the
aliasname. The endpoint used to send the request is theurlparameter.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- delete_request(alias, uri, data=None, json=None, params=None, headers=None, allow_redirects=None, timeout=None)
DEPRECATED Please use DELETE On Session instead.
Send a DELETE request on the session object found using the given alias
aliasthat will be used to identify the Session object in the cacheurito send the DELETE request tojsona value that will be json encodedand sent as request data if data is not specified
headersa dictionary of headers to use with the requestallow_redirectsBoolean. Set to True if POST/PUT/DELETE redirect following is allowed.timeoutconnection timeout
- download(url: str, target_file: str | None = None, verify: bool | str = True, force_new_session: bool = False, overwrite: bool = False, stream: bool = False, **kwargs) dict
An alias for the
HTTP Getkeyword.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 astarget_fileto save to. By default, the filename will be “downloaded.html”.*** Settings *** Library RPA.HTTP *** Variables *** ${DOWNLOAD_PATH}= ${OUTPUT DIR}${/}downloads ${WORD_EXAMPLE}= https://file-examples.com/wp-content/uploads/2017/02/file-sample_100kB.doc ${EXCEL_EXAMPLE}= https://file-examples.com/wp-content/uploads/2017/02/file_example_XLS_10.xls *** Tasks *** Download files with reused session with provided file names # Starts a new session Download ${WORD_EXAMPLE} target_file=${DOWNLOAD_PATH} # Uses the previous session Download ${EXCEL_EXAMPLE} target_file=${DOWNLOAD_PATH} # Above files are downloaded using the same names as they have # on the remote server.
- Parameters:
url – target URL for GET request
target_file – filepath to save request content, default
Noneverify – if SSL verification should be done, default
True, a CA_BUNDLE path can also be providedforce_new_session – if new HTTP session should be created, default
Falseoverwrite – used together with
target_file, ifTruewill overwrite the target file, defaultFalsestream – if
Falsethe response content will be immediately downloaded
- Returns:
request response as a dict
- get_current_session_alias() str
Get request session alias that was used with the
HTTP Getkeyword.- Returns:
name of session alias as a string
- static get_file_for_streaming_upload(path)
Opens and returns a file descriptor of a specified file to be passed as
dataparameter to other requests keywords.This allows streaming upload of large files without reading them into memory.
File descriptor is binary mode and read only. Requests keywords will automatically close the file, if used outside this library it’s up to the caller to close it.
- get_on_session(**kwargs)
Sends a GET request on a previously created HTTP Session.
Session will be identified using the
aliasname. The endpoint used to retrieve the resource is theurl, while query string parameters can be passed as string, dictionary (or list of tuples or bytes) through theparams.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- get_request(alias, uri, headers=None, data=None, json=None, params=None, allow_redirects=None, timeout=None)
DEPRECATED Please use GET On Session instead.
Send a GET request on the session object found using the given alias
aliasthat will be used to identify the Session object in the cacheurito send the GET request toparamsurl parameters to append to the uriheadersa dictionary of headers to use with the requestdataa dictionary of key-value pairs that will be urlencodedand sent as GET data or binary data that is sent as the raw body content
jsona value that will be json encodedand sent as GET data if data is not specified
allow_redirectsBoolean. Set to True if POST/PUT/DELETE redirect following is allowed.timeoutconnection timeout
- head_on_session(**kwargs)
Sends a HEAD request on a previously created HTTP Session.
Session will be identified using the
aliasname. The endpoint used to retrieve the HTTP headers is theurl.allow_redirectsparameter is not provided, it will be set to False (as opposed to the default behavior).By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- head_request(alias, uri, headers=None, allow_redirects=None, timeout=None)
DEPRECATED Please use HEAD On Session instead.
Send a HEAD request on the session object found using the given alias
aliasthat will be used to identify the Session object in the cacheurito send the HEAD request toallow_redirectsBoolean. Set to True if POST/PUT/DELETE redirect following is allowed.headersa dictionary of headers to use with the requesttimeoutconnection timeout
- http_get(url: str, target_file: str | None = None, verify: bool | str = True, force_new_session: bool = False, overwrite: bool = False, stream: bool = False, **kwargs) dict
A helper method for
Get Requestthat will create a session, perform GET request, and store the target file, if set by thetarget_fileparameter.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.
*** Settings *** Library RPA.HTTP *** Variables *** ${DOWNLOAD_PATH}= ${OUTPUT DIR}${/}downloads ${WORD_EXAMPLE}= https://file-examples.com/wp-content/uploads/2017/02/file-sample_100kB.doc ${EXCEL_EXAMPLE}= https://file-examples.com/wp-content/uploads/2017/02/file_example_XLS_10.xls *** Tasks *** Download files with reused session # Starts a new session HTTP Get ${WORD_EXAMPLE} target_file=${DOWNLOAD_PATH}${/}word-example.doc # Uses the previous session HTTP Get ${EXCEL_EXAMPLE} target_file=${DOWNLOAD_PATH}${/}excel-example.xls
- Parameters:
url – target URL for GET request
target_file – filepath to save request content, default
Noneverify – if SSL verification should be done, default
True, a CA_BUNDLE path can also be providedforce_new_session – if new HTTP session should be created, default
Falseoverwrite – used together with
target_file, ifTruewill overwrite the target file, defaultFalsestream – if
False, the response content will be immediately downloaded
- Returns:
request response as a dict
- options_on_session(**kwargs)
Sends a OPTIONS request on a previously created HTTP Session.
Session will be identified using the
aliasname. The endpoint used to retrieve the resource is theurl.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- options_request(alias, uri, headers=None, allow_redirects=None, timeout=None)
DEPRECATED Please use OPTIONS On Session instead.
Send an OPTIONS request on the session object found using the given alias
aliasthat will be used to identify the Session object in the cacheurito send the OPTIONS request toallow_redirectsBoolean. Set to True if POST/PUT/DELETE redirect following is allowed.headersa dictionary of headers to use with the requesttimeoutconnection timeout
- patch_on_session(**kwargs)
Sends a PATCH request on a previously created HTTP Session.
Session will be identified using the
aliasname. The endpoint used to send the request is theurlparameter, while its body can be passed usingdataorjsonparameters.datacan be a dictionary, list of tuples, bytes, or file-like object. If you want to pass a json body pass a dictionary asjsonparameter.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- patch_request(alias, uri, data=None, json=None, params=None, headers=None, files=None, allow_redirects=None, timeout=None)
DEPRECATED Please use PATCH On Session instead.
Send a PATCH request on the session object found using the given alias
aliasthat will be used to identify the Session object in the cacheurito send the PATCH request todataa dictionary of key-value pairs that will be urlencodedand sent as PATCH data or binary data that is sent as the raw body content or file descriptor retrieved by Get File For Streaming Upload
jsona value that will be json encodedand sent as PATCH data if data is not specified
headersa dictionary of headers to use with the requestfilesa dictionary of file names containing file data to PATCH to the serverallow_redirectsBoolean. Set to True if POST/PUT/DELETE redirect following is allowed.paramsurl parameters to append to the uritimeoutconnection timeout
- post_on_session(**kwargs)
Sends a POST request on a previously created HTTP Session.
Session will be identified using the
aliasname. The endpoint used to send the request is theurlparameter, while its body can be passed usingdataorjsonparameters.datacan be a dictionary, list of tuples, bytes, or file-like object. If you want to pass a json body pass a dictionary asjsonparameter.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- post_request(alias, uri, data=None, json=None, params=None, headers=None, files=None, allow_redirects=None, timeout=None)
DEPRECATED Please use POST On Session instead.
Send a POST request on the session object found using the given alias
aliasthat will be used to identify the Session object in the cacheurito send the POST request todataa dictionary of key-value pairs that will be urlencodedand sent as POST data or binary data that is sent as the raw body content or passed as such for multipart form data if
filesis also defined or file descriptor retrieved by Get File For Streaming Uploadjsona value that will be json encodedand sent as POST data if files or data is not specified
paramsurl parameters to append to the uriheadersa dictionary of headers to use with the requestfilesa dictionary of file names containing file data to POST to the serverallow_redirectsBoolean. Set to True if POST/PUT/DELETE redirect following is allowed.timeoutconnection timeout
- put_on_session(**kwargs)
Sends a PUT request on a previously created HTTP Session.
Session will be identified using the
aliasname. The endpoint used to send the request is theurlparameter, while its body can be passed usingdataorjsonparameters.datacan be a dictionary, list of tuples, bytes, or file-like object. If you want to pass a json body pass a dictionary asjsonparameter.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- put_request(alias, uri, data=None, json=None, params=None, files=None, headers=None, allow_redirects=None, timeout=None)
DEPRECATED Please use PUT On Session instead.
Send a PUT request on the session object found using the given alias
aliasthat will be used to identify the Session object in the cacheurito send the PUT request todataa dictionary of key-value pairs that will be urlencodedand sent as PUT data or binary data that is sent as the raw body content or file descriptor retrieved by Get File For Streaming Upload
jsona value that will be json encodedand sent as PUT data if data is not specified
headersa dictionary of headers to use with the requestallow_redirectsBoolean. Set to True if POST/PUT/DELETE redirect following is allowed.paramsurl parameters to append to the uritimeoutconnection timeout
- request_should_be_successful(response=None)
Fails if response status code is a client or server error (4xx, 5xx).
responseis the output of other requests keywords like GET On Session. If omitted the last response will be used.In case of failure an HTTPError will be automatically raised.
For a more versatile assert keyword see Status Should Be.
- session_exists(alias)
Return True if the session has been already created
aliasthat has been used to identify the Session object in the cache
- session_less_delete(**kwargs)
Sends a DELETE request.
The endpoint used to send the request is the
urlparameter.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- session_less_get(**kwargs)
Sends a GET request.
The endpoint used to retrieve the resource is the
url, while query string parameters can be passed as string, dictionary (or list of tuples or bytes) through theparams.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargshere is a list:data| Dictionary, list of tuples, bytes, or file-like object to send in the body of the request. |json| A JSON serializable Python object to send in the body of the request. |headers| Dictionary of HTTP Headers to send with the request. |cookies| Dict or CookieJar object to send with the request. |files| Dictionary of file-like-objects (or{'name': file-tuple}) for multipart encoding upload. |file-tuple| can be a 2-tuple('filename', fileobj), 3-tuple('filename', fileobj, 'content_type')or a 4-tuple('filename', fileobj, 'content_type', custom_headers), where'content-type'is a string defining the content type of the given file andcustom_headersa dict-like object containing additional headers to add for the file. |auth| Auth tuple to enable Basic/Digest/Custom HTTP Auth. |timeout| How many seconds to wait for the server to send data before giving up, as a float, or a(connect timeout, read timeout)tuple. |allow_redirects| Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to${True}. |proxies| Dictionary mapping protocol or protocol and host to the URL of the proxy (e.g. {‘http’: ‘foo.bar:3128’, ‘http://host.name’: ‘foo.bar:4012’}) |verify| Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to${True}. Warning: if a session has been created withverify=${False}any other requests will not verify the SSL certificate. |stream| if${False}, the response content will be immediately downloaded. |cert| if String, path to ssl client cert file (.pem). If Tuple, (‘cert’, ‘key’) pair. |For more updated and complete information verify the official Requests api documentation: https://requests.readthedocs.io/en/latest/api/
- session_less_head(**kwargs)
Sends a HEAD request.
The endpoint used to retrieve the HTTP headers is the
url.allow_redirectsparameter is not provided, it will be set to False (as opposed to the default behavior).By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- session_less_options(**kwargs)
Sends a OPTIONS request.
The endpoint used to retrieve the resource is the
url.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- session_less_patch(**kwargs)
Sends a PUT request.
The endpoint used to send the request is the
urlparameter, while its body can be passed usingdataorjsonparameters.datacan be a dictionary, list of tuples, bytes, or file-like object. If you want to pass a json body pass a dictionary asjsonparameter.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- session_less_post(**kwargs)
Sends a POST request.
The endpoint used to send the request is the
urlparameter, while its body can be passed usingdataorjsonparameters.datacan be a dictionary, list of tuples, bytes, or file-like object. If you want to pass a json body pass a dictionary asjsonparameter.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- session_less_put(**kwargs)
Sends a PUT request.
The endpoint used to send the request is the
urlparameter, while its body can be passed usingdataorjsonparameters.datacan be a dictionary, list of tuples, bytes, or file-like object. If you want to pass a json body pass a dictionary asjsonparameter.By default this keyword fails if a status code with error values is returned in the response, this behavior can be modified using the
expected_statusandmsgparameters, read more about it in Status Should Be keyword documentation. In order to disable this implicit assert mechanism you can pass asexpected_statusthe valuesanyoranything.Other optional requests arguments can be passed using
**kwargssee the GET keyword for the complete list.
- status_should_be(expected_status, response=None, msg=None)
Fails if response status code is different than the expected.
expected_statuscould 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.responseis the output of other requests keywords like GET or GET On Session. If omitted the last response will be used.In case of failure an HTTPError will be automatically raised. A custom failure message
msgcan be added like in built-in keywords.New requests keywords like GET or GET On Session (starting from 0.8 version) already have an implicit assert mechanism that, by default, verifies the response status code. Status Should Be keyword can be useful when you disable implicit assert using
expected_status=anything.For example when you have a nested keyword that is used for both OK and ERROR responses:
* Test Cases *Test Get Request And Make Sure Is A 404 Response${resp}= GET Custom Keyword That Returns OK or ERROR Response case=notfoundStatus Should Be 404 ${resp}Should Be Equal As Strings NOT FOUND ${resp.reason}Test Get Request And Make Sure Is OK${resp}= GET Custom Keyword That Returns OK or ERROR Response case=passStatus Should Be 200 ${resp}Should Be Equal As Strings OK ${resp.reason}* Keywords *GET Custom Keyword That Returns OK or ERROR Response[Arguments] $case[…]IF $case == notfound$resp= GET […] expected_status=Anything[Return] $respELSE[…]
- to_json(content, pretty_print=False)
DEPRECATED Please use ${resp.json()} instead. Have a look at the improved HTML output as pretty printing replacement.
Convert a string to a JSON object
contentString content to convert into JSONpretty_printIf defined, will output JSON is pretty print format
- update_session(alias, headers=None, cookies=None)
Updates HTTP Session Headers and Cookies.
Session will be identified using the
aliasname. Dictionary ofheadersandcookiesto be updated and merged into session data.