TestComplete – Handling Web Browser (1)
Parent page: GUI Recognition with TestComplete
Close single browser window
Description
In the example presented, Internet Explorer browser program (executable name) is hard-coded (as “iexplore”).
Instance number (i.e. a sequential number of the process in memory, if a few were loaded), is parameterized.
In first attempt, .Close method is used, which allows an application to finalize.
Second attempt uses .Terminate method. Any unsaved data will be lost.
Implementation
Public Const syncTimeShort = 5 Public Function wbCloseBrowser(ByVal intInstance) Dim IEProcess Dim PropNames, PropValues PropNames = Array("processname", "index") PropValues = Array("iexplore", IntVal(intInstance)) Set IEProcess = Sys.FindChild(PropNames, PropValues, 1, True) If Not IEProcess.Exists then Exit Function End if IEProcess.Close(syncTimeShort*1000) If Not IEProcess.Exists then Exit Function End if IEProcess.Terminate End Function