[原创]QTP的在txt中写日志的方法
上一篇 /
下一篇 2007-03-30 18:26:20
/ 个人分类:QTP
就是为了在脚本中出现特殊情况的时候写到txt文件中方便查找。
Public Sub WriteLineToFile(message)Const ForReading = 1, ForWriting = 2, ForAppending = 8Dim fileSystemObj, fileSpecDim currentTimecurrentDate = DatecurrentTime = Time testName = "log"Set fileSystemObj = CreateObject("scrīpting.FileSystemObject")fileSpec ="C:\" &testName& ".txt" 'change this according to your directoryIf Not (fileSystemObj.FileExists(filespec)) Then Set logFile = fileSystemObj.CreateTextFile(fileSpec, ForWriting, True) logFile.WriteLine ("#######################################################################") logFile.WriteLine (currentDate & currentTime & " Test: " & environment.Value("TestName") ) logFile.WriteLine ("#######################################################################") logFile.Close Set logFile = NothingEnd IfSet logFile = fileSystemObj.OpenTextFile(fileSpec, ForAppending, False, True)logFile.WriteLine (currentDate & currentTime & " " & message)logFile.CloseSet logFile = NothingSet fileSystemObj = NothingEnd Sub
相关阅读:
- GetROProperty,GetTOProperties,GetTOProperty的区别 (ghx, 2007-3-26)
- QTP识别和操作对象的原理 (ghx, 2007-3-26)
- Action之间参数传递 (ghx, 2007-3-27)
- 模板的应用 (ghx, 2007-3-27)
- 关于文件的操作 (ghx, 2007-3-29)
- QTP识别和操作对象的原理(转载) (Eagle1983, 2007-3-29)
- 数据表的添加、数据导入、数据导出 (ghx, 2007-3-29)
- [分享]在QTP取得IP地址 (风过无息, 2007-3-29)
收藏
举报
TAG:
QTP