Ask a Question

How to handle if not finding on objects is not an error

cagan
Occasional Contributor

How to handle if not finding on objects is not an error

I have a teststep for saving a file. On windows you know how to save as works. It can directly  save or a pop-up window asks you do you want to overwrite with same name. Briefly, a file can be directly saved or it can overwrite. Both option is applicable for me.

 

So i don't want to take en error when save as window is appeared on the screen. Below code takes error like "Cannot obtain the window with the windowclass...." How can i fix the problem? Thank you

 

var saveAsWindow= Saveasobject

if (saveAsWindow.Exists)

{object.clickbutton();

Log.Message("overwritten button is selected.")

}

else

Log.message("overwritten window is not appeared.  Because it is a new file.")

6 REPLIES 6
mattb
Staff

Re: How to handle if not finding on objects is not an error

Hi,

A list of possible cause of the problem can be found here: https://support.smartbear.com/testcomplete/docs/testing-with/running/handling-errors/object-not-foun... 

Are we able to identify an object within the pop up? 

Best,
Matt 

cagan
Occasional Contributor

Re: How to handle if not finding on objects is not an error

Hi,

 

The error is not important to me because it is not an error for me. Because of TestComplete cannot find the related variable it takes error but i wonder how can i handle to don't take an error. I also tried TRY-CATCH but it still idenfied being as an error.

mattb
Staff

Re: How to handle if not finding on objects is not an error

I wonder if it is failing because the pop up is not in focus. 

If we add a setfocus method to the parent level of the tested object, that may help force TestComplete to identify the parent level, and therefore the child object. 

Example scripts can be found here: https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/window-and-process/se... 

cagan
Occasional Contributor

Re: How to handle if not finding on objects is not an error

Hi, is there anyting like that if a pop-up opens then click OK button, else just write a informative log and don't do anything. Because of popup object is set, TestComplete see it being as error. 

mattb
Staff

Re: How to handle if not finding on objects is not an error

I would also see what settings on the current project properties to handle unexpected windows. Check within current project properties, and then playback.

https://support.smartbear.com/testcomplete/docs/working-with/managing-projects/properties/playback.h... 
https://support.smartbear.com/testcomplete/docs/testing-with/running/handling-errors/unexpected-wind...

 

Maybe we are deleting the window before we can interact with it. 

React
Visitor

Re: How to handle if not finding on objects is not an error

@caganYou may look at this.

I came to similar problem when I didn't know if window will appear but still I must search for it.
My solution was to use FindEx method to search the object because it will return Exists property equals false if it will not found it.
No error will be raised and you can set the timeout so method will be quite fast.

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/findex...

var object = findEx()

if (object.exists == false) Log.Message('Windows is not here, so no futher operqations needed');
else {
  Log.Message('Found the window,');
  CloseAdditionalPopup();
}

cancel
Showing results for 
Search instead for 
Did you mean: