|
7#
楼主 |
发表于 2006-12-15 14:52:52
|
只看该作者
我试着分别用QTP和Robot录制了段同样的脚本,比较了一下,感觉可读性还是差别很大啊,大家可以自己对比一下后面的脚本。
另外,对Edit、ComboBox、List等本身没有文字的对象,Robot为什么不会象QTP那样自动用其左边的标题文字来识别呢?都是用index来识别,阅读代码时怎么知道是哪个按钮啊,可读性差,又容易出错。
QTP:
JavaWindow("拓扑管理").JavaMenu("配置").JavaMenu("创建网元").Select
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaEdit("网元名称(*)").Set "111"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaList("网元类型").Select "CE"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaList("软件版本").Select "222"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaList("硬件版本").Select "333"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaEdit("IP地址").Set "4"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaEdit(".").Set "5"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaEdit("._2").Set "6"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaEdit("._3").Set "7"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaEdit("SNMP端口号").Set "888"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaList("SNMP版本号").Select "v2c"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaList("getCommunity").Select "99"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaList("writeCommunity").Select "100"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaEdit("位置信息").Set "111"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaEdit("描述").Set "222"
JavaWindow("拓扑管理").JavaDialog("添加网元").JavaButton("取消").Click
Robot:
Window SetContext, "Caption=拓扑管理", ""
JavaMenu MakeSelection, "JavaCaption=拓扑管理\;Type=JavaMenu;Index=1;Path=配置", ""
JavaMenu Click, "JavaCaption=拓扑管理;\;Type=JavaMenu;Index=1;Path=配置->创建网元", ""
Window SetContext, "Caption=添加网元", ""
InputKeys "111"
Browser SetApplet,"JavaCaption=添加网元",""
ComboBox Click, "Type=ComboBox;Index=1", ""
ComboListBox MakeSelection, "Type=ComboListBox;Index=1", "Text=CE"
ComboBox Left_Drag, "Type=ComboBox;Index=2", "Coords=63,8,-18,7"
InputKeys "222"
ComboBox Left_Drag, "Type=ComboBox;Index=3", "Coords=69,10,-43,9"
InputKeys "333"
EditBox DblClick, "Type=EditBox;Index=2", "Coords=31,9"
InputKeys "4{RIGHT}{DELETE}5{RIGHT}{DELETE}6{RIGHT}{DELETE}7"
EditBox Click, "Type=EditBox;Index=6", "Coords=51,14"
InputKeys "{BKSP}{BKSP}{BKSP}8"
ComboBox Click, "Type=ComboBox;Index=4", ""
ComboListBox MakeSelection, "Type=ComboListBox;Index=4", "Text=v1"
ComboBox Click, "Type=ComboBox;Index=5", "Coords=57,10"
InputKeys "9"
ComboBox Left_Drag, "Type=ComboBox;Index=6", "Coords=52,10,-32,13"
InputKeys "10"
EditBox Click, "Type=EditBox;Index=8", "Coords=20,7"
InputKeys "11"
EditBox Click, "Type=EditBox;Index=9", "Coords=35,22"
InputKeys "12"
PushButton Click, "Type=PushButton;Name=取消" |
|