Pages

Tuesday, November 13, 2012

Quick Test Professional (QTP) - OptionalStep Object


This is used to make a statement optional in situations where a statement might fail. Consider the below statement:

'Click Yes on the security warning dialog box
Browser("Browser").Dialog("Security Warning").WinButton("Yes").Click

This statement could have been recorded where a security warnings were enabled, but then run on another PC who's browser does not have those warning enabled-in that scenario the statement will fail. So when a statement depends on a system state, it should be maed optional using the OptionalStep object:

'Click Yes on the security warning dialog box
'In case the step fails proceed to nect step without failing the status in the test result summary
OptionalStep.Browser("Browser").Dialog("Security Warning").WinButton("Yes").Click


How to Set Optional Steps from Keyword tab
This task describes how to set an optional step. Do one of the following:
In the Keyword View, right-click the step and select Optional Step. The Optional Step icon is added next to the selected step.




No comments:

Post a Comment