Micro Focus QTP (UFT) Forums
Custom function ExitTest - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Custom function ExitTest (/Thread-Custom-function-ExitTest)



Custom function ExitTest - skadam - 11-03-2011

Hi All,

I guess this might not be possible in VB script. But just checking if by anyway we can achieve this. The requirement is that in our framework, at lot of places ExitTest statement was used for invalid cases or inputs. Now the thought is that we should close the application also in all these cases meaning calling ExitTest should first close the application and then exit the test execution. is there anyway QTP provides us this feature to overwrite the functionality of library functions. I guess no, pl share if you have any clue.

Thanks
Sravanthi


RE: Custom function ExitTest - Ankesh - 11-03-2011

u can use RegisterUserFunc to define the existing QTp functions...

Plz check qtp help for more information.

Regards,
Ankesh


RE: Custom function ExitTest - ravi.gajul - 11-03-2011

Hi ,
you can use the below code and call the user defined function CloseApplicationAndTest() instead of ExitTest

Code:
Function CloseApplicationAndTest()
   Dim intcounter
    Set o=Description.Create
    oDesc("micclass").Value="Browser"
    intcounter=0
    While Browser("micclass:=Browser","index:="&intcounter).exist(0) and intcounter<Desktop.ChildObjects(oDesc).count
        If instr(1, Browser("micclass:=Browser","index:="&intcounter).getRoProperty("name"),"Quality Center") = 0 Then
            SystemUtil.CloseProcessByHwnd( Browser("micclass:=Browser","index:="&intcounter).getRoProperty("hwnd"))
        else
            intcounter=intcounter+1
        End if
    wend
    ExitTest
End Function

This will close all the browsers open except quality center

Regards,
Ravi