Ask a Question

aqObject.CheckProperty- (checkpoint on Content text) Control does not go to else condition

SOLVED
Gaya
Occasional Contributor

aqObject.CheckProperty- (checkpoint on Content text) Control does not go to else condition

Hi,

 

Is there anything wrong with below code? Control is not going to Else conditon even if the If condition is not true. It just evalutes If condition and throws an error.  

 

Note: Object properties for both are same only the "content text" differs.

 

if((aqObject.CheckProperty(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4, "contentText", cmpEqual, "Order accepted"))==true){
Log.Message("Order Accepted")
}
else{
if(aqObject.CheckProperty(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4, "contentText", cmpEqual, "A pending order already exists.")==true){
//Code goes here
}
}

11 REPLIES 11
RUDOLF_BOTHMA
Community Hero

Two things to look at: The text has to match exact any differences e.g. a "." at the end of the text will return false.  Also, CaseSensitive is an optional parameter  By default the value is true if not specified.  If you add a CaseSensitive of false you may find the value to equate to true:

 

aqObject.CheckProperty(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4, "contentText", cmpEqual, "Order accepted",false)

 

aqObject.CheckProperty Method


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Gaya
Occasional Contributor

Hi,

 

Thanks for your reply. The text is exactly same how it is showing in object properties. I tried the Case Sensitive option as well still did not work.

If condition evaluates to false then the Control should go to else right? but it is not going.

 

I'd Expect so, yes.  

 

A cleaner way of comparing though would probably be

var doesCompare = aqstring.Compare(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4.contentText,"Order Placed",false);

if(deosCompare==0)
{
...
}
else
{
...
}

since contentText is a property of a TC object.

 

When you are doing the check, are you sure the contentText has changed e.g. what does Log(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4.contentText) tell you at each step of the process ?

 

If it' not what you see on the screen, you may be able to Refresh mapping info


-------------------------------------------------
Standard syntax disclaimers apply
Regards,

Also, does the TC object exist when you evaluate.  In other words, what do you get if you stick

Log.Message(Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4.Exists);

just in front of your if statement ?

If it returns false, TC couldn't find it.  It may not be ready on the page or the mapping may have changed because your table structure changed


-------------------------------------------------
Standard syntax disclaimers apply
Regards,

I was just going to suggest that the problem may not be necessarily in the code but in the assumption that the object exists.  You mentioned that there's an error.  What's the error you're getting?


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
Gaya
Occasional Contributor

I tried the Exists option, it did not work as well.

Gaya
Occasional Contributor

The error is "The property checkpoint failed, because Exists does not equal (case-insensitive) "Order accepted". See Additional Information for details. 15:37:46 Normal 10.48". See Additional Information for details. 9:49:37 Normal 10.58

 

which is the condition I gave inside If

@tristaanogre Will probably be able to confirm - I don't use them - but I believe if a checkpoint fails, the test errors and stops.  You won't see any code after the check executing.


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
tristaanogre
Esteemed Contributor

AH!!  I think I see it... you're using the CheckProperty method.  If that returns false, it will log as an error... and if you have "Stop on Error" as true in your project, as soon as that error gets logged, your project stops.

 

So, you can do one of two things....

 

You can just compare the property to the expected value in a strict if case...  something like

 

if (Aliases.browser2.pageFos2.formPlaceorder.tableOrderlist.cellColumn4.contentText == 'Order accepted')

Alternatively, replace CheckProperty with CompareProperty and change the message type to be either a warning or a straight message 

 

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqobject/compareproperty.h...

 

 


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
cancel
Showing results for 
Search instead for 
Did you mean: