Forum Discussion

Kimoanh's avatar
Kimoanh
Occasional Contributor
15 years ago

Jscript does not recognize I.E MSGBox

I am using TC8 to generate an automation test for a web application, in the test appears a MSGBox windows.  TC Jscript does not recognize the msgbox.


Here is my code:


   page["Wait"]();

   var WarningWin = Sys.Process("iexplore").WaitWindow("#32770", "Windows Internet Explorer");

     if(Sys.Process("iexplore").WaitWindow("#32770", "W*").Exists)

     {

       //Warning Windows.

       WarningWin.Window("Button", "OK").ClickButton();

     }


P.s: I evaluated the msgbox window, it's not exist !!!!


Thanks for any help.

5 Replies

  • Kimoanh's avatar
    Kimoanh
    Occasional Contributor
    I recorded this test then run, the test failed "Cannot obtain the window class'#32770', window caption 'Windows Internet Explorer' and index -1."



    Please help!!!!!

  • Hi,





    The WaitWindow method has the timeout parameter that is responsible for the time spent on waiting for the needed window. In your method call, the parameter is omitted, thus, it has the default value equal to zero. Try increasing the timeout. Also, it is not necessary to use WaitWindow twice:





      page["Wait"](); 

      var WarningWin = Sys.Process("iexplore").WaitWindow("#32770", "W*", -1, 10000); //10 second waiting 

      if(WarningWin.Exists)

        {

          //Warning Windows.

          WarningWin.Window("Button", "OK").ClickButton();

        }






    For more information on the method, refer to the 'WaitWindow Method' help topic.
  • Kimoanh's avatar
    Kimoanh
    Occasional Contributor
    Hi David,

    Thanks for your response.

    I added 20 secs waiting, it still does not recognize the msgbox warning window.







  • Hi,





    It seems that you are working with Internet Explorer 8. This browser by default launches two processes, and it looks as if the dialog were the child of the second process. For more information, refer to the 'Opening a New Tab may launch a New Process with Internet Explorer 8.0' MSDN blogs record.





    To get the needed window, pass index 2 as a second parameter to the Process method:







    var WarningWin = Sys.Process("iexplore", 2).WaitWindow("#32770", "W*", -1, 10000);







    As an alternative, you can make Internet Explorer launch only one process and leave the script unchanged. In the system registry, search for the TabProcGrowth value in the HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main key (if it is not present, add the value of the string type) and set it equal to zero.





    Does this help?