Adding Decision Logic to a Visual Test

This topic describes how you can use the Test Logic Designer to add decision logic to a visual test. For information on how to add decision logic test steps directly to the visual test, see Inserting Decision Logic Using Decision Test Steps.
  1. Open the visual test.
  2. Right-click on the test step or the sequence of test steps that you want to include in your test logic.
  3. Choose Insert > Test Logic > Decision. The Test Logic Designer wizard opens.
  4. Click Next.
  5. From the Select a Logic Type page, select the type of decision logic.
    • The property of a control – Creates decision logic that runs a sequence of steps based on the property of a control in your test application. For example:
      If propertyValue > 2 then Do step 3 To step 4 End If
    • Whether a control exists - Creates decision logic that runs a sequence of steps based on whether a specified control exists or the specified control does not exist. For example:
      If "Button" Exists Is Equal to True Do Step 3 To Step 4 End If
    • A variable defined in this visual test – Creates decision logic that runs a sequence of steps based on the contents of a local variable defined in your visual test. For example:
      If stringVar = "red" then Do step 3 to step 4 End If
    • Advanced logic – Skips the Defining the Condition step of the wizard and creates advanced decision logic using the Condition Designer. For example:
      If stringVar = "red" AND numberVar = 10 then Do step 3 To step 4 End If
  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 Advanced logic, click Next.
  11. The Build the Decision page opens. Specify the conditional logic and sequence of steps to run when the result of the conditional logic is true.
    Tip: Rest your pointer on a link to display a ToolTip containing the full link description.
    1. Click the link to the right of the If statement to specify the conditional logic in the Condition Designer.
    2. Click the link to the right of the Do step statement to specify the first step in the sequence of steps to run.
    3. Click the link to the right of the To step statement to specify the last step in the sequence of steps to run.
    4. Click Add Else If to insert additional conditional logic. Click the provided links to open the Condition Designer and specify the sequence of steps to run when the condition is true.
    5. Click Add Else to insert additional conditional logic. Use the provided links to specify the sequence of steps to run when the condition is false.
    6. Click Delete to remove any additional conditional logic and sequence of steps. This button only appears after you insert additional conditional logic.
  12. 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.
  13. 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.