Variables of the Password Type

Applies to TestComplete 14.40, last modified on April 22, 2021

This topic describes project, project suite and keyword test variables of the Password type. The topic contains the following sections:

About Password Variables

Projects, project suites and keyword tests can have variables of the Password type. These variables store an encrypted string that can be used by the SetText and Keys methods to simulate input of encrypted data. The values of these variables can be used by these methods only. You cannot use these values in any other way.

The behavior of variables of this type differs from the behavior of other variables:

  • Only the SetText and Keys methods can properly access the values of Password variables. Other methods get a special variable moniker and the path to the variable instead of the variable value itself.

  • When the SetText or Keys method inputs the value of a Password variable in a control, neither the value, nor the image of the control containing the value is posted to the test log.

  • Password variable values are masked by special symbols in TestComplete.

  • On the Variables page of the Keyword Test, Project or Project Suite editor, you can only reset a Password variable; there is no way to edit its value.

Creating Password Variables

You can create Password variables in several ways:

  • During test recording, password variables are created automatically when you type passwords into password controls. In this case, TestComplete stores the entered password values in password variables:

    Recording Passwords

    Click the image to enlarge it.

    If your passwords are recorded as text stings and are not masked in tests, make sure the Tools > Options > Engines > Recording > Record text input into simple editors as option is set to SetText (the default value).

    For more information, see Recording Passwords.

  • You create password variables and set their values by using the Add Variable or Add Variable to Keyword Test wizard or on the Variables page of the project, project suite or keyword test editor.

    To create a new password variable, right-click within the page and choose New Item from the context menu.

  • You can create a password variable programmatically during the test execution. For this purpose, you can use the Variables.AddVariable method.

    Note: It is recommended to avoid storing passwords as plain text in your scripts. You can create a user form or use the BuiltIn.InputBox method to ask the user to enter a password.

    JavaScript, JScript

    Project.Variables.AddVariable("PasswordVar", "Password");

    Python

    Project.Variables.AddVariable("PasswordVar", "Password")

    VBScript

    Project.Variables.AddVariable "PasswordVar", "Password"

    DelphiScript

    Project.Variables.AddVariable('PasswordVar', 'Password');

    C++Script, C#Script

    Project["Variables"]["AddVariable"]("PasswordVar", "Password");

See Also

Variable Data Types
Using Variables
Project And Project Suite Variables
Working With Project and Project Suite Variables in Scripts
Working With Passwords and Other Sensitive Data

Highlight search results