Forum Discussion
ArtemS
Alumni
14 years agoHi Ravi,
>>Script terminating when it doesn't find an object.
This behavior is determined by one of the "Stop on error" options. In step 1, when TestComplete cannot detect the object corresponding to dialog1, it posts an error and terminates. You can change this default behavior via the project or test item option, see Stopping Tests on Errors and Exceptions topic.
However, a better way is to adjust the dialog detection scheme. You may:
-- Use the WaitWindow method to detect dialogs. Unlike the "ordinary" Window method, WaitWindow does not post an error message on failure and hence does not cause project termination. To check whether the required dialog was actually found, use the Exists property of the returned object.
var dialog1 = p.WaitWindow("*", "Title 1", -1, 1000);
if (dialog1.Exists) testsStepsforDlg1();
var dialog2 = p.WaitWindow("*", "Title 2", -1, 1000);
if (dialog2.Exists) testsStepsforDlg2();
var dialog3 = p.WaitWindow("*", "Title 3", -1, 1000);
if (dialog3.Exists) testsStepsforDlg3();
See Waiting for an Object, Process or Window Activation for details.
-- Specify all three possible dialog titles as conditional mapping criteria and then check the actual title and perform steps specific to dialog1, dialog2 or dialog3.
if (Aliases.CondDialogN.Exists)
{
if (Aliases.CondDialogN.WndCaption="Title 1") testsStepsforDlg1;
if (Aliases.CondDialogN.WndCaption="Title 2") testsStepsforDlg2;
if (Aliases.CondDialogN.WndCaption="Title 3") testsStepsforDlg3;
}
See Using Conditional Mapping Criteria for details.
Regards.