Ask a Question

Validate if object does not exist

SOLVED
douglasv
Occasional Contributor

Validate if object does not exist

Hi everyone

I'd like to know if this part of code is the best way to validate if some object does not exist......and if is,  best way to do not waste time to checking it. I don't know it there is a method to check NotExist.

Thank you so much.

var TimeoutValue;
TimeoutValue = Options.Run.Timeout;
Options.Run.Timeout = 1000;
if( (! browseTelaSelecionaControle.Controle15.Exists)&&
(! browseTelaSelecionaControle.Controle95.Exists)){
Log.Checkpoint("Controls are NOT visible");
}
else{
Log.Error("Controls ARE visible");
}
Options.Run.Timeout = TimeoutValue;

6 REPLIES 6
Wamboo
Community Hero

Hi,

 

There is a lot of ways to check for an object in TestComplete, for example:

 

1) .WaitWindow method

2) consider use .findxxx() functions

3) .WaitChild

https://community.smartbear.com/t5/TestComplete-Functional-Web/WaitChild-method-syntax-and-how-does-...

4) .VisibleOnScreen

 

 

tristaanogre
Esteemed Contributor

Technically speaking, you can't check the "Exists" property of an object that doesn't exist because there would be no object to have an Exists property.  This is why the methods of WaitChild, WaitAliasChild, WaitWindow, WaitProcess, etc., were created.  Instead of the code you have, I'd do the following.

 

if( (! browseTelaSelecionaControle.WaitAliasChild('Controle15', 1000).Exists)&&
(! browseTelaSelecionaControle.WaitAliasChild('Controle95', 1000).Exists)){
Log.Checkpoint("Controls are NOT visible");
}
else{
Log.Error("Controls ARE visible");
}

This will wait for the control to exist for up to 1 second and, if it doesn't return within that 1 second, it returns a stub object with only the "Exists" property set to False.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
douglasv
Occasional Contributor

Thank you.I'll try this way.

sonya_m
SmartBear Alumni (Retired)

Thank you a lot Community!

 

@douglasv please let us know whether you managed to solve this!


Sonya Mihaljova
Community and Education Specialist

douglasv
Occasional Contributor

@tristaanogre Thank you, it's works.

sonya_m
SmartBear Alumni (Retired)

Awesome news @douglasv !

Great job tristaanogreSmiley Happy


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: