SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    how to use correctly waitForExistence

    Hi,

    I have a username text field (browser) which is displayed after pressing the Sign In button

    I have the following code (i do not use repository to store html elements):

    TestObject[] username = getRootTestObject().find(atDescendant(".name","use rname"));

    username[0].waitForExistence(200,0.5);


    But, this returns the error:
    java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0.].

    because, of course, the username[0] it is not displayed on the page...that is why i want a time out for existence

    How can I use the waitForExistence for an object which does not exist yet?

  2. #2
    Member
    Join Date
    Mar 2003
    Location
    Ottawa, Ontario, Canada
    Posts
    94
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use correctly waitForExistence

    Howdy,

    I think that you need to put the code inside a loop and, while the object you are waiting for does not exist, sleep for a short period of time (one second or two).

    Here is the code I use when waiting for a link to be displayed. You can probably adapt it for your needs, and I am sure that there are easier ways to get the same result:

    public void WaitforLink(String linkValue)
    {
    int kounter = 0;
    boolean linkExists = false;

    RootTestObject root = null;
    while (!linkExists)
    {
    System.out.println("Waiting for Link " + linkValue + " - " + kounter++);
    root = getRootTestObject();
    TestObject[] to = root.find(atDescendant(".text",linkValue.trim()));
    if (to.length > 0)
    linkExists = true;
    else
    sleep(1);
    } // End of IF
    }

    I could have made it shorter, but I needed to make it easily understandable by my co-workers.

    I also like to have debug information displayed, hence the line to print the number of times the routine looped before the object was displayed.

    Some people may not agree with getting the root object every time you do a search, because of performance issues. This has not affected me. Yet!

    Have a great day,

    André

  3. #3
    Junior Member
    Join Date
    Apr 2009
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use correctly waitForExistence

    here it the solution that i used in the end:

    http://blog.qualitance.ro/2011/02/rf...-timed-search/

  4. #4
    Junior Member
    Join Date
    Jul 2009
    Posts
    23
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how to use correctly waitForExistence

    a simpler solution would be using waitForExistence for the Document (or page) you are trying to load before using the find method. this ensures that RFT waits for the document/page to be loaded first before proceeding to the next step.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 06:24 PM.

Copyright BetaSoft Inc.