【问题标题】:How to get value out of .getProperty('style")如何从 .getProperty('style") 中获取价值
【发布时间】:2012-05-08 05:08:06
【问题描述】:

.getProperty("style") 输出TestObject(Ref:RemoteProxyReference{testContext:af4e390002a336, objectId:3171, testObjectClass:TestObject})

to[0].getProperties() 输出文本哈希,其中出现关键“样式”{... , style=DISPLAY: none, oncontrolselect=null Object, rowSpan=1, .....}

如何获取key style属性的值?

这是我的代码示例...

TestObject[] to=null;
RegularExpression findRegExp1 = new RegularExpression(find_arguments[1], false) ;
RootTestObject root = getRootTestObject();
to = root.find(atDescendant(find_arguments[0],findRegExp1),false);

System.out.println(to[0].getProperty("style"));
System.out.println( to[0].getProperties()); 

这两种方法都是标准的 RFT 方法。更多信息IBM Rational Functional Tester API Reference

【问题讨论】:

  • 从您的代码示例中可以看出,getProperty()root.find(...) 返回的任何类型的自定义方法。如果没有至少 getProperty() 的代码,没人能帮助你。
  • @Jim:更新了我的问题。这两种方法都是标准的 RFT 方法。调试时我看不到 getProperty("style") 的值。

标签: java rft


【解决方案1】:
System.out.println(to[0].getProperty("style"));

这会在 to[0].getProperty() 的值上调用 toString()getProperty() 返回的对象可能具有检索各种属性(例如文本值)的方法,但会生成您看到的简单toString() 的输出。

您将不得不在 RFT 文档中对此进行研究,以确定哪种方法可以提供您想要的数据。

【讨论】:

  • Returns the value of the specified property. If the property type is not a value class, getProperty registers the object in the software under test and returns a reference to the object. Registered object references are released by calling one of the unregister methods. 嗯。如何访问创建的对象 getProperty("style")?
  • 你必须弄清楚对象的类型。您尚未在代码中显示 to 的声明。
  • 声明为TestObject[] to=null;。我怎么知道?
  • TestObject上的方法是什么?
【解决方案2】:

我认为“stlye”是一个非值属性。 正如文档所述:http://publib.boulder.ibm.com/infocenter/rfthelp/v7r0m0/index.jsp?topic=/com.rational.test.ft.api.help/ApiReference/com/rational/test/ft/object/interfaces/TestObject.html

您可以通过调用 getNonValueProperties() 找到非值属性。您可以使用 getProperty 方法来访问值和非值属性。 如果您访问非值属性,该属性将返回一个 TestObject,其中包含对被测软件中(非值)对象的引用

无法访问该属性的内容。

打开测试对象检查器并查看“样式”是否在非值属性面板

我刚刚在一个页面上尝试使用 IE6,但无法读取“样式”属性。

【讨论】:

    【解决方案3】:

    我在 IBM 支持下开了一张票,这是最终答案:

    "我已经在你的网站上做了测试,确认了getProperty("style")的输出。这是一个bug,已经在RFT8.2.1.1中修复了。我确认了RFT 8.2中的getProperty方法.1.1 运行良好。"

    【讨论】:

      猜你喜欢
      • 2017-10-01
      • 2018-04-07
      • 2021-12-26
      • 1970-01-01
      • 2016-08-24
      • 2012-11-29
      • 2018-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多