Optional Steps in UFT

. 2 mins read

Optional Steps in UFT

While automating with UFT, we face scenarios where a step is not necessarily required to complete a run session successfully.

Consider a scenario where you add login steps to your code because the application you are testing prompts to enter a username and password in a login window. Consider also that this 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 previously entered. In this case, the steps that you added for entering the login information are not required. We should mark these steps optional.

Once these steps are marked optional, during the subsequent run sessions, 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. At the end of the run session, UFT displays a message for the optional step, which it did not execute. Nevertheless, the step does not cause the run to fail.

However, run fails if UFT cannot find the object from the optional step in the object repository during a run session. This can happen due to object name modification in the test or component but not in the object repository, or if the object was removed from the object repository.

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

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

Default Optional Steps in QTP / UFT

By default, UFT considers steps that open the following dialog boxes or message boxes as optional steps:

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

How to Set Optional Steps in UFT?

To set optional steps, do one of the following

Option 1

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

Option 2

In the Editor, add OptionalStep to the beginning of the VBScript statement. For example: OptionalStep.Browser("Browser").Dialog("AutoComplete").WinButton("Yes").Click

Software Testing
Drag and drop items from windows explorer to application UFT
08 Aug 2016

Subroutine to drag and drop item from windows explorer to application using UFT or QTP. By default this feature is not yet available in QTP or UFT.

Software Testing
Reporting Modes in UFT
21 May 2015

Reporter object in UFT has different reporting modes. This post discusses about various mode available in reporter object.

Software Testing
UFT Function to Select an item from a WebList or WinComboBox
24 Nov 2013

UFT/QTP Function to select an item form WebList or WinComboBox. It selects a list item specified in the function call, reports pass or fail.