四、 脚本开发,调试:
框架设计好后就可以分模块开始写Function.一般是一个test中包括多个action,一个action中又包括多个Function. Function写好后就由当前所以action调用,然后各个action又由主action来调用。具体运行哪些action和Function,是由一个单独的驱动控件表来完成。
Script ID Script name Run
1 Login_IMT Y
2 Back_end N
3 Site N
4 Branch Y
6 Agent Y
7 Support Y
另外错误处理一定要做好,要做到真正的无人值守,可以参考如下代码:
这是最上层控制action运行的代码
Dim row
Dim datapath
'存储控制表中记录数
datapath=Environment ("TestDir")& "\FrameData\Framework.xls"
'存储当前控制表路径
row=rowCount(datapath,"IMT")
'依次读取Framework.xls中IMT中记录,来确定要运行的action
For i=2 to row
Err.Clear
On Error Resume Next '出现错误,继续执行后面的操作
'依次调用需要运行的action
If getcell(datapath,"IMT",i,3)<>"N" Then
Runaction getcell(datapath,"IMT",i,2),oneIteration
End If
'如果捕获到错误,则写错误结果到Report
If Err.Number <> 0 Then
Call Report( Err.Number,"FAIL", Err.Description)
End if
Err.Clear
On Error goto 0 '清除错误
Next
测试业务 结果 注释
Login: Login_IMT PASS login in successfully!
Branch: Create branch PASS The branch already exists
Login: Login_IMT PASS login in successfully!
Branch: Create Branch FAIL The "Reset" FlexButton 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.