An optional step is a step that is not necessarily required to successfully complete a run session.
During a run session, if the object of an optional step does not exist in the application QTP bypasses this step and continues to run the test
To set a step as optional in keyword view right click on the step and select Optional Step
Alternatively, you can directly write the keyword "OptionalStep" preceding a statement to make it optional
Syntax
OptionalStep.StatementToMakeOptional
Example
The following example uses the OptionalStep object to make the Paris selection from the Depart WebList an optional step.
OptionalStep.Browser("Mercury Tours").Page("Find Flights").
WebList("depart").Select "Paris"
During a run session, if the object of an optional step does not exist in the application QTP bypasses this step and continues to run the test
To set a step as optional in keyword view right click on the step and select Optional Step
Alternatively, you can directly write the keyword "OptionalStep" preceding a statement to make it optional
Syntax
OptionalStep.StatementToMakeOptional
Example
The following example uses the OptionalStep object to make the Paris selection from the Depart WebList an optional step.
OptionalStep.Browser("Mercury Tours").Page("Find Flights").
WebList("depart").Select "Paris"