Monday, April 12, 2010

QTP - Display real time test status.

 QTP - Display real time test status.
 
When your test is getting executed, it would be always better to understand the health of the application, how many test cases are getting PASSED and FAILED. We can take immediate action if more number of test cases are getting failed.

To display these messages, we need to use msgbox, but there is a problem with MsgBox, user need to select OK every time it appear on the screen, so we can't use this.
We need a pop-up that close automatically after x seconds, if user have not selected any button. This is the kind of pop-up we require for displaying the real time status.

This kind of pop-up can be created using "Wscript.Shell"

Set goShell = CreateObject("Wscript.Shell")
iUserInput=goShell.popup ("Pop-up message", 03, "Pop-up Title")
Above code will display the pop-up for 3 seconds and close it automatically.

You can design the pop-up message content as per the requirements, I have created the pop-up in great detail, as my tests are getting executed in different locations and have number of settings.Attaching screen shot of Hybrid Framework real time status message.




Attaching the function pertaining to the above pop-up message. I have used number of variables, which keep on updating after each test case execution completion, this design will not have any impact on the performance of your test.


Function funDisplayTestExecuationStatus()
        Set goShell = CreateObject("Wscript.Shell")
        Set goShellApp = CreateObject("Shell.Application")
        'goShellApp.MinimizeAll
        
        Dim sMsg

        iProcessedByQTP = giTotalTestCasesIgnored+cint(giTotalTestCasesPass) + cint(giTotalTestCasesFail)+cint(giTotalTestCasesBadInputs)
        sMsg = "Test Execution Place or System IP  :" '& Environment("envsPlace") & vbcr & vbcr
        sMsg =sMsg & "Test Start time  :" & gdtTestStartTime & vbcr        
'        sMsg =sMsg & "Current      time :" & funGetTimeStamp() & vbcr & vbcr
        sMsg =sMsg & "Current     time  :" & Now() & vbcr
        sMsg =sMsg & gsTimeZone & vbcr & vbcr        
        sMsg =sMsg & "Test Execution  Mode  :" & gsTypeOfExecuationMode & vbcr    
        sMsg = sMsg & "Last Processed Test Case ID  : " & gsTestCaseIdControl & vbcr
        sMsg = sMsg & "############################################################" & vbcr        
        sMsg = sMsg & "Test Cases Processed By QTP / Total  : " & iProcessedByQTP  & " / " & giControlFileRows-1 & vbcr & vbcr
        sMsg = sMsg & "Total Test Cases Executed : " & cint(giTotalTestCasesPass) + cint(giTotalTestCasesFail)+cint(giTotalTestCasesBadInputs) & vbcr
        sMsg = sMsg & "---------------------------------------------------" & vbcr
        sMsg = sMsg & "Total Test Cases PASS : " & giTotalTestCasesPass & vbcr
        sMsg = sMsg & "Total Test Cases FAIL : " & giTotalTestCasesFail & vbcr
        sMsg = sMsg & "Total Test Cases BAD INPUTS : " & giTotalTestCasesBadInputs & vbcr & vbcr
        sMsg = sMsg & "Total Test Cases Ignored : " & giTotalTestCasesIgnored & vbcr
        sMsg = sMsg & "---------------------------------------------------" & vbcr
        sMsg = sMsg & "Total Test Cases PASS : " & giTotalTestCasesIgnoredPass & vbcr
        sMsg = sMsg & "Total Test Cases FAIL : " & giTotalTestCasesIgnoredFail & vbcr
        sMsg = sMsg & "Total Test Cases BAD INPUTS : " & giTotalTestCasesIgnoredBadInputs & vbcr
        sMsg = sMsg & "Total Test Cases EMPTY STATUS : " & giTotalTestCasesIgnoredEmpty & vbcr
        sMsg = sMsg & "Total Test Cases UNKNOWN STATUS : " & giTotalTestCasesIgnoredUnKnownStatus & vbcr & vbcr
        sMsg = sMsg & "Control File Name        : " & gsControlFileName & vbcr
        sMsg = sMsg & "Selected Folder Name : " & gsSelectedFolder & vbcr & vbcr
        sMsg = sMsg & "Execute Flag Mode       : " & gsExecuteFlagStartUp & vbcr 
        sMsg = sMsg & "Execution Status Mode : " & gsExecutionStatusStartUp & vbcr
        sMsg = sMsg & "Execute Specific Test Case IDs : " & gsExecuteSpecificTestCaseIds & vbcr & vbcr        
        sMsg = sMsg & "Exception Exit Counter : " & giExceptionsCounterStartUp & vbcr
        sMsg = sMsg & "Test Report Pop-Up Delay(Sec)  : " & giPopUpDelay & vbcr
        sMsg = sMsg & "Test Report Pop-Up Display : " & gsPopUpDisplay & vbcr
        sMsg = sMsg & "Object Highlighting : " & gsObjectHighlight & vbcr
        sMsg = sMsg & "Web Page Synchronization time out (Sec) : " & giWebPageSync & vbcr   
        sMsg = sMsg & "Silent Mode : " & gsSilentMode & vbcr           
        sMsg = sMsg & "Beep Mode : " & gsBeepMode & vbcr       
        sMsg = sMsg & "Email Notification : " & gsEmailNotification & vbcr
        sMsg = sMsg & "############################################################" & vbcr        
        sMsg = sMsg & "Calculate Avg Response Time Flag : " & gsAvgResponseTimeFlag & vbcr & vbcr
        sMsg = sMsg & "Test Cases Processed By QTP / Total  : " & cInt(giProcessedByQTPResponceTime) + cint(giIgnoredFailByQTPResponceTime) + cint(giIgnoredByQTPResponceTime) + cint(giProcessedByQTPResponceTimeNot) & " / " & giControlFileRows-1 & vbcr
        sMsg = sMsg & "--------------------------------------------------------------------------------" & vbcr
        sMsg = sMsg & "Total Test Cases, Response Time Recorded  : " & giProcessedByQTPResponceTime & vbcr 
        sMsg = sMsg & "Total Test Cases PASS, Response Time Not Considered  : " & giProcessedByQTPResponceTimeNot & vbcr 
        sMsg = sMsg & "Total Test Cases Fail, Response Time Ignored : " & giIgnoredFailByQTPResponceTime & vbcr         
        sMsg = sMsg & "Total Test Cases, Resposce Time Ignored     : " & giIgnoredByQTPResponceTime & vbcr & vbcr          
        sMsg = sMsg & "Press OK to STOP Execution ..."

        giExitFlag = goShell.popup (sMsg, 09, "Test Report (Real Time)")
        
End Function

For more details look into Hybrid Framework.




----

7 comments:

  1. do you have a framework that you share ?

    ReplyDelete
  2. Hi Bharath,
    Would you please explain me, whats the logic behind stopping QTP on clicking "OK" button

    ReplyDelete
  3. Hello Raghuram,

    Lets assume you are executing test with 2000 test cases and after executing 100 test cases, you want to STOP the test for some reason. If you stop ATP log files are not created, when user click on "OK" it will stop the test and proper log files are generated. For more details look at the Dual function hybrid framework.

    ReplyDelete
  4. Hi Bharath,
    I wanted to know what code you used to stop the QTP on click on the OK button, is it "ExitTest" or do you have anything custom function for this, also how do we detect the user intervention while running QTP, thanks in advance

    ReplyDelete
  5. Hello Raghuram,

    I will check the value of iUserInput and then decide to stop or proceed with the test.

    iUserInput=goShell.popup ("Pop-up message", 03, "Pop-up Title")

    ReplyDelete
  6. Hi Bharath ,

    Can you provide me some link from where i can download data driven,keyword and hybrid framework samples.I want to see the practical use of frameworks.please help.

    Regards,
    Deepika

    ReplyDelete
    Replies
    1. You need to build the framework bases on ur requirements.
      Below link can help you understand how to build it.
      http://bharath-marrivada.blogspot.in/search/label/QTP%20Hybrid%20Framework%20Design%20Architecture

      Delete