在RFT中如何通过脚本获取已添加到某个脚本中的测试对象?
来源:互联网 发布:淘宝网狗窝 编辑:程序博客网 时间:2024/05/17 16:43
如何通过脚本获取已添加到某个脚本中的测试对象?(已添加到脚本中的测试对象在脚本资源管理器中的测试对象节点下会列出来。)
下面的脚本将打印Login脚本中的测试对象的相关信息:
Vector vector = new Vector();
vector.addElement (new Login());
Vector testScript = vector;
for(int i = 0; i < testScript.size(); i++)
{
if(testScript.elementAt(i) instanceof RationalTestScript)
{
RationalTestScript ts = (RationalTestScript)testScript.elementAt(i);
IScriptDefinition sd = ts.getScriptDefinition();
Enumeration e = sd.getTestObjectNames();
while(e.hasMoreElements())
{
String currentObjName = (String)e.nextElement();
String role = sd.getRole(currentObjName);
String mapID = sd.getMapId(currentObjName);
String curClassName = (String)ts.getMap().find(mapID).getClassName();
String objClassName = (String)ts.getMap().find(mapID).getTestObjectClassName();
System.out.println(role);
System.out.println(mapID);
System.out.println(curClassName);
System.out.println(objClassName);
}
}
}
输出:
Button
B.JGKG3Ig8tvE:kFGtR:MFnGLmf:8WT
Html.INPUT.submit
GuiTestObject
Text
9.JGKG3Ig8tvE:kFGtR:MFnGLmf:8WU
Html.INPUT.text
TextGuiTestObject
Text
A.JGKG3Ig8tvE:kFGtR:MFnGLmf:8WU
Html.INPUT.password
TextGuiTestObject
其中使用getScriptDefinition 方法来获取IscriptDefinition类型的对象,也就是脚本相关的定义对象,其中就包含测试对象。
Persists the definition about the artifacts associated with the script as an object that implements this interface when the script is created or updated. Object-map information is maintained to improve the resilience of scripts relative to changes in shared object maps. Also, verification points and other assocatied artifacts are managed by the script definition interface.
再通过getTestObjectNames方法来获取测试对象的集合。
Returns an enumerator for the TestObject names associated with a script. Each object returned by the enumerator is a java.lang.String value known to be unique relative to a script.
对于测试对象集合中的每一个元素,通过getRole方法来获取测试对象的角色,通过getMapId来获取测试对象的映射ID。
通过getMap可返回与测试脚本关联的对象映射(object map),再根据MapID,通过find方法查找返回映射的测试对象,然后通过getClassName和getTestObjectClassName返回对象的类型以及测试对象类名。
- 在RFT中如何通过脚本获取已添加到某个脚本中的测试对象?
- 通过RFT命令行执行测试脚本
- RFT测试脚本
- RFT测试脚本
- 自动化测试 - RFT系列教程4: RFT是如何识别控件的(二) 对象库与脚本
- 在RFT中如何获取JTable中的所有数据?
- 在RFT中如何获取JComboBox中的所有项?
- 如何在Shell中通过脚本判断某个服务是否存在的解决方法
- 【Unity】中如何通过GPS获取设备经纬度(测试脚本)
- QTP在录制脚本的时候会将鼠标点击过的对象自动添加到对象库中,而那些未被点击过的对象将不会被添加,导致针对某一对象手动添加的脚本运行不通过,因此需要手动把测试对象添加到对象库中,方法如下:
- 在smarty中通过php脚本获取smarty变量
- 在查询分析器中,通过SQLDMO来得到脚本
- 在查询分析器中,通过SQLDMO来得到脚本
- 在查询分析器中,通过SQLDMO来得到脚本
- RFT脚本执行工具
- RFT 脚本整理
- SQLServer 事务复制中使用脚本添加某个对象的发布
- C# 获取数据库中某个某个表的创建脚本
- c++服务端程序基本结构
- 小小的测试了一下Ycnd 3D
- json格式字符串到json对象转化
- 后天补考,可是只想看电脑书,看不进物理。。。
- Beginning Java AWT and Swing in NetBeans
- 在RFT中如何通过脚本获取已添加到某个脚本中的测试对象?
- OA
- 传智播客——javaWEB开发基础知识
- google ---- mapreduce介绍
- spring mocke
- spring mocke 2
- pls:00201 00304
- 电脑桌面图标被更改(解决)
- 试用版Plarform Builder 6.0到期后的解决办法