Forum Discussion
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
Hi Robert
Thanks for the fast answer, but....
if i use the toArray() function, i get a type mismatch
function test() { var test = Aliases.browser.MainPage.contentDocument.script.csGetControlValue("ctrlInterestRateTypeSleList"); var test1 = test.toArray(); }
TypeError test.toArray is not a function Error location: Unit: "FMP_TC_Suite\FMP_TC_Project\Script\test" Line: 7 Column: 18.
test.toArray is not a function
Error location:
Unit: "FMP_TC_Suite\FMP_TC_Project\Script\test"
Line: 7 Column: 18.
- tristaanogre9 years agoEsteemed Contributor
Just a bit of investigation... drop a break point on the var test1 = line and then bring up the evaluator for your test variable. If you can screenshot that, that would be great. I want to see how TestComplete sees the item.
The other thing to try is that, if you're using JavaScript, getting values of indexed items that are not native JavaScript objects requires the use of the $get method.
So... something else to try is to do the following:function test() { var test = Aliases.browser.MainPage.contentDocument.script.csGetControlValue("ctrlInterestRateTypeSleList"); Log.Message("Value of item 0 is : " + test.$get('0')); }
Even though the code you are calling is a JavaScript method on the page itself, from the previous problem, it's obvious that TestComplete is putting it through some sort of process that masks it as a JavaScript array. I've had this problem myself in a slightly different situation so I think the $get method should work.