By default, QuickTest Professional deems steps that open the following dialog boxes or message boxes as Optional Steps:
Dialog Box / Message Box Title Bar
Enter Network Password
Username and Password Required
1. To COMPLETE a Run session an optional step is not necessarily required.
2.If a Step in an optional dialog box does not open, QTP avoids that step and continues ahead during a Run session. At the end of the Run session, a message is displayed for the step that failed to open the dialog box. Here remember that the step does not cause the Run to fail.
3. However if QTP does not find an Object from the optional step in the Object Repository, then the Run fails with an error message.
You can also add an optional step in the Expert View by adding OptionalStep to the beginning of the VBScript statement. For example:
OptionalStep.Browser("Browser").Dialog("AutoComplete").WinButton("Cancel").ClickThis is an Optional step icon
A simple example for Optional Step:
1. Make sure that a new blank test and a blank Internet Explorer window is open.
2. In QTP click on Record in order to start recording.
3. Go to Start-> Programs-> QuickTest Professional->Sample Applications-> Flight.
4. Enter Username.
5. Enter Password.
6. Hit the enter key.
7. When the Flight application is open go to File->Exit.
8. Close the Internet explorer window also from the Cross button which is on the extreme top right..
9. Click Stop to stop the test recording.
In the Keyword view, follow the below steps:
Finally it looks like this
Now before you run the test make sure Internet Explorer window is NOT open.
The idea is when you run the above test without IE, it will not show any error message or fail, it will just bypass the ‘browser closing’ step as we have marked it Optional and it will ignore any error for the optional step. But it shows you the warning in the test results.
Try to run the same test by just removing the ‘Optional Step’ tag from the above lines and see that it will fail and show you the Run Error.
QTP SystemUtil Vs InvokeApplication
QTP Relative Path
QTP Random Variables
QTP Crypt Object