Forum Discussion
I think, but I'm not sure, that this is because you are passing a native JavaScript array through to a function that comes from an object in the AUT. While it works just fine through the chrome console (because you are accessing the JavaScript process directly), going through the TestComplete code, I think, requires that array to be passed, not as a native JavaScript array but as a variant array.
Try converting your array first using something like:
function ConvertJScriptArray(JScriptArray) { // Uses the Dictionary object to convert a JScript array var objDict = Sys.OleObject("Scripting.Dictionary"); objDict.RemoveAll(); for (var i in JScriptArray) objDict.Add(i, JScriptArray[i]); return objDict.Items(); }
Again, I could be wrong, but that seems to be the best bet.
- tristaanogre9 years agoEsteemed Contributor
Awesome! Glad to hear it.
The reason why I wasn't quite sure was because that bit of code comes from a help article talking about JScript and native arrays rather than JavaScript. Since, however, they are, essentially, the same (although JavaScript uses a newer engine), I guessed that they would have a similar limitation.
TanyaYatskovska and HKosova, this might be a documentation item that needs updated.Sorry Robert
One additional question please.
Now i have just the opposite situation.
With the function csGetControlValue i get an array, but i cannot read the items.
I think the format of the return value is the same as i have to use for setting the value.
maybe you know a solution for this problem, too?
best regards
- tristaanogre9 years agoEsteemed Contributor
Yup... same help topic... take what you got back and simply get the "ToArray" result from it.
var jscript_array = original_array.toArray();
This will take what you get as a result and turn it back into a JScript/JavaScript native array.
Help topic for this is https://support.smartbear.com/testcomplete/docs/scripting/specifics/jscript.html