Forum Discussion

robert_L's avatar
robert_L
Occasional Contributor
11 years ago
Solved

Java Sys.Process object ID change

Hello,



I initially identified, via TestComplete ObjectSpy, a Java Security Warning popup as:

Sys.Process("java").SwingObject("JDialog", "Security Warning", -1, 1).SwingObject("JRootPane", "", 0)...



I would then use this "object ID" in my script to process this object.



However, in recent runs, the object ID has changed to:

Sys.Process("java", 2).SwingObject("JDialog", "Security Warning", -1, 1).SwingObject("JRootPane", "", 0)...





Why did this change, and how do I handle this variation in my JScript code? 



Thanks in advance for your help,

Robert





  • This will change if you have multiple forms with the same name, or in this case, duplicates of the same popup window. You can omit the ID but more than likely you didn't expect multiple popups here so you'll want to find out why you have 2 of them open and add handling for that.

4 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    This will change if you have multiple forms with the same name, or in this case, duplicates of the same popup window. You can omit the ID but more than likely you didn't expect multiple popups here so you'll want to find out why you have 2 of them open and add handling for that.
  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    In this case it's probably just the process that is duplicated. So you have a second "java" process running in the background. Since this can change you'll probably want ensure there isn't a process already running when you start your test.



    Use a function something like this prior to starting your test:




    function closejava(){

     for (;Sys.WaitProcess("java",0).Exists;){


      Sys.Process("java").Terminate();


      }

    }



    To terminate all pre-existing java processes prior to starting your tests.

    Now that only one "java" process is running you should omit the index:

    Sys.Process("java")

     

  • robert_L's avatar
    robert_L
    Occasional Contributor
    thanks for the response Ryan.  I only see one popup so i'm not sure why testcomplete is thinking there are duplicates...  hmm.



    also, I'm still kind of a beginner with testcomplete and jscript.

    How in the jscript code could i handle for this case where in some cases it's: Sys.Process("java")... and in other cases it's Sys.Process("java", 2)...?



    Thanks.



  • robert_L's avatar
    robert_L
    Occasional Contributor
    Thanks, Ryan, that did the trick, don't get the sys.process index anymore.