Forum Discussion

ravisangam's avatar
ravisangam
Occasional Contributor
13 years ago

Script terminating when it doesn't find an object

Script terminating when it doesn't find an object. I mean, once we clicked on "submit" button in flex application, it may raise 1 of 3 dialogue boxes. Those 3 dialogue controls are same, but the number of buttons, text it contains varies. TestComplete object spy detecting 3 dialogues as same. The thing is i am checking that,



Step 1: if dialogue 1 exists then do some thing..

Step 2: if dialogue 2 exists then do some thing..

Step 3: if dialogue 3 exists then do some thing..



But, if dialogue2 is popped up, when i clicked on Submit. TC is checking failing at the 1st step itself. It is not moving to 2nd check

  • Hi 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.