On error resume next

上一篇 / 下一篇  2013-06-03 15:54:34 / 个人分类:功能测试

QTP使用On error resume next使脚本报错后可以继续执行

(2011-03-21 14:11:47)
标签:

it


转载http://www.51testing.com/?uid-197386-action-viewspace-itemid-91560

On error resume next

datatable.GlobalSheet.DeleteParameter "num" '实际Global表中没有num这个字段,运行时会报错.

If err.number <> 0 Then
 createlog "C:\error.txt","Error",err.descrīption
End If

Function createlog(filepath,logtype,logdetail)

'该脚本用于输出LOG

FilePath = filepath  'LOG文件的路径
LOGType = logtype  'LOG的类型
LOGDetail = logdetail  'LOG的内容

Set fso = CreateObject("scrīpting.FileSystemObject")

'判断LOG文件是否存在,如不存在,则按指定路径新建

If fso.FileExists(FilePath) = False Then

         Set LOGFile = fso.CreateTextFile(FilePath, True)

         LOGFile.Close

end if


       Set LOGFile = fso.OpenTextFile(FilePath, 8, True)  '8为追加

       LOGFile.WriteLine("")

       LOGFile.WriteLine(" ---------------------------------------------------------")

  LOGFile.WriteLine(" Time:" & Cstr(Now))

       LOGFile.WriteLine(" Type:" & LOGType )

       LOGFile.WriteLine(" Detail:" & LOGDetail)

       LOGFile.Close

  Set LOGFile = nothing
  Set fso = nothing
End Function


TAG:

 

评分:0

我来说两句

Open Toolbar