Using Loops and Sections

Prev Next

In this example, we will show you how to repeat instructions several times and control the number of repetitions via a Data Set input parameter.

Suppose we wanted to create 2 sales orders in one test automation run. We would want to repeat a set of instructions several times. In order to do that we could follow the below steps.

  1. We begin by recording a basic Fiori transaction and creating a sales order.

  2. Use sections to separate the instructions into blocks, such as a Login section and a Create Sales Order section.

  1. Create an input parameter, number_of_orders; this will be used to control the number of times a specific set of instructions should be executed. For this example, we will set it to 2, and when running the test in ScriptBuilder, we will expect that 2 Sales Orders will be created.

  1. This number can be further adjusted as needed in the Panaya Automated Test Data Sets screen so that when an agent executes the test, it will use the value entered here.

  1. We will also create an internal parameter, Orders, to monitor the number of times a section of instructions is run.

  1. Notice that we set the parameter Orders before the section "Create Sales Order" and initialize it with the number of orders.


7. At the end of the script, we will reduce the Orders parameter by 1

  1. Then, using the Go to section command, we will validate the value of the Orders parameter. As long as it is greater than 0, the script will jump back to the Create Sales Order section to create a new sales order. In this example, if the input parameter number_of_orders is set to 2, then it should create 2 sales orders.