|
由于项目需要,想实现日志的结构化、层次化写入,在网上找了下,看到很多网友都说可以用如下方法实现:
Call EnterNode("STEP1","初始化环境")
ExitNode context
Call EnterNode("STEP2","结果校验")
ExitNode context
Public Function EnterNode(ByRef NodeName, ByRef NodeContent)
Set dicMetaDescription = CreateObject("Scripting.Dictionary")
dicMetaDescription("Status") = MicDone
dicMetaDescription("PlainTextNodeName") = NodeName
dicMetaDescription("StepHtmlInfo") = NodeContent
EnterNode = Reporter.GetConText()
intContext = Reporter.LogEvent("User", dicMetaDescription, Reporter.GetContext) ‘使用Reporter对象的LogEvent写入新节点
Reporter.SetContext intContext ’调用Reporter对象的SetContext把新写入的节点作为父节点
Set dicMetaDescription = Nothing
End Function
Public Function ExitNode(ByVal intContext)
Reporter.SetContext intContext '调用Reporter对象的UnSetContext,返回上一层
End Function
现在俺实验的结果是,运行到intContext = Reporter.LogEvent("User", dicMetaDescription, Reporter.GetContext) ‘使用Reporter对象的LogEvent写入新节点
就会提示出错”Reporter object required", 我再查QTP的API手册,发现调用.LogEvent 对象应该是个Wshell对象,真是搞糊涂了我,请教各位大虾们,这些是怎么回事呢?
网上原文有:http://www.51testing.com/?57222/viewspace-130651.html 和 http://tech.it168.com/a2008/0806/199/000000199725.shtml,大家帮忙看下 |
|