QTP codes & shell application

'Create the shell application object
Set shlApp = CreateObject("Shell.Application"
'Get all open windows collection
Set allWins = shlApp.Windows  
'Loop through each window and close if IE
For Each window In allWins
    If InStr(window.fullName, "iexplore.exe") Then
        'Close the IE window
        window.Quit
    End If
Next


Dim windows2Close 
'Initialize with negative upper bound
ReDim windows2Close( -1
'Create the shell application object
Set shlApp = CreateObject("Shell.Application"
'Get all open windows collection
Set allWins = shlApp.Windows  
'Loop through each window and close if IE
For Each window In allWins
    'Close all IE windows but ignore Quality Center
    If InStr(window.fullName, "iexplore.exe") And InStr(Window.LocationURL, "/qcbin/") = 0 Then  
        'Increase the array size by 1
        ReDim Preserve windows2Close(UBound(windows2Close) + 1
        Set windows2Close(UBound(windows2Close)) = Window
    End If
Next 
'Loop through all array elements and close each window
For Each Window In windows2Close
    Window.Quit



Lots of stuffs on Automation Testing :


Post a Comment

أحدث أقدم