标题: 求助:如何在录制的脚本中添加条件语句 [打印本页] 作者: urral 时间: 2006-4-19 10:12 标题: 求助:如何在录制的脚本中添加条件语句 目的:在用户表中添加若干用户,如果是新用户直接添加成功,如果是已经存在的用户,需要对弹出的对话控点击确认,"cansel"这一次添加后继续添加.
录制的添加一个新用户的脚本:
JavaWindow("System User Management").JavaButton("add").Click
JavaWindow("System User Management").JavaDialog("Create New User").JavaTab("JTabbedPane").Select "General"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Account").Set DataTable("p_Text", dtGlobalSheet)
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Account").PressKey "C",micCtrl
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Real Name").Set "123456"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Cert Number").Set "123456"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Phone").Set "123456"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Address").Set "123456"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Comments").SetCaretPos 0,0
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("New Password").SetSecure "44442ece631adb03dffd54fd9d113ff499f2"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Confirm Password").SetSecure "44442ed24b0a7d6eac859b00ebcc3d0a3172"
JavaWindow("System User Management").JavaDialog("Create New User").JavaTab("JTabbedPane").Select "Role"
JavaWindow("System User Management").JavaDialog("Create New User").JavaButton("addall_grey").Click
wait 2
JavaWindow("System User Management").JavaDialog("Create New User").JavaButton("commit").Click
录制的添加已经存在的脚本时在上面脚本的基础上需要执行的动作:
JavaWindow("System User Management").JavaDialog("Create New User").JavaDialog("Create New User Error").JavaButton("ok").Click
JavaWindow("System User Management").JavaDialog("Create New User").JavaDialog("Create New User Error").Close
JavaWindow("System User Management").JavaDialog("Create New User").JavaButton("cancel").Click
问题: 如何将后面这部分脚本用条件语句加入到前面脚本中?谢谢作者: urral 时间: 2006-4-19 10:14
"录制的添加已经存在的脚本时在上面脚本的基础上需要执行的动作:"
应该是"录制的添加已经存在的用户时在上面脚本的基础上需要执行的动作:"作者: 我要做SQAD 时间: 2006-4-19 10:21
JavaWindow("System User Management").JavaButton("add").Click
JavaWindow("System User Management").JavaDialog("Create New User").JavaTab("JTabbedPane").Select "General"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Account").Set DataTable("p_Text", dtGlobalSheet)
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Account").PressKey "C",micCtrl
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Real Name").Set "123456"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Cert Number").Set "123456"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Phone").Set "123456"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Address").Set "123456"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Comments").SetCaretPos 0,0
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("New Password").SetSecure "44442ece631adb03dffd54fd9d113ff499f2"
JavaWindow("System User Management").JavaDialog("Create New User").JavaEdit("Confirm Password").SetSecure "44442ed24b0a7d6eac859b00ebcc3d0a3172"
JavaWindow("System User Management").JavaDialog("Create New User").JavaTab("JTabbedPane").Select "Role"
JavaWindow("System User Management").JavaDialog("Create New User").JavaButton("addall_grey").Click
wait 2
if JavaWindow("System User Management").JavaDialog("Create New User").JavaDialog("Create New User Error").exist(3) then
JavaWindow("System User Management").JavaDialog("Create New User").JavaDialog("Create New User Error").JavaButton("ok").Click
JavaWindow("System User Management").JavaDialog("Create New User").JavaDialog("Create New User Error").Close
JavaWindow("System User Management").JavaDialog("Create New User").JavaButton("cancel").Click
End if
JavaWindow("System User Management").JavaDialog("Create New User").JavaButton("commit").Click作者: urral 时间: 2006-4-19 10:54
谢谢,不过运行的时候出现如下错误:
The test run cannot continue due to an unrecoverable error.
The "Create New User Error" object was not found in the Object Repository.
Check the Object Repository to confirm that the object exists or to find the correct name for the object.作者: urral 时间: 2006-4-19 10:55
是运行到if JavaWindow("System User Management").JavaDialog("Create New User").JavaDialog("Create New User Error").exist(3) then 这一行的时候作者: urral 时间: 2006-4-19 11:05
再解释一下哈:
我的问题应该这样描述才对:在只录制添加一个新用户的情况下通过修改脚本(加入条件语句)达到涵盖用户已经存在的情况.作者: 我要做SQAD 时间: 2006-4-19 13:41
JavaDialog("Create New User Error")这个Dialog在对象仓库中没有吧,你用"Add Object"把他加到对象仓库中,或者自己把这个对象描述出来。