Validation variables | Ranorex
HomeUser GuideRanorex Studio AdvancedVariables & parametersValidation variables

Validation variables

Usually, a validation action matches an attribute or content of a UI-element against a constant value. When developing automated data-driven tests based on test data, it might be useful to replace this constant match value with a variable.

In this chapter

    Validation types

    Basically, we distinguish between text- or attribute-based validation and image-based validation. Depending on the validation type, the variable definition is different.

    Validation types

    Validation types

    Example for a text- or attribute-based validation Example for an image-based validation

    Validation match operator

    The validation match operators cannot be automized by variables. The choice of the match operator is fixed for a validation action.

    Validation match operators

    Validation match operators

    Making match name variable

    The matching name is part of the text- and attribute based validation action. The selection of an attribute out of the list of available attributes can be made variable.

    Making match name variable

    Making match name variable

    Match name (in the current example, the match name is a Text attribute)
    List of available attributes for match name selection
    Option to make match name selection variable

    Replacing match value by a variable

    The match value is part of the text- and attribute-based validation. Usually, the match value is a constant value which is matched against the value retrieved by the corresponding UI-element (i.e. repository item). Replacing a match value by a variable is pretty much similar to the specification of recorder variables.

    Replacing match value by a variable

    Replacing match value by a variable

    Select the validation action, open the match value drop-down list and click As new variable…
    Assign the variable a meaningful name and click OK
    See the new match value variable $intDBEntries

    Default match value

    The initially set (i.e. recorded) value is automatically pre-set as default variable value. In our example, the initially recorded text value ‘1’ is therefore set as default value. Default values can be changed at will.

    Default match value

    Default match value

    Note icon

    Note

    The default value is the value which is applied if the variable is not bound to any data. Therefore, it might be important to choose the default value with care.

    Making image-based validation variable

    Making image-based validation variable works pretty similar to the specification of repository variables. Any available attribute of the corresponding validation image can be used for automation purpose.

    Making image-based validation variable

    Making image-based validation variable

    Select the validation action and open the context menu
    Click Make repository item variable…
    Repository variable definition

    Repository variable definition

    Open the drop-down button of the validation image attribute which is to be replaced by a variable (in the current example this is the controlname attribute)
    Assign the variable a meaningful name and confirm with OK
    Click APPLY in the path editor window to end variable specification
    tipp icon

    Hint

    If the application under test is not started and the validation image is not visible, the path editor may be unable to find and identify the validation image. In this case, Ranorex works with an offline and possibly invalid RanoreXPath specification. Therefore, start the application under test and make the validation image visible before defining a validation variable.

    Path editor without / with visible validation image

    Path editor without / with visible validation image

    Path editor not being able to find & identify the corresponding validation image
    Path editor successfully finding & identifying the corresponding validation image

    Further reading

    The details of how to define and specify a repository variable can be seen in > Ranorex Studio advanced > Variables & Parameter > ⇢ Repository variables

    Result(s):

    You can find the result in the repository where the RanoreXPath of the corresponding repository item has been partly replaced by the new repository variable.

    Image-based validation variable

    Image-based validation variable

    Link of repository item in validation action to corresponding repository
    Partly changed RanoreXPath specification with replaced controlname variable

    Validation variable management

    The validation variable management works similar to the variable management of recorder variables and repository variables and is summarized herein shortly.

    Recorder variable management

    Recorder variable management

    Recorder variable management

    Select & open the recording module containing validation variables
    Click the Variables… button in recorder toolbar to open the variable editor
    Note icon

    Note

    Only variables of the current recording module are displayed in the variable editor.

    Variable editor with validation recorder variable

    Variable editor with validation recorder variable

    Variable name(s) with corresponding default value(s)
    Variable editor toolbar

    • Menu to copy & paste a variable to / from the clipboard
    • Option to add a new variable directly
    • Option to remove unused variables (variable cleanup)
    • Option to copy a variable from the repository to the current recording module if existent

    Variable indicator

    • Variable in use: Variable is used, i.e. it is assigned to an action item
    • Variable in use from repository: Variables from the repository show up if a variable repository item is used by the recording
    • Variable not in use: Variable is defined, but not assigned to an action item

    Repository variable management

    Repository variables are managed by clicking the Variables… button in the repository toolbar.

    Opening repository variable management

    Opening repository variable management

    Click Variables… in the repository toolbar
    Note icon

    Note

    All repository variables of the current repository are displayed in the variable editor.

    Repository variable editor

    Repository variable editor

    List of repository variables with variable name and default value
    Variable editor toolbar

    • Menu to copy & paste a variable to / from the clipboard
    • Option to add a new variable directly
    • Option to remove unused variables (variable cleanup)

    Variable indicator

    • Variable in use: Variable is used, i.e. it is assigned to an action item
    • Variable not in use: Variable is defined, but not assigned to an action item