Pre-process request body before executing test cases

Yes, request body can be modified with the help of utility methods. Let's take an example scenario.

Suppose we want to encrypt request body before executing the test case. We can achieve this with the help of utility methods in the following steps:

  1. First write a utility method which pre-process our input. In our example scenario, first write an utility method which encrypts the data. A sample code can be downloaded below for your reference.
    1. Download the file - encrypt.js
    2. Few points regarding this code:
      1. Copy the attached sample code and create a new utility method with that code. Name this utility method as "encrypt".
      2. Library used in the code is jsencrypt.
  2. Now, in test cases, you may encrypt the request body as shown in the below figure:

Note: You may even pass the dynamic data using variables to this utility method.