This project focuses on automating REST API tests using Robot Framework and the RequestsLibrary. It includes sending a POST request to the Reqres API, validating the status code, and verifying the content of the response body. This setup aims to simplify API testing by automating repetitive tasks and ensuring that the API behaves as expected.
This project automates REST API testing using Robot Framework and the RequestsLibrary. It interacts with the Reqres API to send POST requests, validate status codes, and ensure the correctness of response content. This is particularly useful for performing regression tests and validating API behavior.
- Author: Enock Odhiambo Omondi
- Version: 1.0.0
- API: Reqres API
- Robot Framework Libraries:
- RequestsLibrary
- Collections
The test case sends a POST request to the Reqres API to create a user with the following steps:
- Establishes a session with the base URL.
- Sends a POST request with user details (name and job).
- Logs the status code and response content.
- Validates the status code to ensure it is
201. - Verifies the response body contains the expected user details (name: morpheus, job: leader).
*** Settings ***
Metadata Author Enock Odhiambo Omondi
Metadata Version 1.0.0
Documentation REST API AUTOMATION
Library RequestsLibrary
Library Collections
*** Variables ***
${base_url}= https://reqres.in
*** Test Cases ***
Put_UsersLists
[Documentation] Send Post Request and Validate the Status code along with the response body.
[Tags] Regression Tests
Create Session mysession ${base_url}
${body}= Create Dictionary name=morpheus job=leader
${header}= Create Dictionary Content-Type=application/json
${response}= Post Request mysession /api/users data=${body} headers=${header}
Log To Console ${response.status_code}
Log To Console ${response.content}
#VALIDATIONS
${status_code}= Convert To String ${response.status_code}
Should Be Equal ${status_code} 201
${res_body}= Convert To String ${response.content}
Should Contain ${res_body} morpheus
Should Contain ${res_body} leader
## How to Run the Tests
1. **Clone the repository:**
```bash
git clone https://github.com/yourusername/rest-api-automation.git
2. Install the necessary dependencies:
pip install -r requirements.txt
3. Run the test case:
robot .\TestCases\TC2_POST_USERS.robot
4. License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
5. Contact
For any questions or inquiries, please contact [enockodhiambo2@gmail.com].

