Manual Testing Tools for API's in Robot Framework

Manual testing is a type of software testing where Testers manually execute test cases without using any automation tools, Manual testing is the most primitive of all the testing types and helps to find the bugs in the software system. Any new applications must be manually tested before its testing can be automated.

Following are the manual testing tools :

  • Postman (API Testing)
  • Selenium (Web Application Testing)
  • Jenkins (Continuous Testing)
  • Appium (Mobile Testing)
  • JMeter (Load Testing)
  • TestLink (Test Management)
  • Mantis (Bug-Tracking & Project Management)
  • Firebug / Firepath (Online Debugging)

We have discussed Jenkins in detail, please refer my previous article for complete Jenkins Tutorial

Automation of REST API in Robot Framework

Postman an API tool in Robot Framework

Postman is an API(application programming interface) development tool that helps to build, test, and modify APIs. Almost any functionality that could be needed by any developer is encapsulated in this tool. It presents you with a friendly GUI for constructing requests and reading responses.

Installation of postman software:

Navigate to Download Postman and click on the Download button on the below page depend on your system configuration.

download-postman-software

Once it downloaded, click on Open to open the folder. Once the exe file is open, it will ask you to create a free account for the first time users, enter the required credentials and sign up. The next set up page will open, select the option Debugging and manual testing as your preference.

set-my-preferences

The postman page will look like as shown below

postman-page

Now, start testing our Google Search API, navigate to the link google Search API Documentation, and you will find all the details of place search. If you scroll down, you will find an example which as been given from the google, A Find Place request is an HTTP URL of the following form and given an endpoint alsohttps://maps.googleapis.com/maps/api/place/findplacefromtext/output?parameters

The Base URL is:https://maps.googleapis.com/maps/api

The resource is:/place/nearbysearch/JSON

Parameter is: ?location=-33.8670522,151.1957362&radius=1500&type=restaurant&keyword=cruise&key=YOUR_API_KEY

Goggle also says about the required parameters and the optional parameters

Required parameters:

Key : Your application's API key. This key identifies your application. See Get a key for more information.

Input: Text input that identifies the search target, such as a name, address, or phone number. The input must be a string. Non-string input, such as a lat/lng coordinate or plus code, generates an error.

Inputtype: The type of input. This can be one of either textquery or phonenumber. Phone numbers must be in international format (prefixed by a plus sign ("+"), followed by the country code, then the phone number itself).

Optional Requirements :

Language : The language code, indicating in which language the results should be returned, if possible. Searches are also biased to the selected language; results in the selected language may be given a higher ranking. See the list of supported languages and their codes. Note that we often update supported languages, so this list may not be exhaustive.

Fields: The fields were specifying the types of place data to return, separated by a comma.

Locationbias: Prefer results in a specified area, by specifying either a radius plus lat/lng, or two lat/lng pairs representing the points of a rectangle. If this parameter is not specified, the API uses IP address biasing by default.

IP bias: Instructs the API to use IP address biasing. Pass the string ipbias (this option has no additional parameters).

Point: A single lat/lng coordinate. Use the following format:

point:lat,lng.

Circular : A string specifying a radius in meters, plus lat/lng in decimal degrees.

Use the following format:
 circle:[email protected],lng.

Rectangular : A string specifying two lat/lng pairs in decimal degrees, representing the south/west and north/east points of a rectangle. Use the following format:

rectangle:south,west|north,east. Note that east/west values are wrapped to the range -180, 180, and north/south values are clamped to the range -90, 90.

As we are learning and hence we will use only the required parameters, the first parameter is Key, which acts as an authenticator, click on the Get a key and then you will find the steps to get an API key, just follow the below steps to get an API key:

  • Visit the Google Cloud Platform Console. and click on I agree and then click on the Agree and Continue button
    agree-and-continue
  • Click the project drop-down and select or create the project for which you want to add an API key.
    creating-new-project-robot-framework
  • Click the menu button and select APIs & Services > Credentials
    google-cloud-platform-menu
  • On the Credentials page, click Create credentials and select the API key.
    craete-credentialss-robot-framework
  • The API key created dialog displays your newly created API key.
    api-keys-robot-framework
  • Click Close.
  • The new API key is listed on the Credentials page under API keys.
  • (Remember to restrict the API key before using it in production.) On the Restrict and rename API key page, select IP addresses (web servers, cron jobs, etc.) to restrict.
    key-restrictions
  • Add the server IP addresses.
  • You may also enter a subnet using CIDR notation (e.g., 192.168.0.0/22).
  • Under API restrictions, Select Restrict key.
    api-restrictions
  • Click Select APIs and select Places API, and If the Places API is not listed, you need to enable it.
    Steps To Enable Places API :
  • Go to the Google Cloud Platform Console.
  • Click the menu button(Horizontal lines before Google Cloud Platform) and select APIs & Services > Library.
    api-service-library
  • On the API Library page, locate Maps and click VIEW ALL (15).
  • The 15 Google Maps Platform APIs and SDKs that you can enable are displayed.

api-library

  • On the Maps page, click the API or SDK you want to enable.
    maps-sdk-for-android
  • Enabling the Places API also enables the Places SDK for Android and Places SDK for iOS.
  • Back on the API Library page, under the name of the API or SDK you selected:
  • If the button says ENABLE, click the button to enable the API or SDK.
    enable-maps-javascript-api
  • If the button says MANAGE, the API or SDK is already enabled, and you don't need to do anything further.
  • Note: Clicking either button will display the dashboard for the API or SDK. (Click the DISABLE button to remove the API or SDK from this project.)
  • Repeat Steps 2-5 for each API or SDK you want to enable.
  • Click SAVE.
  • Add the API key to your request

Now, go back to the postman, and by default, it is a Get request, enter the base URL and the resource. Now enter the parameter, the first parameter we have to provide here is location, and the next parameter is key, for the key parameter you have to enter the value which has been generated while creating credentials, so just copy and paste as shown below and then the last one is the radius.

creating-end-point

Once you enter the required parameters, click on send. The postman will respond to you with the result, When I tried, the postman is not able to find the server, and hence it is throwing not found error.

not-found-error1

Automation Testing Basics

Swapi API in Robot Framework

The Star Wars API or swapi (Swah-pee) is the world's first quantified and programmatically-accessible data source for all the data from the Star Wars canon universe! We've taken all the rich contextual stuff from the universe and formatted it into something easier to consume with software.

Navigate to Swapi, and if you click on the documentation on the right-upper corner, you will find detailed information about the Introduction, Base URL, and rate Limiting, etc..

swapi-documentation

Let us send a request by copying the base URL from the Swapi app by selecting the people example

Base URL : https://swapi.co/api/

Resource : A People resource is an individual person or character within the Star Wars universe.

Enpoints:

/people/ -- get all the people resources

/people/:id/ -- get a specific people resource

/people/schema/ -- view the JSON schema for this resource

I am going to get all the people resource, and hence the resource becomes: /people/

The endpoint is: https://swapi.co/api/people/ copy this endpoint and pastes it in the postman to send a request

The postman gives the response as shown below, and the first thing we have to verify in every response is Status, it has given the status as 200 Ok and it also gave all the 87 counts.

response-for-people

{
    "count": 87,
    "next": "https://swapi.co/api/people/?page=2",
    "previous": null,
    "results": [
        {
            "name": "Luke Skywalker",
            "height": "172",
            "mass": "77",
            "hair_color": "blond",
            "skin_color": "fair",
            "eye_color": "blue",
            "birth_year": "19BBY",
            "gender": "male",
            "homeworld": "https://swapi.co/api/planets/1/",
            "films": [
                "https://swapi.co/api/films/2/",
                "https://swapi.co/api/films/6/",
                "https://swapi.co/api/films/3/",
                "https://swapi.co/api/films/1/",
                "https://swapi.co/api/films/7/"
            ],
            "species": [
                "https://swapi.co/api/species/1/"
            ],
            "vehicles": [
                "https://swapi.co/api/vehicles/14/",
                "https://swapi.co/api/vehicles/30/"
            ],
            "starships": [
                "https://swapi.co/api/starships/12/",
                "https://swapi.co/api/starships/22/"
            ],
            "created": "2014-12-09T13:50:51.644000Z",
            "edited": "2014-12-20T21:17:56.891000Z",
            "url": "https://swapi.co/api/people/1/"
        },
        {
            "name": "C-3PO",
            "height": "167",
            "mass": "75",
            "hair_color": "n/a",
            "skin_color": "gold",
            "eye_color": "yellow",
            "birth_year": "112BBY",
            "gender": "n/a",
            "homeworld": "https://swapi.co/api/planets/1/",
            "films": [
                "https://swapi.co/api/films/2/",
                "https://swapi.co/api/films/5/",
                "https://swapi.co/api/films/4/",
                "https://swapi.co/api/films/6/",
                "https://swapi.co/api/films/3/",
                "https://swapi.co/api/films/1/"
            ],
            "species": [
                "https://swapi.co/api/species/2/"
            ],
            "vehicles": [],
            "starships": [],
            "created": "2014-12-10T15:10:51.357000Z",
            "edited": "2014-12-20T21:17:50.309000Z",
            "url": "https://swapi.co/api/people/2/"
        },
        {
            "name": "R2-D2",
            "height": "96",
            "mass": "32",
            "hair_color": "n/a",
            "skin_color": "white, blue",
            "eye_color": "red",
            "birth_year": "33BBY",
            "gender": "n/a",
            "homeworld": "https://swapi.co/api/planets/8/",
            "films": [
                "https://swapi.co/api/films/2/",
                "https://swapi.co/api/films/5/",
                "https://swapi.co/api/films/4/",
                "https://swapi.co/api/films/6/",
                "https://swapi.co/api/films/3/",
                "https://swapi.co/api/films/1/",
                "https://swapi.co/api/films/7/"
            ],
            "species": [
                "https://swapi.co/api/species/2/"
            ],
            "vehicles": [],
            "starships": [],
            "created": "2014-12-10T15:11:50.376000Z",
            "edited": "2014-12-20T21:17:50.311000Z",
            "url": "https://swapi.co/api/people/3/"
        },
        {
            "name": "Darth Vader",
            "height": "202",
            "mass": "136",
            "hair_color": "none",
            "skin_color": "white",
            "eye_color": "yellow",
            "birth_year": "41.9BBY",
            "gender": "male",
            "homeworld": "https://swapi.co/api/planets/1/",
            "films": [
                "https://swapi.co/api/films/2/",
                "https://swapi.co/api/films/6/",
                "https://swapi.co/api/films/3/",
                "https://swapi.co/api/films/1/"
            ],
            "species": [
                "https://swapi.co/api/species/1/"
            ],
            "vehicles": [],
            "starships": [
                "https://swapi.co/api/starships/13/"
            ],
            "created": "2014-12-10T15:18:20.704000Z",
            "edited": "2014-12-20T21:17:50.313000Z",
            "url": "https://swapi.co/api/people/4/"
        },
        {
            "name": "Leia Organa",
            "height": "150",
            "mass": "49",
            "hair_color": "brown",
            "skin_color": "light",
            "eye_color": "brown",
            "birth_year": "19BBY",
            "gender": "female",
            "homeworld": "https://swapi.co/api/planets/2/",
            "films": [
                "https://swapi.co/api/films/2/",
                "https://swapi.co/api/films/6/",
                "https://swapi.co/api/films/3/",
                "https://swapi.co/api/films/1/",
                "https://swapi.co/api/films/7/"
            ],
            "species": [
                "https://swapi.co/api/species/1/"
            ],
            "vehicles": [
                "https://swapi.co/api/vehicles/30/"
            ],
            "starships": [],
            "created": "2014-12-10T15:20:09.791000Z",
            "edited": "2014-12-20T21:17:50.315000Z",
            "url": "https://swapi.co/api/people/5/"
        },
        {
            "name": "Owen Lars",
            "height": "178",
            "mass": "120",
            "hair_color": "brown, grey",
            "skin_color": "light",
            "eye_color": "blue",
            "birth_year": "52BBY",
            "gender": "male",
            "homeworld": "https://swapi.co/api/planets/1/",
            "films": [
                "https://swapi.co/api/films/5/",
                "https://swapi.co/api/films/6/",
                "https://swapi.co/api/films/1/"
            ],
            "species": [
                "https://swapi.co/api/species/1/"
            ],
            "vehicles": [],
            "starships": [],
            "created": "2014-12-10T15:52:14.024000Z",
            "edited": "2014-12-20T21:17:50.317000Z",
            "url": "https://swapi.co/api/people/6/"
        },
        {
            "name": "Beru Whitesun lars",
            "height": "165",
            "mass": "75",
            "hair_color": "brown",
            "skin_color": "light",
            "eye_color": "blue",
            "birth_year": "47BBY",
            "gender": "female",
            "homeworld": "https://swapi.co/api/planets/1/",
            "films": [
                "https://swapi.co/api/films/5/",
                "https://swapi.co/api/films/6/",
                "https://swapi.co/api/films/1/"
            ],
            "species": [
                "https://swapi.co/api/species/1/"
            ],
            "vehicles": [],
            "starships": [],
            "created": "2014-12-10T15:53:41.121000Z",
            "edited": "2014-12-20T21:17:50.319000Z",
            "url": "https://swapi.co/api/people/7/"
        },
        {
            "name": "R5-D4",
            "height": "97",
            "mass": "32",
            "hair_color": "n/a",
            "skin_color": "white, red",
            "eye_color": "red",
            "birth_year": "unknown",
            "gender": "n/a",
            "homeworld": "https://swapi.co/api/planets/1/",
            "films": [
                "https://swapi.co/api/films/1/"
            ],
            "species": [
                "https://swapi.co/api/species/2/"
            ],
            "vehicles": [],
            "starships": [],
            "created": "2014-12-10T15:57:50.959000Z",
            "edited": "2014-12-20T21:17:50.321000Z",
            "url": "https://swapi.co/api/people/8/"
        },
        {
            "name": "Biggs Darklighter",
            "height": "183",
            "mass": "84",
            "hair_color": "black",
            "skin_color": "light",
            "eye_color": "brown",
            "birth_year": "24BBY",
            "gender": "male",
            "homeworld": "https://swapi.co/api/planets/1/",
            "films": [
                "https://swapi.co/api/films/1/"
            ],
            "species": [
                "https://swapi.co/api/species/1/"
            ],
            "vehicles": [],
            "starships": [
                "https://swapi.co/api/starships/12/"
            ],
            "created": "2014-12-10T15:59:50.509000Z",
            "edited": "2014-12-20T21:17:50.323000Z",
            "url": "https://swapi.co/api/people/9/"
        },
        {
            "name": "Obi-Wan Kenobi",
            "height": "182",
            "mass": "77",
            "hair_color": "auburn, white",
            "skin_color": "fair",
            "eye_color": "blue-gray",
            "birth_year": "57BBY",
            "gender": "male",
            "homeworld": "https://swapi.co/api/planets/20/",
            "films": [
                "https://swapi.co/api/films/2/",
                "https://swapi.co/api/films/5/",
                "https://swapi.co/api/films/4/",
                "https://swapi.co/api/films/6/",
                "https://swapi.co/api/films/3/",
                "https://swapi.co/api/films/1/"
            ],
            "species": [
                "https://swapi.co/api/species/1/"
            ],
            "vehicles": [
                "https://swapi.co/api/vehicles/38/"
            ],
            "starships": [
                "https://swapi.co/api/starships/48/",
                "https://swapi.co/api/starships/59/",
                "https://swapi.co/api/starships/64/",
                "https://swapi.co/api/starships/65/",
                "https://swapi.co/api/starships/74/"
            ],
            "created": "2014-12-10T16:16:29.192000Z",
            "edited": "2014-12-20T21:17:50.325000Z",
            "url": "https://swapi.co/api/people/10/"
        }
    ]
}

The following example demonstrates the Employee API

Navigate to Dummy employee Which is having a dummy employee list, it is open-source, and hence, you can add or delete employee details here.

dummy-employee-details

Copy the link from the first employee and paste it in the postman to get the response.

first-employee-response

As you can see the employee details shown above, it is in the HTML format, if you want to see nicely then click on the dropdown menu as shown below and select JSON, you can see in a proper form.

select-json-from-drop-down-menu

The response in the JSON is as follow:

first-employee-response-in-json-format

The detailed response is as shown below

[
    {
        "id": "1",
        "employee_name": "fdgfdhhgfg",
        "employee_salary": "1",
        "employee_age": "3",
        "profile_image": ""
    },
    {
        "id": "13462",
        "employee_name": "bbvb",
        "employee_salary": "67567",
        "employee_age": "65",
        "profile_image": ""
    },
    {
        "id": "13463",
        "employee_name": "dsfdsf",
        "employee_salary": "543543",
        "employee_age": "43543543",
        "profile_image": ""
    },
    {
        "id": "13469",
        "employee_name": "priya",
        "employee_salary": "100",
        "employee_age": "15",
        "profile_image": ""
    },
    {
        "id": "13471",
        "employee_name": "sadsadsa",
        "employee_salary": "4545",
        "employee_age": "44",
        "profile_image": ""
    },
    {
        "id": "13474",
        "employee_name": "Aasim",
        "employee_salary": "124567",
        "employee_age": "22",
        "profile_image": ""
    },
    {
        "id": "13476",
        "employee_name": "SUAU",
        "employee_salary": "294",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13477",
        "employee_name": "eksb",
        "employee_salary": "86",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13478",
        "employee_name": "poFO",
        "employee_salary": "358",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13480",
        "employee_name": "lSGc",
        "employee_salary": "896",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13481",
        "employee_name": "dfdsfds",
        "employee_salary": "4354354",
        "employee_age": "43543",
        "profile_image": ""
    },
    {
        "id": "13485",
        "employee_name": "august123",
        "employee_salary": "125",
        "employee_age": "29",
        "profile_image": ""
    },
    {
        "id": "13488",
        "employee_name": "TMPg",
        "employee_salary": "707",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13489",
        "employee_name": "iBrl",
        "employee_salary": "78",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13490",
        "employee_name": "otks",
        "employee_salary": "571",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13491",
        "employee_name": "tcIj",
        "employee_salary": "578",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13493",
        "employee_name": "km-test-3",
        "employee_salary": "123",
        "employee_age": "23",
        "profile_image": ""
    },
    {
        "id": "13495",
        "employee_name": "Asim",
        "employee_salary": "500000",
        "employee_age": "29",
        "profile_image": ""
    },
    {
        "id": "13498",
        "employee_name": "tammy1338",
        "employee_salary": "5000",
        "employee_age": "20",
        "profile_image": ""
    },
    {
        "id": "13503",
        "employee_name": "Sd Xws",
        "employee_salary": "135813",
        "employee_age": "312",
        "profile_image": ""
    },
    {
        "id": "13505",
        "employee_name": "test35b285u2",
        "employee_salary": "12337837",
        "employee_age": "23374373",
        "profile_image": ""
    },
    {
        "id": "13506",
        "employee_name": "test",
        "employee_salary": "123",
        "employee_age": "23",
        "profile_image": ""
    },
    {
        "id": "13507",
        "employee_name": "Mohit",
        "employee_salary": "243",
        "employee_age": "434",
        "profile_image": ""
    },
    {
        "id": "13511",
        "employee_name": "AUtS",
        "employee_salary": "109",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13512",
        "employee_name": "FpEs",
        "employee_salary": "261",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13513",
        "employee_name": "TYoF",
        "employee_salary": "30",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13514",
        "employee_name": "FnOh",
        "employee_salary": "718",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13515",
        "employee_name": "undefined",
        "employee_salary": "0",
        "employee_age": "0",
        "profile_image": ""
    },
    {
        "id": "13521",
        "employee_name": "abubakarmaeru",
        "employee_salary": "1000000",
        "employee_age": "23",
        "profile_image": ""
    },
    {
        "id": "13525",
        "employee_name": "Mohitrtrt",
        "employee_salary": "434",
        "employee_age": "54434",
        "profile_image": ""
    },
    {
        "id": "13529",
        "employee_name": "try",
        "employee_salary": "3",
        "employee_age": "43",
        "profile_image": ""
    }
]

By using the id, we can also get the employee details as shown below

employee-details-by-using-emp-id

Now let us work on the post, copy the link from dummy example, for posting requesting we need to use create command as seen in the link http://dummy.restapiexample.com/api/v1/create. Click on the drop-down menu and select the Post and then select the Body under the post and next select raw as shown below.

select-post-body-and-raw-robot-framework

Now we have sent a raw request as key-value pairs in the JSON format as shown below and pastes it in the raw field and click on Send

{"name":"NextGen5","salary":"12345","age":"25"}

Once you send the request, you will get the response, and the id has been created as shown below

{"name":"NextGen5","salary":"12345","age":"25","id":"13968"}

To verify whether the id has been created or not go back to the get request and enter the link to get all the employee detail, you will find the newly created employee id over there.

newly-created-emp-id

Now, let us work on PUT request, for put request we have to provide the id, let us put our newly created id as shown below:

{"name":"NextGen6","salary":"12345","age":"25","id":"13968"}

So it has updated our employee details as shown below

put-request

Now, go back to get and verify whether the employee with name Nextgen6 has created or not. Next, let us work on the Delete request for that you need to use delete command followed by id you are going to delete at the end as sown below.

http://dummy.restapiexample.com/api/v1/delete/2

I am going to delete the employee details which is associated with the employee id 14428

deleting-emp-id-14428

Now, go back to the postman and enter the delete command, and if it is successfully deleted, then you will get the message as shown below.

delete-command

Now go back to get a request and verify, the employee details associated with id 14428 have been deleted.

verifying-after-deleting-file

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Subscribe to See Videos

Subscribe to my Youtube channel for new videos : Subscribe Now