In some cases, you need to write custom code to handle the user activities while preparing the script. For example, a hotel booking site displays a list of the hotels along with their occupancy status (Booked/Available). As per the business case, a user has to pick only that hotel which has occupancy status as ‘Available’. Let’s consider you replay the script with the recorded hotel which has already been booked while recording then the script will try to book the same booked hotel and the server will refuse it and throw an error. At last, you will get the script failure message. Now, you need to write a custom logic that checks the occupancy status of the hotel first and then book the available hotel only. In this scenario, you will perform flow debugging by inserting the correct business flow logic in the script.
You must have the basic knowledge of coding (like C language) to direct the execution flow in the right direction. The basic knowledge includes a command on conditional and iteration statements, declaration of variables, calling a function etc. Let’s try to understand the important flow control statements used in the LoadRunner:
Conditional Statements:
They evaluate the value of a variable against the given condition and control the flow as per the output (True or False).
- ‘if’ statement
- ‘if-else’ statement
- ‘if-(else-if…..)-else’ statement
Refer to the link to get more details on the conditional statements.
Iteration Statements:
The iteration statement helps to develop the logic to repeat certain codes or requests. Such statements are also called ‘Loop’. In C language, there are three basic loop statements which are listed below. LoadRunner supports all these three loop statements and helps to develop iterative logic in the test script.
- ‘for’ loop
- ‘while’ loop
- ‘do-while’ loop
Refer to the link to get more details on iteration statements.