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:
- 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.
- Download the file - encrypt.js
- Few points regarding this code:
- Copy the attached sample code and create a new utility method with that code. Name this utility method as "encrypt".
- Library used in the code is jsencrypt.
- 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.