Ask a Question

Return [object Object]

David91
Frequent Contributor

Return [object Object]

Hi, i have a problem with this script. count return value [object Object]... why? Where i do mistake? This script should return ..

I need..

{ "a": 3, "b": 2, "c": 2, "d": 2, "e": 2, "f": 1, "g": 1, "h": 3 }

 

 

my Method

function getDuplicates() {
uniqueCount = ["a","b","c","d","d","e","a","b","c","f","g","h","h","h","e","a"];
var count = {};
uniqueCount.forEach(function(i) { count[i] = (count[i]||0) + 1;});
Log.Message(count)
}

 

Thank you

1 REPLY 1
chriscc
Contributor

Hi @David91.

 

I believe the problem you are having is that testcomplete isn't converting the count object to a string to log as a message.  If you stopped testcomplete during debugging you would see counts' properties/fields and their associated values (first image).  If you want these to log as a string you will need to walk the object's fields (using aqObject.GetFields) and concatenate the field names and field values to a message string, like this...

 

Return [Object Object].jpg

 

The logged messages

Return [Object Object]1.jpg

 

I hope this helps.

Chris
cancel
Showing results for 
Search instead for 
Did you mean: