Adding Repetition Logic to a Visual Test

This topic describes how you can use the Test Logic Designer to add repetition logic to a visual test.
  1. Open the visual test.
  2. Right-click on the test step or the sequence of test steps that you want to repeat.
  3. Choose Insert > Test Logic > Repetition. The Test Logic Designer wizard opens.
  4. Click Next.
  5. From the Select a Logic Type page, select the type of repetition logic.

    Select a type of repetition logic based on:

    • The property of a control – Creates repetition logic that repeats a sequence of steps based on the property of a control in your test application. For example:
      Repeat While propertyValue = 3 Do step 3 To step 4 End Repeat
    • Whether a control exists - Creates repetition logic that repeats a sequence of steps based on whether a specified control exists or the specified control does not exist. For example:
      Repeat While "Button" Exists Is Equal to True Do Step 3 To Step 4 End Repeat
    • A variable defined in this visual test – Creates repetition logic that repeats a sequence of steps based on the contents of a local variable defined in your visual test. For example:
      Repeat While numberVar < 5 Do step 3 To step 5 End Repeat
    • Repeating a sequence of steps a set number of times - Creates repetition logic that repeats a sequence of steps a set number of times. For example:
      Repeat this loop 10 times Do step 3 To step 7 End Repeat
    • The contents of a list or combo box - Creates repetition logic that repeats a sequence of steps for each item in a list or combo box. For example:
      Repeat for each item in ListA Do step 3 To step 5 End Repeat
    • Repeating a sequence of steps using data from an ActiveData file - Creates repetition logic to run a sequence of steps based on the data in an ActiveData file used in your visual test. For example:
      Repeat using ActiveData file testData Do step 3 To step 5 End Repeat
    • Advanced logic – Skips the Defining the Condition step of the wizard and creates advanced repetition logic using the Condition Designer. For example:
       Repeat While propertyValue = red OR stringVar = red Do step 3 To step 5 End Repeat
  6. Click Next.
  7. If you have selected The property of a control, the Define a property-based condition page opens.
    1. Expand the Identify a Control menu to the right of the Name of control field.
    2. Expand the Identify a control menu and select one of the following:
      • Application Under Test – Click this button to identify a visible control directly from the application under test.
      • Screen Preview – Click this button to identify a control directly from the Screen Preview, if the application under test is not available.
      • Identify Object Dialog – Click this button to use the Identify Object dialog box to identify a non-visible control. The Identify Object dialog box additionally enables you to edit the locator of the control.
    3. In the Select a property table, select the property.
    4. From the Select the condition list, select the conditional logic to apply to the property of the control.
    5. In the Expected value field, specify the value that the property is expected to have.
    6. Click Next.
  8. If you have selected Whether a control exists, the Define an exists condition for the control page opens.
    1. Expand the Identify a control menu and select one of the following:
      • Application Under Test – Click this button to identify a visible control directly from the application under test.
      • Screen Preview – Click this button to identify a control directly from the Screen Preview, if the application under test is not available.
      • Identify Object Dialog – Click this button to use the Identify Object dialog box to identify a non-visible control. The Identify Object dialog box additionally enables you to edit the locator of the control.
    2. Select Control exists to verify that the control exists.
    3. Select Control does not exist to verify that the control does not exist.
    4. Type a value into the Timeout field to specify how long Silk Test Workbench should wait for the control to appear or to disappear. The default timeout is 0, which means Silk Test Workbench does not wait for the control to appear or to disappear.
    5. Click Next.
  9. If you have selected A variable defined in this visual test, the Define a variable-based condition page opens.
    1. Select a pre-defined local variable from the Select the variable list. For a variable to appear in this list, you must include the local variable in your visual test. To add a new local variable to the visual test, click New. The Evaluate as field, displays the data type of the selected variable.
    2. Select the comparison operator to apply to the variable from the Select the condition list.
    3. In the Expected value field, specify the value that the variable is expected to have.
    4. Click Next.
  10. If you have selected Repeating a sequence of steps a set number of times, the Define the Number of Times to Repeat page opens.
    1. Specify the number of times to repeat a sequence of steps by entering a numerical value between 1 and 32767.
    2. Click Next.
  11. If you have selected The contents of a list or combo box, the Define the repeat based on a control page opens.
    1. Expand the Identify a control menu and select one of the following:
      • Application Under Test – Click this button to identify a visible control directly from the application under test.
      • Screen Preview – Click this button to identify a control directly from the Screen Preview, if the application under test is not available.
      • Identify Object Dialog – Click this button to use the Identify Object dialog box to identify a non-visible control. The Identify Object dialog box additionally enables you to edit the locator of the control.
      For either type of control, you can create repetition logic that uses the value of each item in a list or combo box. For example, you can create a repeat loop that iterates through the values in a list or combo box and inserts the value of each item into a text box in your test application. In this way, you can quickly test the entire contents of a list or combo box.
    2. Click Next.
  12. If you have selected Repeating a sequence of steps using data from an ActiveData file, the Define the ActiveData asset to use page opens. Use the Define the ActiveData Asset to use page to define the ActiveData asset and the retrieval method of the data in the ActiveData asset to use in your repetition logic.
    1. Select an ActiveData asset from the list. You must first include an ActiveData asset in your visual test to make it available in this list.
    2. Select the sheet in the data file that you want to use from the Sheet name list. By default, the sheet that is specified in the ActiveData asset is used.
    3. Type the number of the first row of data in your ActiveData file to use into the Start row field.
    4. Check the Start at last row containing data check box to start at the last row of data in your ActiveData file. Silk Test Workbench automatically detects the last row in your file and reverses the iteration through the rows in your ActiveData file. For example, if your ActiveData file contains 10 rows and you select this option, Silk Test Workbench iterates starting with row 10, then row 9, row 8, and so on.
    5. Type the number of the last row of data in your ActiveData file into the End row field.
    6. Check the End at last row containing data check box to end at the last row of data in your ActiveData file. Silk Test Workbench automatically detects the last row in your file.
      Tip: If the Start at last row containing data or End at last row containing data check boxes are checked, the Start Row or End Row property values for the Repeat step are set to -1.
    7. Select in which order the rows should be processed:
      • Get all rows in sequence – Select this option to iterate through the selected rows in your ActiveData file in sequence from the first specified row to the last specified row.

      • Get all rows in random order – Select this option to randomly iterate through all of the rows in your ActiveData file.

      • Get X random rows – Select this option and type the number of rows in your ActiveData file to randomly iterate through.

    8. Click Next.
  13. If you have selected Advanced logic, click Next.
  14. The Build the Repeat page opens. Specify the sequence of steps to repeat.
    Tip: Rest your pointer on a link to display a ToolTip containing the full link description.
    1. For a "repeat while", select whether you want the condition for the repeat to be checked at the start or at the end of the loop.
    2. For a "repeat while", click the link to the right of the Repeat while statement to specify the conditional logic in the Condition Designer.
    3. Click the link to the right of the Do step statement to specify the first step in the sequence of steps to repeat.
    4. Click the link to the right of the To step statement to specify the last step in the sequence of steps to repeat.
  15. Click Next. The Summary page displays the test logic that you have defined. Uncheck the check box at the bottom of the page to prevent the Summary page from appearing on subsequent uses of the Test Logic Designer wizard. Checking or un-checking this check box updates the Show Test Logic Designer summary screen general option. For more information, see Modifying General Options.
  16. Click Finish to insert the test logic into the test steps of your visual test. To modify the test logic, click Back and make the desired changes. The test logic is added to the visual test.