cancel
Showing results for 
Search instead for 
Did you mean: 

Validate if object does not exist

SOLVED
Highlighted
New 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;

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Validate if object does not exist

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

View solution in original post

6 REPLIES 6
Highlighted
Community Leader

Re: Validate if object does not exist

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

 

 

Highlighted
Community Hero

Re: Validate if object does not exist

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

View solution in original post

Highlighted
New Contributor

Re: Validate if object does not exist

Thank you.I'll try this way.

Highlighted
Community Manager

Re: Validate if object does not exist

Thank you a lot Community!

 

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


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
New Contributor

Re: Validate if object does not exist

@tristaanogre Thank you, it's works.

Highlighted
Community Manager

Re: Validate if object does not exist

Awesome news @douglasv !

Great job tristaanogreSmiley Happy


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Read the Latest News
JuneSCNJ
Top Kudoed Authors