Forum Discussion

ArmandsBruns's avatar
ArmandsBruns
Frequent Contributor
12 years ago

Sys.Process("iexplore").Terminate() - Internet Explorer 9

TestComplete 8.70

Windows 7

Internet Explorer 9



What could be the reasons that sometimes doesn't work "Terminate"

code:

----------------------------------------------

 If Sys.Process("iexplore").Exists Then

     Sys.WaitProcess("iexplore").Terminate()

     aqUtils.Delay(4000)

     Sys.Refresh()

  End if

-----------------------------------------------

and as a result get error (attach error log: "2 running iexplore")

3 Replies

  • mesg2anil's avatar
    mesg2anil
    Regular Contributor
    Hi,



    Try below code...




    Sub CloseAllIEProcess


    CloseAllIEProcess

    IExplore = Sys.FindAllChildren("ProcessName","iexplore")


    If UBound(iexplore)>=0 Then


    For i = UBound(iexplore) to LBound(iexplore) Step -1 ' <== iterate from top to bottom


    iexplore(i).Terminate


    Next


    End If

    End Sub

    =================================

    After terminating IE forcibly, if you run any script immediately, please add below code, this will take IE to home page...



    If Sys.Process("iexplore").WaitWindow("#32770", "Windows Internet Explorer", 1, 1000).Exists Then

    Sys.Process("iexplore").Window("#32770", "Windows Internet Explorer", 1).Window("DirectUIHWND", "", 1).Window("CtrlNotifySink", "", 8).Window("Button", "Go to your home page", 1).Click




    End If

  • ArmandsBruns's avatar
    ArmandsBruns
    Frequent Contributor
    Hi Anil,



    Thanks, now works perfectly.



    After Terminate I use:



      Set iexplore = TestedApps.iexplore.Run()

      URL = "Go to my home page"

          

      Call iexplore.WaitPage("*", 2000).ToURL(URL)

     

      If (Not iexplore.WaitPage("*", 20000).Exists) Then

        Sys.WaitProcess("iexplore").Terminate()

        Call Sys.Refresh()

        TestedApps.iexplore.Run()

      End If



    Best Regards

    Armands