Optional steps

Relevant for: GUI tests and scripted GUI components

An optional step is a step that is not necessarily required to successfully complete a run session. For example, suppose that when creating a test or component, you add login steps because the application you are testing prompts you to enter a user name and password in a login window. Suppose, too, that this particular application remembers user login details, so that you do not need to log in every time you open the application. During a run session, the application does not prompt you to enter your user name and password because it retained the information that was previously entered. In this case, the steps that you added for entering the login information are not required and should, therefore, be marked optional.

During a run session, if the object of an optional step does not exist in the application, UFT bypasses this step and continues to run the test or component. When the run session ends, a message is displayed for the step indicating that the step was not performed, but the step does not cause the run to fail.

However, if, during a run session, UFT cannot find the object from the optional step in the object repository (for example, if the object name was modified in the test or component but not in the object repository, or if the object was removed from the object repository), an error message is displayed listing the required object, and the run fails.

During a recording session, UFT automatically marks steps that open certain dialog boxes as optional:

Dialog Box / Message Box Title Bar

AutoComplete

File Download

Internet Explorer

Enter Network Password

Error

Security Alert

Security Information

Security Warning

Username and Password Required

You can also manually designate steps as optional. For example, you can add conditional statements or use recovery scenarios to automatically click a button, press Enter, or enter login information in a step.

To set an optional step:

  • In the Keyword View, right-click the step and select Optional Step.

  • In the Editor, add OptionalStep to the beginning of the VBScript statement. For example:

    OptionalStep.Browser("Browser").Dialog("AutoComplete").WinButton("Yes").Click