Forum Discussion
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.
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.