从obj获取JavaArray属性

2024-09-29 22:25:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个带有python脚本的套件,可以使用squish测试java应用程序。你知道吗

在我的测试中,我得到一个名为menuObj的对象,其中包含一个名为items的属性,该属性的类型是JavaArray。当我尝试使用getattr()获取该属性时,会得到一个包含属性的对象,而不是这样的列表(或包含列表中项目的字符串)。你知道吗

正确的方法是什么?你知道吗

预期=[MenuItem{Project Ctrl+Shift+D},MenuItem{System Ctrl+Shift+M},MenuItem{Panel}] 获得=包含三个属性。你知道吗


Tags: 对象脚本应用程序类型列表shift属性套件
1条回答
网友
1楼 · 发布于 2024-09-29 22:25:30

当访问属性或调用作为/返回Java数组的方法时,Squish会产生JavaArray。你知道吗

要访问该数组中的元素,请使用JavaArray.at文件(int)方法:

items_array = swtMenuObj.items
test.log("Type of items container/array: %s" % className(items_array))
test.log("A: Item 0 text: %s" % items_array.at(0).text)
// Example output/log entries:
//  JavaArray
//  &File


items_array2 = getattr(swtMenuObj, "items")
test.log("Type of items container/array: %s" % className(items_array))
test.log("B: Item 0 text: %s" % items_array2.at(0).text)
// Example output/log entries:
//  JavaArray
//  &File

对我来说,使用。。。你知道吗

menuObj.items

…还有。。。你知道吗

getattr(menuObj, "items")

…两者都会产生一个JavaArray类型的对象。你知道吗

相关问题 更多 >

    热门问题