Reporter.ReportEvent Statement is used to send desired events (like Pass, Fail, etc) and custom messages in the run results of UFT.
ReportEvent Method in UFT
1 |
Reporter.ReportEvent micPass,"Flight Booking Order","The order placed successfully" |
Or you can also write it in the following way:
1 |
Reporter.ReportEvent micPass,"Flight Booking Order should be placed","Flight Booking order placed succesfully" |
Using the numeric value for EventStatus
‘Reporting a fail step
1 |
Reporter.ReportEvent 1,"Flight Booking Order should be placed","Flight Booking order was not placed" |
Capture Error Screenshot using ReportEvent
You can capture screenshots in Run Results for all EventStatus.However, capturing screenshots for every EventStatus is not advisable because it will take huge space in the hard drive and it may impact the performance as well. So it is better to capture screenshots for only failed steps.
1 2 3 4 5 |
errorFile="D:\Test\ErrorFile.png" WpfWindow("HPE MyFlight Sample Application").CaptureBitmap errorFile,True 'True will overwrite an existing file' Reporter.ReportEvent 1,"Flight Booking Order should be placed","Flight Booking order was not placed",errorFile |
A sample Run Result for the following code. You can see the screenshot for the failed step is displaying in the result viewer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
SystemUtil.Run "C:\Program Files\HPE\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe" If WpfWindow("HPE MyFlight Sample Application").Exist Then Reporter.ReportEvent micPass,"HPE MyFlight Sample Application should be displayed","HPE MyFlight Sample Application displayed succesfully" Else Reporter.ReportEvent micFail,"HPE MyFlight Sample Application should be displayed","HPE MyFlight Sample Application failed to displayed" End If WpfWindow("HPE MyFlight Sample Application").WpfEdit("agentName").Set "john" WpfWindow("HPE MyFlight Sample Application").WpfEdit("password").SetSecure "5bc01c71aff4a72b0c02" WpfWindow("HPE MyFlight Sample Application").WpfButton("OK").Click Reporter.ReportEvent micDone,"User Credential were entered","" errorFile="D:\Test\ErrorFile.png" WpfWindow("HPE MyFlight Sample Application").CaptureBitmap errorFile,True 'True will overwrite an existing file' Reporter.ReportEvent 1,"Flight Booking Order should be placed","Flight Booking order was not placed",errorFile WpfWindow("HPE MyFlight Sample Application").Close'Closing Flight Booking application to fail the following steps |
*Note: UFT cannot load images from HP ALM. Hence save images only in your local machine or in a network location
Recommended Posts
- Import Excel File into Datatable in UFT
- What are new features in New UFT One Datatable
- DataTable in UFT One | Example of Datatable Methods
- How to Download and Install UFT One
- Descriptive Programming in UFT with Examples
- Mainframe Automation Using UFT One
- How to Use WaitProperty | Dynamic Wait in UFT