Forum Discussion
Hi,
Basically, you want check whether an object displayed in the screen or not. This doesn't require any API if you are using Test Complete.
you can use like below,
function testSample()
{
if(Sys.Process("notepad").Exists)
{
Log.Message("Object exists in the screen");
}
else
{
Log.Error("Object not exists");
}
}
To verify the object property you can use https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqobject/checkproperty.html
Also, take a Test Complete 101 training or see the existing video here for better understanding of Test Complete.
Correct code:
function testSample()
{
if(Sys.WaitProcess("notepad").Exists)
{
Log.Message("Object exists");
}
else
{
Log.Error("Object not exists");
}
}Call Sys.Process("notepad") will cause an error when object doesn't exist. And script will fail before your "Else" block. So you have to use "WaitProcess" method.
- shankar_r9 years agoCommunity Hero
Bobik I agree, else block will not run if Stop On Error is checked but it will run when Stop On Error is unchecked. :)
- LupitaM8 years agoNew Member
I am trying to verify the date object exists on a window. I am using the following and getting that the object is not found. Do I need to use the WaitProcess?
if (Sys.WaitProcess("DateEdit").Exists)
{
Log.Message("Date Range is present");
}
else
{
Log.Error("Date Range is not present");
}- AlexKaras8 years agoCommunity Hero
Hi,
> Do I need to use the WaitProcess?
You need to read documentation.
As the name assumes, WaitProcess() waits for the process to become available in the system.
Considering the provided name (DateEdit) you need to search for the date edit control. Depending on the control's class and whether or not you are using NameMapping (and Aliases), you need to use either one of the WaitXXX() methods, of Find() one or WaitAliasChild().
Check documentation for the mentioned methods and related help articles for more details and better understanding of how TestComplete works.
P.S. Recordings from the https://support.smartbear.com/screencasts/testcomplete/ web page might be useful as well.