访问驻留在另一个Object中的Object的属性(Accessing the properties of an Object that resides in another Object)

编程入门 行业动态 更新时间:2024-10-09 23:18:15
访问驻留在另一个Object中的Object的属性(Accessing the properties of an Object that resides in another Object)

我正在使用UFT和VBS,我从JavaScript命令中获取一个返回其他对象的对象,但我无法访问这些对象属性。

详细地:

我在UFT中运行一个命令,它返回SlickGrid表中的所有数据。 该命令是grid.getData(); 并返回一个对象。 此对象设置为对象变量objListArray ,层次结构为:
objListArray (Object) | |---0 (Object) | | | |---Property1 : Value | |---Property2 : Value | |---Propertyx : Value | |---1 (Object) | | | |---Property1 : Value | |---Property2 : Value | |---Propertyx : Value | |---2 (Object) | | | |---Property1 : Value | |---Property2 : Value | |---Propertyx : Value | |---n (Object) | |---Property1 : Value |---Property2 : Value |---Propertyx : Value

无论我尝试什么,我都无法访问对象的属性。 我有什么想法可以访问这些属性? 我仅限于VBS,因为这是UFT脚本。

到目前为止,我试过没有成功:

objListArray(0).Property1 '--> Generic error For Each x in objListArray '--> Object does not support that

返回一般错误的各种其他组合。

I am using UFT and VBS and I am getting an object from a JavaScript command that returns other objects, but I am unable to access these objects properties.

In detail:

I run in UFT a command that returns all the data from a SlickGrid table. The command is grid.getData(); and returns an object. This object is set to object variable objListArray and the hierarchy is:
objListArray (Object) | |---0 (Object) | | | |---Property1 : Value | |---Property2 : Value | |---Propertyx : Value | |---1 (Object) | | | |---Property1 : Value | |---Property2 : Value | |---Propertyx : Value | |---2 (Object) | | | |---Property1 : Value | |---Property2 : Value | |---Propertyx : Value | |---n (Object) | |---Property1 : Value |---Property2 : Value |---Propertyx : Value

No matter what I tried I cannot access the properties of the objects. Any ideas how I can access these properties? I am limited to VBS as this is for a UFT script.

So far I tried without success:

objListArray(0).Property1 '--> Generic error For Each x in objListArray '--> Object does not support that

various other combinations that return a generic error.

最满意答案

在UFT中访问JavaScript数组时出现问题,请参阅我对另一个问题的回答 。

我似乎记得UFT已经解决了问题,所以尝试使用.item ,如果这不起作用,你可以尝试我前面提到的答案的建议。

I realized that the object is of type JScriptTypeInfo

In order to access it I can use the bellow:

objListArray.[0].Property1

Now, to iterate through the Object you can do it like that:

For i = 0 To objListArray.Length-1 x = eval("objListArray.[" & index & "].[Account Number]") 'Do anything you want with x Next

更多推荐

本文发布于:2023-07-30 14:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1338771.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   Object   Accessing   resides   properties

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!