Ask a Question

CheckProperty

SOLVED
sandeep7972
Occasional Contributor

CheckProperty

Hi 

Im creating a script in JavaScript to verify the details of a page in a Desktop application.

I would like to know how to check that the caption of an object is one of the value we have.

For example, in a 'status' field, we know that there should be one of the following values. New, Completed, In progress, closed. 

So what i tried is the following script

aqObject.CheckProperty(Object, "Caption", cmpEqual, " New"||"Completed"||" In progress"||" closed");

 

This script passes if the status value in the page is 'New'. If its anything else it fails. Please advise me on any possible methods to tackle this.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
mattb
Staff

Re: CheckProperty

Hi try this

aqObject.CheckProperty(Object, "Caption", cmpIn, " New Completed In progress  closed");

View solution in original post

5 REPLIES 5
mattb
Staff

Re: CheckProperty

In the script it seems like you use an Equals condition. I would change that condition to be contains. 

https://support.smartbear.com/testcomplete/docs/testing-with/checkpoints/property/creating.html Step 3 point 3 highlights the condition.

Best,
Matt 

sandeep7972
Occasional Contributor

Re: CheckProperty

Thanks for the reply. But thts not what im exactly looking for. im looking for the code i can use so that the test will pass if the caption equals  any one of the given values. 

mattb
Staff

Re: CheckProperty


Ok, So a passing validation in your case would be if the status field contains: 

"New"
"Completed"

"In Progress" 
"Closed"

So with the condition cmpEquals the checkpoint = "Completed" would fail as expected. 

If we were to use cmpContains, we would simply search within that status field object for any text that matches "Completed" and the test would pass. 


If contains doesnt work, I would still look at the available conditions. Though I believe the code we are looking for is: 

aqObject.CheckProperty(Object, "Caption", cmpContains, " New"||"Completed"||" In progress"||" closed");


Here is the list of available conditions: https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqobject/compareproperty.h... 

mattb
Staff

Re: CheckProperty

Hi try this

aqObject.CheckProperty(Object, "Caption", cmpIn, " New Completed In progress  closed");

sonya_m
Community Manager

Re: CheckProperty

Thanks a lot Matt! @sandeep7972 please let us know if this solved the issue! 


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: