|
2#
楼主 |
发表于 2011-11-26 16:47:03
|
只看该作者
为了方便解决,把对象层和业务层代码粘贴到二楼和三楼
对象层代码:
import resources.GetSurObjHelper;
import com.rational.test.ft.object.interfaces.GuiTestObject;
import com.rational.test.ft.object.interfaces.TestObject;
/**
* Description : Functional Test Script
* @author Administrator
*/
public class GetSurObj extends GetSurObjHelper
{
/**城域监控系统window().
* Script Name : <b>GetSurObj</b>
* Generated : <b>2011-11-25 上午11:50:14</b>
* Description : Functional Test Script
* Original Host : WinNT Version 5.1 Build 2600 (S)
*
* @since 2011/11/25
* @author Administrator
*/
public void testMain(Object[] args)
{
// TODO 在此插入代码
}
//获取顶层对象
public GuiTestObject GetRootObject()
{
TestObject[] tos = null;
GuiTestObject returnObject = null;
System.out.println("开始查找root对象");
tos = find(atDescendant(".name","城域监控系统",".text","城域监控系统"));
System.out.println("tos.length="+tos.length);
//输出所有对象的属性
for(int i=0;i<tos.length ;i++)
{
if(tos[i].getProperty(".class").equals("#32770")&&tos[i].getProperty(".processName").equals("SurveillanceUI.exe"))
{
System.out.println("找到对象");
returnObject=(GuiTestObject) tos[i];
return returnObject;
}
}
if (tos.length > 0)
{
return returnObject;
}
else
{
return null;
}
}
//查找告警台按钮
public GuiTestObject getAlarmButton()
{
TestObject[] tos = null;
TestObject returnObject = null;
GuiTestObject root = new GetSurObj().GetRootObject();
tos = root.find(atList(atDescendant(".class",".Pushbutton",".name","告警台"),atProperty(".text","告警台")));
//输出所有对象的属性
for(int i=0;i<tos.length ;i++)
{
if(tos[i].getProperty(".visible").equals(true))
{
System.out.println("找到对象");
returnObject=(GuiTestObject) tos[i];
return (GuiTestObject) returnObject;
}
}
return (GuiTestObject) returnObject;
}
} |
|