QTP codes & Browser

'Create a description for browser
Set oBrowser = Description.Create
oBrowser("micclass").Value = "Browser"  
Set oPage = Description.Create
oPage("micclass").Value = "Page"  


'Get all browsers
Set allBrowser = Desktop.ChildObjects(oBrowser) 
Dim i, iCount 
iCount = allBrowser.Count - 1  
For i = 0 To iCount
    'Get the page object from the browser
    Set oPg = allBrowser(i).ChildObjects(oPage)(0) 
    'Get the URL of the
    If InStr(oPg.GetROProperty("title"), "Quality Center", vbTextCompare) = 0 Then
        'Close the browser
        allBrowser(i).Close
    End If
Next 
By now you must be wondering about the line


'Get the page object from the browser
Set oPg = allBrowser(i).ChildObjects(oPage)(0)


'Name/IP of the computer
sComp = "."  


'Get the WMI object
Set WMI = GetObject("winmgmts:\\" & sComp & "\root\cimv2")


'Get collection of processes for with name iexplore.exe
Set allIE = WMI.ExecQuery("Select * from Win32_Process Where Name = 'iexplore.exe'"


'Loop through each process and terminate it
For Each IE in allIE
    IE.Terminate()

Post a Comment

أحدث أقدم