Forum Discussion
There is Element which Exists in different Windows or Strategies but in one Window it shouldn't be there and I have chcek that it doesn't exist in that window.
We have a .Exist method to check if the element is there but is there any method or way to check that it is not there?
Thanks
If the .Exists method returns false that means it it not there.
- abrar2210 years agoFrequent Contributor
True. But my Tests script is failing because TestComplete is throwing error that it cant find the element. (see attached)
function vElementNotExists(NameMapAlias) {
{
if(NameMapAlias.Exists==False)
{
Reporter.vCheckpoint("Check Element Not Exists: PASS", "ClassName: " + NameMapAlias.ClrFullClassName + ": Object Not found ", 100 );
}
else
{
Reporter.vError("Check Element Not Exists: Fail", "ClassName: " + NameMapAlias.ClrFullClassName + ": Object found ", 100 );
}
}}
- djadhav10 years agoRegular Contributor
Instead of directly using exists, use WaitAliasChild.
e.g. Instead of saying Loginform.SubmitButton.Exists use Loginform.WaitAliasChild("SubmitButton").Exists
More information here: https://support.smartbear.com/viewarticle/70275/
- Colin_McCrae10 years agoCommunity Hero
If the object doesn't exist, you are trying to log this:
Reporter.vCheckpoint("Check Element Not Exists: PASS", "ClassName: " + NameMapAlias.ClrFullClassName + ": Object Not found ", 100 );
Which I don't think will work as you are trying to retrieve (and write to the log) the classname of an element you have already established does not exist.
Also - you can't always assume Exists alone will cover it. In my current application (Delphi mainly) some elements are destroyed (don't Exist) when not in use. Other are simply hidden. So Exists will still return true, but they are not visible.
So I have a helper function that checks both properties and runs off a timer etc etc.