Robot Framework Requests Library
robotframework-requests is a Robot Framework keyword library that wraps the popular Python Requests library, providing HTTP API testing functionalities. It is actively developed, with a stable `0.9.x` series and an ongoing `1.0aX` pre-release series introducing significant changes and new features.
Warnings
- breaking Python 2 support has been removed in `v1.0a10` and later versions. Users on Python 2 must either upgrade to Python 3 or stick to older `0.9.x` releases.
- breaking Many old keywords (e.g., `Get Request`, `Post Request`) are deprecated and will be removed in `v1.0.0` in favor of new keywords (e.g., `GET`, `POST`, `GET On Session`, `POST On Session`). The new keywords offer improved parameter alignment with the underlying `requests` library.
- gotcha Keywords like `GET On Session` or `POST On Session` implicitly fail if an error status code (e.g., 4xx, 5xx) is returned by default. To test for expected error responses (negative testing), you must explicitly set the `expected_status` parameter (e.g., `expected_status=any` or `expected_status=404`).
- gotcha Sensitive information, such as Authorization headers containing API keys or tokens, is logged by default. This can lead to security vulnerabilities if logs are not properly secured.
- gotcha There was an issue where file descriptors might not be closed correctly when using the `files` parameter, potentially leading to resource leaks. Additionally, uploading files as a list was broken in some `1.0aX` versions.
- gotcha The `auth` parameter for authentication can be inconsistent. `Create Session` may accept an iterable (e.g., list or tuple), but non-session keywords like `GET` typically expect a 2-length tuple specifically for HTTP Basic Authentication.
Install
-
pip install robotframework-requests
Imports
- RequestsLibrary
*** Settings *** Library RequestsLibrary
Quickstart
*** Settings ***
Library RequestsLibrary
*** Test Cases ***
Quick Get Request Example
${response}= GET https://jsonplaceholder.typicode.com/posts/1
Status Should Be 200 ${response}
Should Be Equal As Strings 1 ${response.json()}[id]
Log To Console Response Body: ${response.json()}