Skip to content

swapnilkanthale01/robot_api_testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Automation Testing using Robot Framework

Objective

This project automates API testing for 3 different endpoints from ReqRes using the Robot Framework and RequestsLibrary.
Each API request (GET, POST, and PUT) is tested for both positive and negative scenarios to ensure accurate processing of API responses.


Project Overview

Task: Automation Testing for APIs
Goal: Validate the correct processing of requests for at least 3 APIs — one of each method: GET, POST, and PUT.

Key Requirements

  • Use APIs from https://reqres.in
  • Create different positive and negative scenarios
  • Automate using Robot Framework and RequestsLibrary
  • Ensure clear test coverage and documentation
  • Upload project with README and setup instructions

Technologies Used

  • Python 3.8+
  • Robot Framework
  • RequestsLibrary
  • ReqRes Fake REST API

Project Structure

robot_api_testing/ │ ├── tests/ │ └── api_tests.robot # Contains all test cases │ ├── README.md # Project documentation └── requirements.txt # Required dependencies


Setup Instructions

Follow these steps to set up and run the tests on your local system.

1️ Prerequisites

Make sure you have:

Check installation:

python --version

2️ Clone the Repository
git clone https://github.com/swapnilkanthale01/robot-api-testing.git
cd robot-api-testing

3️ Create and Activate a Virtual Environment

For Windows:

python -m venv venv
venv\Scripts\activate


4️ Install Required Packages
pip install -r requirements.txt

5️ Verify Installation
robot --version

 APIs Used (from ReqRes)
HTTP Method	Endpoint	Description
GET	/api/users?page=2	Fetch list of users
POST	/api/users	Create a new user
PUT	/api/users/2	Update an existing user


 Test Scenarios Covered
** Positive Scenarios
Test Case	Method	Expected Result
Fetch user list	GET	Status code 200, valid data returned
Create new user	POST	Status code 201, user ID and timestamp created
Update existing user	PUT	Status code 200, update timestamp generated
** Negative Scenarios
Test Case	Method	Expected Result
Invalid GET endpoint	GET	Status code 404
POST with missing fields	POST	Status code 201, handled response
PUT with invalid user ID	PUT	Status code 200, handled response


 Test File: api_tests.robot
*** Settings ***
Library           RequestsLibrary
Library           Collections
Suite Setup       Create Session    reqres    https://reqres.in
Test Setup        Log To Console    Starting test...
Test Teardown     Log To Console    Test completed.

*** Test Cases ***

# -------------------- GET TESTS --------------------
Validate Successful GET Request
    [Documentation]    Verify successful retrieval of user data using GET.
    ${response}=    Get Request    reqres    /api/users?page=2
    Should Be Equal As Integers    ${response.status_code}    200
    Dictionary Should Contain Key    ${response.json()}    data
    Log    ${response.json()}

Validate GET Request with Invalid Endpoint
    [Documentation]    Negative test: invalid endpoint should return 404.
    ${response}=    Get Request    reqres    /api/userz?page=2
    Should Be Equal As Integers    ${response.status_code}    404


# -------------------- POST TESTS --------------------
Validate Successful POST Request
    [Documentation]    Verify user creation using POST method.
    ${body}=    Create Dictionary    name=Swapnil    job=Tester
    ${response}=    Post Request    reqres    /api/users    json=${body}
    Should Be Equal As Integers    ${response.status_code}    201
    Dictionary Should Contain Key    ${response.json()}    id
    Dictionary Should Contain Key    ${response.json()}    createdAt
    Log    ${response.json()}

Validate POST with Missing Fields
    [Documentation]    Negative test: Missing fields should still return valid error or handled response.
    ${body}=    Create Dictionary    name=Swapnil
    ${response}=    Post Request    reqres    /api/users    json=${body}
    Should Be Equal As Integers    ${response.status_code}    201
    Log    ${response.json()}


# -------------------- PUT TESTS --------------------
Validate Successful PUT Request
    [Documentation]    Verify user update using PUT method.
    ${body}=    Create Dictionary    name=Swapnil    job=SeniorTester
    ${response}=    Put Request    reqres    /api/users/2    json=${body}
    Should Be Equal As Integers    ${response.status_code}    200
    Dictionary Should Contain Key    ${response.json()}    updatedAt
    Log    ${response.json()}

Validate PUT with Invalid User ID
    [Documentation]    Negative test: invalid user ID should still return handled response.
    ${body}=    Create Dictionary    name=InvalidUser    job=Tester
    ${response}=    Put Request    reqres    /api/users/99999    json=${body}
    Should Be Equal As Integers    ${response.status_code}    200
    Log    ${response.json()}


** Running the Tests

To execute all tests, run:

robot tests/api_tests.robot

*** Viewing Test Reports

After running, Robot Framework generates three files in the project root:

File	Description
output.xml	Machine-readable results
report.html	High-level summary report
log.html	Detailed step-by-step test logs

To open:

Double-click report.html or log.html, or

Run start report.html (Windows) or open report.html (Mac)


***References

Robot Framework Official Site

RequestsLibrary Documentation

ReqRes Public API

About

Robot Framework API Automation using Reqres.in

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published