现在的位置: 首页 > 综合 > 正文

ReportEvent的用法

2013年05月21日 ⁄ 综合 ⁄ 共 1118字 ⁄ 字号 评论关闭

一直在坚持看买的这本QTP书,看了一半了,嘿嘿,不错,夸夸自己。。。好了,进入正题。。。

今天看到“报告实例”了,里面有一个函数ReportEvent是运行脚本过程中添加一个事件到test results,具体用法在QTP中按F1搜索ReportEvent这个函数就行,写的很清楚,不过是不是有的人一看就晕,不想看呢,因为全是英文。。。呵呵

 

格式:Reporter.ReportEvent EventStatus, ReportStepName, Details [, in]
'EventStatus
状态:pass0,失败:1done:2,警告:3
状态:0 or micPass1 or micFail2 or micDone3 or micWarning:
ReportStepName
Name of the intended step in the report (object name)
Details:Description of the report event. The string will be displayed in the step details frame in the report.

 

可以用QTP自带的flight订票系统来试验一下:

Window("Flight Reservation").Activate'激活订票系统窗口
Window("Flight Reservation").WinMenu("Menu").Select "Analysis;Reports..."'选择菜单栏中的analysis——>reports

window("记事本").Close'关闭报告'

 

然后再给脚本添加个条件判断语句:

Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "Analysis;Reports..."
If window("记事本").Exist Then
 reporter.ReportEvent micPass,"报告","报告生成并被打开"
 window("记事本").Close'关闭报告'
else
reporter.ReportEvent 3,"报告","报告未被打开"
End If

 

回放一下看看效果

再看看,在results里面是不是添加了一个事件

看到了吗?左边第一个画圈的是

---

Reporter.ReportEvent EventStatus, ReportStepName, Details [, in]
reporter.ReportEvent micPass,"报告","报告生成并被打开"

--
中的ReportStepName,最右边那个Details

这下明白了吗?

抱歉!评论已关闭.