Questions about Checking Whether an Object Exists
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Questions about Checking Whether an Object Exists
I want to use
"Checking Whether an Object Exists"
https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/checking-existence.html
API for checking weather after clicking a button, the next page shows up right or not.
If a sentence which is supposed to be in the page that I want, it will be "success"
Do you think this is proper use of API?
Acutally I have no experience about this area, I'm really newbie here.
Please let me know if there is better option for checking the right value.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.htm...
Also, take a Test Complete 101 training or see the existing video here for better understanding of Test Complete.
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Bobik I agree, else block will not run if Stop On Error is checked but it will run when Stop On Error is unchecked. 🙂
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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");
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
