Sunday, September 27, 2015

Reporter Object || Results Formatting

Description
The object used for sending information to the test results.
Associated Methods

  • ReportEvent Method
  • Syntax
    Reporter.ReportEvent EventStatus, ReportStepName, Details [, ImageFilePath]
  • Examples
    The following examples use the ReportEvent method to report a failed step.
    Reporter.ReportEvent 1, "Custom Step", "The user-defined step failed."
    or
    Reporter.ReportEvent micFail, "Custom Step", "The user-defined step failed."
    The following example uses the ReportEvent method to include a captured bitmap in the test results.
    Browser("Browser").Page("WebPage").Image("MyLogo").CaptureBitmap("MyLogo.bmp")
    Reporter.ReportEvent micDone, "Display Logo", "This is my logo", "MyLogo.bmp"
  • 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. 
Associated Properties


  • Filter Property
  • Syntax
  • Reporter.Filter = NewMode
  • Reporter.ReportEvent micGeneral, "2", ""
    Reporter.Filter = rfDisableAll 
  • Mode
    Description
    0 or
    rfEnableAll
    Default. All reported events are displayed in the Test Results.
    1 or rfEnableErrorsAndWarnings
    Only event with a warning or fail status are displayed in the Test Results.
    2 or
    rfEnableErrorsOnly
    Only events with a fail status are displayed in the Test Results.
    3 or
    rfDisableAll
    No events are displayed in the Test Results. 

  • ReportPath Property
  • Description
    Retrieves the folder path in which the current test's results are stored.
    Note: Do not use this property to attempt to set the results folder path.
    Syntax
    Path = Reporter.ReportPath
    Argument
    Type
    Description
    Path
    String
    The folder path in which the current test's results are stored.
    Example
    The following example uses the ReportPath property to retrieve the folder in which the results are stored and displays the folder in a message box.
    dim Path
    Path = Reporter.ReportPath
    MsgBox (Path) 

  • RunStatus Property
  • Description
    Retrieves the run status at the current point of the run session. For tests, it returns the status of current test during the test run. For business components, it returns the status of current business component (not the entire business process test).
    Syntax
    Reporter.RunStatus
    Example
    The following example uses the RunStatus property to retrieve the status of the run session at a specific point and exit the action if the test status is fail. If the test status is not fail, the test run continues.
    If Reporter.RunStatus = micFail Then ExitAction

  • Source: QuickTest Professional Help 

Thursday, September 3, 2015

How to work with Windows registry

To work with Windows registry using WScript.Shell object.


If you want to read a specific Key from registry
Set wscriptObj=createobject("WScript.Shell")
objProperties=wscriptObj.RegRead("HKLM\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Browser\CommonUse\")
msgbox objProperties
The above will give you the "Default" property value

If you want to read a specific property name in the registry:
objProperties=wscriptObj.RegRead("HKLM\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Browser\CommonUse\Sync")

If you want to update a specific property value in the registry:
wscriptObj.RegWrite "HKLM\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Browser\CommonUse\Sync",0,"REG_DWORD"

If you want to delete a specific property from the registry:
wscriptObj.RegDelete "HKLM\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Browser\CommonUse\Sync"


You can also use DotNetFactory to retrieve any retrieve any value
registryPath1="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE"
'Here i am creating an instance of DotNet Factory computer object
Set objDFComputer=DotNetFactory("Microsoft.VisualBasic.Devices.Computer","Microsoft.VisualBasic")
'Here i am creating an instance of Registry Object
Set objRegistry=objDFComputer.Registry
'The below will retrieve the "Default" Property
print objRegistry.GetValue(registryPath1,"","")

'The below retrieves the property of the regsitry
print objRegistry.GetValue(registryPath1,"Path","")
Set objRegistry=nothing
Set objDFComputer=nothing