QTP10的Reporter对象

QTP10 中, Reporter 对象有了一些改进, ReportEvent 方法中增加了一个参数“ ImageFilePath ”。下面是函数原型描述:

Reporter.ReportEvent EventStatus , ReportStepName , Details [, ImageFilePath ]

Argument

Type

Description

EventStatus

Number or pre-defined constant

Status of the Test Results step:

0 or micPass: Causes the status of this step to be passed and sends the specified message to the Test Results window.

1 or micFail: Causes the status of this step to be failed and sends the specified message to the Test Results window. When this step runs, the test fails.

2 or micDone: Sends a message to the Test Results window without affecting the pass/fail status of the test.

3 or micWarning: Sends a warning message to the Test Results window, but does not cause the test to stop running, and does not affect the pass/fail status of the test.

ReportStepName

String

Name of the step displayed in the Test Results window.

Details

String

Description of the Test Results event. The string will be displayed in the step details frame in the Test Results window.

ImageFilePath

String

Optional . Path and filename of the image to be displayed in the Results Details tab of the Test Results window. Images in the following formats can be displayed: BMP, PNG, JPEG, and GIF.

Notes:

  • Images cannot be loaded from Quality   Center .
  • Including large images in the test results may impact performance.
  • If an image is specified as a relative path, QuickTest will first search the Results folder for the image and then the search paths specified in the Folders pane of the Options dialog box.

 

这样的话就可以在测试步骤的报告中添加截图信息,例如:

Browser("Browser").Page("WebPage").Image("MyLogo").CaptureBitmap("MyLogo.bmp")

Reporter.ReportEvent micDone, "Display Logo", "This is my logo", "MyLogo.bmp"

 

一般在碰到错误时,应该把当前屏幕截一下,以便后面查看测试日志时分析和定位出错的原因,例如下面的代码所示:

validation1 = Browser("Web Tours").Page("Web Tours").Frame("navbar").Image("Login").Exist(0)

If validation1 Then

    Reporter.ReportEvent micPass, "The Login object exists", "The Login object exists"

Else

       Desktop.CaptureBitmap "Fail.png",True

    Reporter.ReportEvent  micFail, "The Login object exists","The Login object doesn't exists","Fail.png"

End if

 

'...

 

validation2 = Browser("Web Tours").Page("Web Tours").Frame("navbar").Image("SignOff Button").Exist(0)

If validation2 Then

    Reporter.ReportEvent micPass, "The LogOut object exists", "The LogOut object exists"

Else

       Desktop.CaptureBitmap "Fail.png",True

    Reporter.ReportEvent  micFail, "The LogOut object exists","The LogOut object doesn't exists","Fail.png"

End if

 

 

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值