preload

TestComplete – Handling Web Browser (2)

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

Parent page: GUI Recognition with TestComplete

Close all browser windows

Description

In the example presented, Internet Explorer browser program (executable name) is hard-coded (as “iexplore”).
Closing begins from first instance number (i.e. a sequential number of the process in memory, if a few were loaded).
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 wbCloseAll()
  Dim IEProcess
  Dim PropNames, PropValues
 
  While True
    PropNames = Array("processname", "index")
    PropValues = Array("iexplore", 1)

    Set IEProcess = Sys.FindChild(PropNames, PropValues, 1, True)

    If Not IEProcess.Exists then
      Exit Function
    End if 
 
    IEProcess.Close(syncTimeShort*1000)

    If IEProcess.Exists then
      IEProcess.Terminate
    End if 

  WEnd
 
End Function


  • One response to "TestComplete – Handling Web Browser (2)"

  • qagrl
    18th October 2010 at 5:37

    Please post more TestComplete tips like that

  • 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.