Skip to end of metadata
Go to start of metadata

An If...Then condition will execute its child objects if a given condition is true (or false). There are multiple types of conditions that are described below.

Creating a condition

To create an If...Then condition, follow the following steps:

  1. Go to the Build Test Case node.
  2. Select the starting object
  3. Right mouse click to open the Context Menu and click Create Container -> Create If...Then.
  4. A new object dialog will appear.
  5. Select the last object in the condition.
  6. Click Create If...Then.

Quick create

Another way to create a loop is to select multiple objects; the test case tree -> right-click -> select Create If...Then. This will create an If...Then around the selected objects.

Condition types

There are 3 condition types:

  • Compare expressions
  • Match extractor (deprecated)
  • Match scriptable variable (deprecated)

    Note:

    Starting from v5.4, the preferred condition type is Compare expressions. Match extractor and Match scriptable variable have been deprecated.

Compare expressions

This type compares 2 expressions using a specified operand. An expression is a combination of text and/or variables.

  • In the Condition type property, select Compare expressions
  • In the Left expression and Right expression properties, enter expressions to compare. To insert a variable, hit the down arrow in the property grid to bring up the variable picker.

  • In the Compare operator property, select the operator to use to compare left and right expressions. The available operators are:
    • =: Returns true if left and right expressions return the same value.
    • >: Returns true if the left expression returns a value that is greater than the value returned by the right expression. 
    • >=: Returns true if the left expression returns a value that is greater than or equal to the value returned by the right expression.
    • <: Returns true if the left expression returns a value less than the value returned by the right expression. 
    • <=: Returns true if the left expression returns a value that is less than or equal to the value returned by the right expression.
    • Contains: Returns true if the left expression returns a value contained in the value returned by the right expression.
    • Starts with: Returns true if the left expression returns a value that starts with the value returned by the right expression.
    • Ends with: Returns true if the left expression returns a value that ends with the value returned by the right expression.
    • Exists: Returns true if the left expression's value is not empty and has a length greater than 0. Use this operand to test if an extractor is found.
  • In the Run the child objects if Compare condition is True? property select Yes to run the child objects when the expression comparison evaluates to true, and skip the child objects when the expression comparison evaluates to true. Select No to run the child objects when the expression comparison evaluates to false, and skip the child objects when the expression comparison evaluates to true.

An example below shows a condition that will run the child objects when the value of an extractor UsernameToken equals the value of a dataset column Credentials.Token.

Match Extractor (deprecated)

This type compares an extractor's value to a constant string.

  • In the Condition type property, select Match Extractor 
  • In the property Extractor to match, select an extractor of the drop-down to compare with the string.  The extractor must be defined before the If...Then object

  • In the property Text-to-match, enter a string to compare with the extractor.
  • In the property Run the child objects if Match? select Yes to run the children when the extractor matches the Text-to-match value, and skip the children when the extractor does not match the Text-to-match value. Select No to skip the children when the extractor matches the Text-to-match value, and run the children when the extractor does not match the Text-to-match value

Match scriptable variable (deprecated)

This type compares a scriptable variable return value to a constant string.

  • In the Condition type property, select Match scriptable variable
  • In the property Scriptable variable to match, select a scriptable variable of the drop-down to compare its value with the string.
  • In the property Text-to-match, enter a string to compare with a value of the scriptable variable returned by the IExternalVariable.GetValue() method.
  • In the property Run the child objects if Match? select Yes to run the children when the scriptable variable's value matches the Text-to-match value, and skip the children when the scriptable variable's value does not match the Text-to-match value. Select No to skip the children when the scriptable variable's value matches the Text-to-match value, and run the children when the scriptable variable's value does not match the Text-to-match value.

Action if child objects are skipped

Some conditions are critical, and if they fail, then the iteration can't continue. Set the Action when child objects are skipped property to specify the action to execute when the condition fails, and the child objects are skipped. 

  • Continue - To continue the iteration.

  • Abort iteration - To stop the current iteration and start a new one

  • Abort vu - To stop sending requests from this VU.


  • No labels