TestComplete – Handling Web Browser (1)

Posted by Albert Gareev on Oct 12, 2010 | Categories: Source codeWeb

Parent page: GUI Recognition with TestComplete

Close single browser window


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.


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 

  If Not IEProcess.Exists then
    Exit Function
  End if 

End Function

  • Leave a Reply

    * Required
    ** Your Email is never shared

Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.