Topic
  • 11 replies
  • Latest Post - ‏2013-09-18T17:10:02Z by Y5QY_gerben_delange
michho
michho
7 Posts

Pinned topic waitForExistence

‏2013-09-17T13:38:55Z |

Hello,

i want to know why waitForExistence do not work on ProcessTestObject.

i'm doing the following:

ProcessTestObject testObject = startApp(config.getApplicationName());
testObject.waitForExistence();
.....
clickOK();

when i run the script an exception occurs, because the button is not found => application not fully loaded.

i thought i could use waitForExistence instead of sleep(3)

regards, michael

  • MrCoolK
    MrCoolK
    64 Posts

    Re: waitForExistence

    ‏2013-09-17T13:45:32Z  

    hi is it a web application?

  • michho
    michho
    7 Posts

    Re: waitForExistence

    ‏2013-09-17T13:47:06Z  
    • MrCoolK
    • ‏2013-09-17T13:45:32Z

    hi is it a web application?

    no, a java application.

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: waitForExistence

    ‏2013-09-17T13:49:03Z  

    hmm you have a funny way of asking questions.. it's more like a statement ;) Anyway here you go±

     

    waitForExistence

    public void 
    waitForExistence(double maximum_find_object_time,
                                 double find_object_wait_between_retry)
    
    Normally, waits until an object exists, but for a process this actually never waits. If the process does not now exist, it never will. Throws an exception if the process has terminated. The RationalTestScript onObjectNotFound methods are not supported.

     

    Overrides:
    waitForExistence in class TestObject

     

     

    Parameters:
    maximum_find_object_time - the maximum amount of time (in seconds) to wait while finding the object
    find_object_wait_between_retry - the amount of time (in seconds) to wait between attempts to find the object
    Throws:
    ObjectNotFoundException
    Since:
    RFT1.1
    See Also:
    isAlive()
    http://publib.boulder.ibm.com/infocenter/rtnlhelp/v6r0m0/index.jsp?topic=%2Fcom.rational.test.ft.help%2Fcom%2Frational%2Ftest%2Fft%2Fobject%2Finterfaces%2FProcessTestObject.html
  • michho
    michho
    7 Posts

    Re: waitForExistence

    ‏2013-09-17T14:08:24Z  

    hmm you have a funny way of asking questions.. it's more like a statement ;) Anyway here you go±

     

    waitForExistence

    <pre dir="ltr" style="color: rgb(0, 0, 0);">public void waitForExistence(double maximum_find_object_time, double find_object_wait_between_retry) </pre>
    Normally, waits until an object exists, but for a process this actually never waits. If the process does not now exist, it never will. Throws an exception if the process has terminated. The RationalTestScript onObjectNotFound methods are not supported.

     

    Overrides:
    waitForExistence in class TestObject

     

     

    Parameters:
    maximum_find_object_time - the maximum amount of time (in seconds) to wait while finding the object
    find_object_wait_between_retry - the amount of time (in seconds) to wait between attempts to find the object
    Throws:
    ObjectNotFoundException
    Since:
    RFT1.1
    See Also:
    isAlive()
    http://publib.boulder.ibm.com/infocenter/rtnlhelp/v6r0m0/index.jsp?topic=%2Fcom.rational.test.ft.help%2Fcom%2Frational%2Ftest%2Fft%2Fobject%2Finterfaces%2FProcessTestObject.html

    Hm, i'm using version 8.

    in the docu there is another info at waitForExistence():

    waitForExistence(double maximum_find_object_time, double find_object_wait_between_retry)
              Wait for the Existence of the Objects

    http://pic.dhe.ibm.com/infocenter/rfthelp/v8r1/index.jsp?topic=/com.rational.test.ft.api.help/ApiReference/com/rational/test/ft/object/interfaces/ProcessTestObject.html

    testObject.waitForExistence(10,1); does not wait the max time of 10 sec.

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: waitForExistence

    ‏2013-09-17T14:12:41Z  
    • michho
    • ‏2013-09-17T14:08:24Z

    Hm, i'm using version 8.

    in the docu there is another info at waitForExistence():

    waitForExistence(double maximum_find_object_time, double find_object_wait_between_retry)
              Wait for the Existence of the Objects

    http://pic.dhe.ibm.com/infocenter/rfthelp/v8r1/index.jsp?topic=/com.rational.test.ft.api.help/ApiReference/com/rational/test/ft/object/interfaces/ProcessTestObject.html

    testObject.waitForExistence(10,1); does not wait the max time of 10 sec.

    From the page the link you have just supplied refers to:

    Detail description:
    Normally, waits until an object exists, but for a process this actually never waits. If the process does not now exist, it never will. Throws an exception if the process has terminated. The RationalTestScript onObjectNotFound methods are not supported.
  • michho
    michho
    7 Posts

    Re: waitForExistence

    ‏2013-09-17T14:19:35Z  

    From the page the link you have just supplied refers to:

    Detail description:
    Normally, waits until an object exists, but for a process this actually never waits. If the process does not now exist, it never will. Throws an exception if the process has terminated. The RationalTestScript onObjectNotFound methods are not supported.

    oh, yes, you where right :)

    i will use sleep instead of waitForExistence.

  • MrCoolK
    MrCoolK
    64 Posts

    Re: waitForExistence

    ‏2013-09-17T18:32:05Z  
    • michho
    • ‏2013-09-17T14:19:35Z

    oh, yes, you where right :)

    i will use sleep instead of waitForExistence.

    I think sleep is a bad idea because if the application doesn't open within that time you are going to get the same error.

    So the solution is use this.

            int i=0;
            while(i==0){
                if(testObject().exists()){
                    i++;
                }
                System.out.println("found it not");
            }
            System.out.println("found it ");

     

    This will insure you that the script will wait until it opens.

     

    Thanks

    Cool K

     

  • cagin.uludamar
    cagin.uludamar
    66 Posts

    Re: waitForExistence

    ‏2013-09-18T10:37:14Z  

    Hi, did you try button().waitForExistance() ?

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: waitForExistence

    ‏2013-09-18T15:33:27Z  
    • MrCoolK
    • ‏2013-09-17T18:32:05Z

    I think sleep is a bad idea because if the application doesn't open within that time you are going to get the same error.

    So the solution is use this.

            int i=0;
            while(i==0){
                if(testObject().exists()){
                    i++;
                }
                System.out.println("found it not");
            }
            System.out.println("found it ");

     

    This will insure you that the script will wait until it opens.

     

    Thanks

    Cool K

     

    That's a terrible loop.. wastes far to much system resources and is potentially infinite when object will never exsist.  fixed it for you:

     

    boolean loadedWithinTimeout = false;
    int timeOutInSeconds = 60;
    for (int i = 0; i < timeOutInSeconds; i++) {
    if (testObject().exists()){
    loadedWithinTimeout = true;
    break;
    }
    sleep(1);
     
    }
     
    if (loadedWithinTimeout){
    System.out.println("Yeah!");
    }else{
    System.out.println("nogo :(");
    }
  • MrCoolK
    MrCoolK
    64 Posts

    Re: waitForExistence

    ‏2013-09-18T16:56:40Z  

    That's a terrible loop.. wastes far to much system resources and is potentially infinite when object will never exsist.  fixed it for you:

     

    boolean loadedWithinTimeout = false;
    int timeOutInSeconds = 60;
    for (int i = 0; i < timeOutInSeconds; i++) {
    if (testObject().exists()){
    loadedWithinTimeout = true;
    break;
    }
    sleep(1);
     
    }
     
    if (loadedWithinTimeout){
    System.out.println("Yeah!");
    }else{
    System.out.println("nogo :(");
    }

    I just provided him the approach how to handle that situation.

    If you are concern regarding time frame just add a code to capture time and set a expire code.

    What is the difference between your code and having a wait for existence for 60 second .If you have one line of code that does it why use a long code

    In that case your code is use less.

    My code was to provide him a approach  not a solution.

    Sorry for the harsh sentence.

     

     

    Thanks

    Cool K

     

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: waitForExistence

    ‏2013-09-18T17:10:02Z  
    • MrCoolK
    • ‏2013-09-18T16:56:40Z

    I just provided him the approach how to handle that situation.

    If you are concern regarding time frame just add a code to capture time and set a expire code.

    What is the difference between your code and having a wait for existence for 60 second .If you have one line of code that does it why use a long code

    In that case your code is use less.

    My code was to provide him a approach  not a solution.

    Sorry for the harsh sentence.

     

     

    Thanks

    Cool K

     

    I just provided him the approach how to handle that situation.

    My code was to provide him a approach  not a solution.

     

    Well then u could have made that a little clearer; if you say 'So the solution is use this', people might get confused.

     

    What is the difference between your code and having a wait for existence for 60 second 

    waitForExistence is void(), my code 'returns' a boolean.

     

    Sorry for the harsh sentence.

     

    no hard feelings, maybe i was i little rude in my last reply