Reporter Object
As the name itself indicates Reporter Object reports test results at the end of running the test.
The method of Reporter Object is ReportEvent
Reporter.ReportEvent StatusOfTest, TypeOfMessaege, Details
Example:
Reporter.ReportEvent micPass, "Alert", " The test performed here has succeed"
Reporter.ReportEvent micFail, "Failure", " The test performed here has succeed"
Reporter.ReportEvent micDone, "Done", " The test performed here has succeed"
Reporter.ReportEvent micWarning, "Warning", " The test performed here has succeed"
The Status of Test can be
micPass
micFail
micDone
micWarning
micInfo
micGeneral
micGeneral is also considered as micDone
Apart from these, any junk text entered in StatusOfTest is considered as micPass.
Note that, mic stands for Mercury Interactive Constant
The Type of Message will be displayed in the left panel of the test result. When the message type is selected, the corresponding details are displayed in right panel.
Filter:
If we want the test result should not display any of the pass or fail status, we can set the mode of the result window while running the script.These modes can be set in Filter property of Reporter Object
The different modes are
rfEnableAll
rfEnableErrorsAndWarnings
rfEnableErrorsOnly
rfDisableAll
When no filter mode is set,the default one is rfEnableAll, where all the pass, failed and warnings are displayed in the test result
To set any mode:
Reporter.Filter = AnyMode
To Display the current mode in the test
MsgBox Reporter.Filter
Other properties of Reporter Object are Reportpath and RunStatus
Customising the Test Result
The results of each QTP run session are saved in results.xml which is located in C:\Documents and Settings\...\Local Settings\Temp\TempResults\Report. This xml file stores information on each of the test result nodes. Each node in the run results tree is an element in the results.xml file. You can create a customized .xsl file that specifies the information to be included in the printed report, and the way it should appear from this xml file.
Few More on Datatable...
AddParameter
Adds a column to the sheet in the run-time Data Table, and sets the value of the first row.
GetParameter
Retrieves the specified parameter from the run-time Data Table sheet.
DeleteParamater
To delete a parameter from a sheet in datatable
Any changes made using these methods will effect the run-time DataTable only which can be seen on the test results window at the end of running the test. These changes will not effect the Design time datatable. These can be retrieved and used in the script too.
Example
' Create a column header UserName and password and sets the first value as CNR and prokarma
Adds a column to the sheet in the run-time Data Table, and sets the value of the first row.
GetParameter
Retrieves the specified parameter from the run-time Data Table sheet.
DeleteParamater
To delete a parameter from a sheet in datatable
Any changes made using these methods will effect the run-time DataTable only which can be seen on the test results window at the end of running the test. These changes will not effect the Design time datatable. These can be retrieved and used in the script too.
Example
' Create a column header UserName and password and sets the first value as CNR and prokarma
DataTable.GlobalSheet.AddParameter "UserName", "CNR"
DataTable.GlobalSheet.AddParameter "Password", "prokarma"
DataTable.GlobalSheet.AddParameter "Password", "prokarma"
'Picking up the value from UserName and save it in val1, val2 to use it further
'Here the row pointer will be pointing to the first row in the datatable and will be picking up the values existing there.
'Here the row pointer will be pointing to the first row in the datatable and will be picking up the values existing there.
val1=DataTable.GetSheet("dtGlobalSheet").GetParameter ("UserName")
val2=DataTable.GetSheet(1).GetParameter("Password")
MsgBox Val1 & " " & Val2
val2=DataTable.GetSheet(1).GetParameter("Password")
MsgBox Val1 & " " & Val2
Datatable.SetNextRow ' Second row
'The row pointer will be pointing to the next row in the datatable and will be picking up the values existing there.val3=DataTable.GetSheet(1).GetParameter ("UserName")
val4=DataTable.GetSheet("dtGlobalSheet").GetParameter("Password")
MsgBox Val3 & " " & Val4
val4=DataTable.GetSheet("dtGlobalSheet").GetParameter("Password")
MsgBox Val3 & " " & Val4
' We can as well put the values back into the datatable
Datatable.SetNextRow ' Third row
Datatable("userName",1)="pranav"
Datatable("Password",1)="newpwd"
Datatable("userName",1)="pranav"
Datatable("Password",1)="newpwd"
val5=DataTable.GetSheet(1).GetParameter ("userName").Name
val6=DataTable.GetSheet(1).GetParameter("Password")
MsgBox val5 & " " & val6
val6=DataTable.GetSheet(1).GetParameter("Password")
MsgBox val5 & " " & val6
We can even create a new sheet into the data table and add few values in it
DataTable.AddSheet("MySheet").AddParameter("AccountNumber","047845")
The parameter from the MySheet can also be deleted.DataTable.GetSheet("MySheet").DeleteParameter("AccountNumber")
Subscribe to:
Posts (Atom)