Forum Discussion
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.htmlHi 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.
TypeError
test.toArray is not a function
Error location:
Unit: "FMP_TC_Suite\FMP_TC_Project\Script\test"
Line: 7 Column: 18.In the browser, i get:best regards- 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.