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

 

 

 

 

你可能感兴趣的:(object,String,image,validation,browser,login)