...

Integrating Worksoft Certify with Python - API Testing

In my previous blog Overview of API Testing, Where I have explained briefly the API testing features and their benefits. I suggest you go and check out the SOAIS blog.

Now let us begin how to Integrate Worksoft Certify with Python. Where I have explained step by step procedure followed by.

  1. Requirements
  2. Prerequisite/Installation
  3. Source Code
  4. Result

Requirement:

  1. Send the API Request from Certify and triggering Python to receive a response.
  2. API URL: http://jsonplaceholder.typicode.com/todos
  3. Store the Response data in a text file in the Document folder.
  4. Deserialize the response in Certify.

Prerequisite for API Testing:

  1. Install the latest version of Python
  2. Install the latest version of PyCharm Community Version (Links given in the reference section)

After installing Python, we need to verify whether python is installed or not, to do so open the command prompt and type Python –Version. You should be seeing the version number that you have installed.

Command prompt

After successfully installation python we need to install and upgrade the PIP

PIP:  pip is the package installer for Python. You can use pip to install packages from the Python Package Index and other indexes.

Command: python -m pip install –upgrade pip

upgrade pip

Verify the PIP version by entering the below command, you should be seeing the latest version of PIP as per the below screenshot

Command: pip –version

pip version

So now you have successfully installed Python and PIP.

PyCharm Installation Procedure:

PyCharm is a dedicated Python Integrated Development Environment (IDE) providing a wide range of essential tools for Python developers, tightly integrated to create a convenient environment for productive Python, web, and data science development.

After Installing PyCharm, click on the Create New Project

Pycharm

After clicking on Create New Project we need to Name the Project now as you can see in the screenshot you can name your project as per your preference.

API testing

Now you ready to Create you are Python file to do so you can right-click on the project>New>PythonFile

Python file

After selecting the python file provide a name to the file with the .py extension.

Example: SampleDemo.py

Sample demo

After providing the name to the Python file. Workspace is now ready to where you can write the python code.

Python code

Python Code: Copy the Python code and paste it into your workspace.

Workspace

After Copying the Python code, you will see the warning message asking to install the Request Package.

Requests allow you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URL or to form-encode your POST data. Steps: To do so hover the mouse near the import request step in python code you will see a suggestion popup asking to import Request Package, click on it and wait for the Request Package to get installed. Once it’s successfully installed there will be no warning message.

Warning message

Let us now integrate it with Worksoft Certify

As per the requirement. Create certify steps to trigger the Python project from a command prompt and store the Response in a text file and deserialize the response values in Certify.

Worksoft certify

Recordset: Certify Recordset will have two input values

  1. Python file path
  2. Output file path where the response will store in a txt file
Recordset

Concatenate Python File path and the output file path and store the concatenated value in a variable called CMD.

cmd

Use the Input dos command step to trigger the Python where the API Testing project is created.

API testing

Store the Response from the text file in a variable called Result.

Result

Once it is stored in a variable, we can deserialize the values based on the requirements

In this example, I am Deserializing

  1. Response Status
  2. Response Time
  3. User ID
  4. Title
Deserializing

Run the Certify Process

Certify process

As you can see, we have stored the Response and Deserialized based on our Requirement

This concludes the Integrating Worksoft Certify with Python. Contribution by Feroz Shaikh

References:

Worksoft: https://docs.worksoft.com/Welcome_To_Worksoft_Help_Portal.htm

Python: https://www.python.org/doc/

PyCharm: https://www.jetbrains.com/pycharm/documentation/

Leave a Reply

Your email address will not be published. Required fields are marked *