Robot Framework API Automation using AWS

Robot framework is a test automation framework that uses its own builtin robot libraries. The core framework is implemented using Python language and also runs in Jython(JVM) and IronPython(.NET). With Robot framework we can do both UI testing and API testing.

Robot framework also gives the flexibility to create own test libraries. The name of the test library should be same as the class or module implementing it. This test library can be called by importing it.

As a part of this blog, would like to showcase on how api’s are being processed effectively by aws microservices components and how integration testing of these components using robot framework is executed.

Why API Testing?

Api testing is basically a part of integration testing to determine that they meet the intended functionality of the application and also its security. Since API testing is done without GUI its validated through response code, message and errors. And through amazon api gateway its made easy to process and publish secure api’s at any size.

API Base Library

All RESTful api’s that uses HTTP request to GET, PUT, POST and DELETE data, needs to be automated are written in apibase library file. This library can be initiated with header “Content-Type”: “application/json”.

  • GET – Retrieves Information of the HTTP request
self.response = requests.get(self.url, headers=self.headers, verify=ssl_certificate)
  • PUT – Creates a new entry if it doesn’t exist or update the existing one based on body content added to request.
self.response = requests.put(self.url, payload, headers=self.headers, verify=ssl_certificate)
  • POST – Creates a new entry based on body content added to request.
self.response =, payload, files=file, headers=self.headers, verify=ssl_certificate)
  • DELETE – Removes the resource provided in HTTP request
self.response = requests.delete(self.url, data=payload, headers=self.headers, verify=ssl_certificate)

Actions through API:

  1. Get status code of the API result: self.response.status_code
  2. Get body content of API result in json format: json.loads(self.response.text)
  3. Validate the response with the expected result.

Sample API robot Test:

Settings Section

  1. Library: The library file that’s required by api test case.
  2. Variables: The User Variables that needs to be validated

Test Case Section

  1. Test Case Name: Name of the test case
  2. Tags: Tag names specific to test case and testing type to which it corresponds to.       
  3. Documentation: Short summary of the test-case.                                                           
  4. ${VARIABLE}: The value that needs to be stored in a variable                                                     
  5. Method Name: The method name to be called from library imported                                       
  6. Condition: The condition that needs to be validated. This keyword by default is called from  Robot in-built library.

 Python Class  

  1. Import required libraries from specific modules.
  2. Import User Variables file.
  3. Import Config Values.
  4. Import log files
  5. Create a class
  6. Initialise base api python class
  7. Create methods required for the specific class
  8. Call the specific REST api method[GET/PUT/POST/DELETE] based on action that has to be performed
  9. From the payload class file import the payload that has to be added to body.  
  10. Perform following validation:
    1. Status code validation
    2. Response validation
    3. Mandatory fields validation
    4. Invalid Json Payload Validation
    5. Duplicate Entry Validation
  11. Return response to robot test case
  12. Connect to Database[Postgresql/SQL]
  13. After posting the request check whether the returned response value matches with new entry in database.
  14. From Robot Test validate whether the actual matches with the expected.

Processing Of API Packet Information

An application can subscribe to list of SNS topics. Through SNS it’s easy to send notifications reliably to endpoints and through SQS it’s easy to receive, store and send messages between software components. The packets/messages published by an application is received by SQS queue and Event Source(ES) queue as these queues are subscribed to the SNS topics which are also subscribed by  application too. The end application polls messages from the SQS queue process them and update accordingly in its database. And if the user wants to see the expired messages within a specific time range, an api to re-play those messages is requested and the messages get replayed back from Dynamodb to the SQS queue specified in api body.

Connection to AWS:

Boto is the Amazon Web Services (AWS) SDK for Python, which allows Python developers to  make use of Amazon services like S3 and EC2.

SNS: A low-level client representing Amazon Simple Notification Service (SNS).

To connect to SNS:

SQS: A low-level client representing Amazon Simple Queue Service (SQS)

To connect to SQS:

Dynamodb: A low-level client representing Amazon DynamoDB

To connect to DynamoDB:

DynamoDB values can be read either by scanning or by querying.


Scan operation is required as it can return items by accessing every item in table. FilterExpression is used to return items based on specific condition.

Fetching Information From AWS

After establishing connection to aws resources, the queue is accessed by providing the name. As in AWS, messages can’t be read as a batch from queue, each message body is stored in json format in a list like below.

Once the end application consumes the api information, its deleted from the queue. Finally it’s checked whether the information is processed correctly by validating the messages stored in list is available in the database of receiving end application.

Robot Framework Final Test Report




As a part of this blog, have detailed on how robot framework testing cab be used when large volume of data needs to be ingested, stored, protected and processed by AWS components for customers to handle their data.