Graphical If-Then-Else Comparisons

Document created by Chris Sommerstad Employee on Jul 21, 2017
Version 1Show Document
  • View in full screen mode

In the case of If-Then-Else containers—CloudTest provides the ability to do true comparisons between two values. In prior releases, it was already possible to express: if property has a value equivalent to true. But, regardless of the example—in all cases—you could only specify one thing.

The Comparison row in this releases supports the comparison of two things. For example, "if property is greater than 100".

The Clip Editor container UI for Ifs supports these before and after comparisons with a full offering of If/Switch types, Data Types, Operators, and Predicates around which a comparison can be made.

 

Comparison Data Types

The comparison data types are: Boolean, Text, Integer, Float, and Null.

 

  • If Boolean, is selected, then the next field displays the True/False option.
  • If Text, Integer, or Float are selected, then the next field is an entry field.

  • If Null is selected, then the next field is dropped and the Predicates field is next.

Comparison Predicates

As part of specifying courses of action in making a comparison typical of If statements, the following comparison predicates are available: = (equal), != (not equal to), < (less than), <= (less than or equal to), >= (greater than), and >= (greater than or equal to).

The values defined on either side of these symbols determine the type of comparison being made. Refer to Graphical If-Then-Else Comparisons and Type Conversionfor more about comparison values in CloudTest.

If using a Constant

When Constant is selected in the If drop-down, the comparison syntax shown below appears.

  1. With if Constant selected, specify a data type and assign its value (either true/false for boolean, an entry field for text, integer, or float). If null is the data type no value is specified.
  2. Select a predicate for the comparison.
  3. Repeat the steps to the right of the predicate symbol you chose. All the same fields are available on the right as were available on the left.

If using a Property

When Property is selected in the If drop-down, the comparison syntax shown below appears.

    1. With if Property selected, specify a property to use by double-clicking the blue highlighted text, [not specified].

 

 

The Property Chooser box appears.

  1. Choose a global, system, or custom property from those available, or define a new custom property for this test clip.
    • To select a global property, click the Global Property Lists node in the Chooser’s tree (on the left). Select the global list to use and click OK.

 

    • To select a system property, expand the clip node and locate the object on which the property exists. Typically, this will be either the container or the clip, but it can be anything shown. Once the object is selected in the tree on the left, click the Property Name to use it and click OK.

    • To select an existing custom property, select the object in the tree and then select the custom property from the Custom tab.
    • To enter the property path manually, use the entry form at the bottom of the Property Chooser box.

The property to use appears in the comparison form to the right of Property.

    1. Select a predicate for the comparison.
    2. Repeat the steps to the right of the predicate symbol you chose. All the same fields are available on the right as were available on the left.

For example, in the comparison on the right: If myclipProp is greater than or equal to the constant integer 10, then the comparison passes and the nested clip element, in this case the page, soastastore.com (2), is used. If the Else clause also exists and the comparison fails, then the test will use that clip element instead, in this example--soastastore.com (3).

If using a Linked Script

When Linked Script is selected in the If drop-down, the comparison syntax shown below appears.

    1. With if Linked Script selected, specify a script to use by clicking the Script button and then using the Script Browser to specify the script.
    2. Specify a predicate. For example, greater than or equal to as shown above.
    3. Repeat the steps to the right of the predicate symbol you chose. All the same fields are available on the right as were available on the left.

For example, in the shot on the right if the Linked Script, Check elapsed time, is greater than or equal to the constant integer 10 (seconds), then the first page will play, else the second page will play.

If using an Embedded script

When Embedded Script is selected in the If drop-down, the comparison syntax shown below appears.

    1. With if Embedded Script selected, click the Plus (+) icon and enter or paste the code to use.
    2. Specify a predicate. For example, greater than or equal to as shown above.
    3. Repeat the steps to the right of the predicate symbol you chose. All the same fields are available on the right as were available on the left.

For example, in the shot on the right if the Embedded Script code is greater than or equal to the constant integer 10 (seconds), then the first page will play, else the second page will play.

If using an Accessor

In CloudTest, an accessor makes an action’s return value usable—as a simple output, something to wait on, validate, or to use in a property set. The accessors of an action can be used in the test for various purposes.

For mobile apps and browser UIs, an Accessor option also appears. When Accessor is selected in the If drop-down, the comparison syntax shown on the right appears.

    1. With if Accessor selected, specify a mobile app or browser action accessor to use by clicking from the drop-down and then enter the Locator to use.
      • If the Accessor takes a Locator, enter the Locator to use.

For example, in the shot above if the Locator for the Accessor, elementText, returns a value that is equal to the Case provided for a given action, then that action is used in the switch.

Note:        Ifs using an Accessor are covered in the following section on Graphical If Comparisons.

 

 

  • Some Accessors have no parameters, so there's nothing to enter. For example, isDevicePortrait has no parameters.
  • Some Accessors have more than one parameter, and values for each field must be entered.

    1. Specify a predicate. For example, equal to.
    2. Repeat the steps to the right of the predicate symbol you chose. All the same fields are available on the right as were available on the left.

For example, in the shot above if the Accessor, elementTime, returns a value that is equal to the Constant provided, the comparison passes.

Attachments

    Outcomes