SPONSORS:






User Tag List

Results 1 to 3 of 3

Thread: Sleep Function

  1. #1
    Senior Member
    Join Date
    Jul 1999
    Location
    Burlingame CA 94010
    Posts
    502
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sleep Function

    The Sleep function is extremely useful when testing Web applications with SilkTest. Some methods, Exists () for example, don't always wait for the page to fully load. Therefore, you may get back FALSE from the method when an object actually exists. By adding a Sleep (n), where n is usually between 2-5, many problems go away. Whenever you have problems with testcase executon, look at well-placed Sleep statements as a possible solution to your problem. It shouldn't be that way, but it is !!!!

    Speaking of Exists (), it takes an optional integer parameter, which represents the maximum time SilkTest should wait for the object to exist.

    Example:

    Sleep (10)
    BOOLEAN b = w.Exists ()

    Better Example:

    BOOLEAN b = w.Exists (10)

    The second example is better because it will wait UP TO 10 seconds, but no longer than it needs to. The first example will wait 10 seconds.

    ------------------
    John W Green
    jwgreen@automationexpertise.com http://www.automationexpertise.com

    [This message has been edited by John Green (edited 07-19-2000).]

  2. #2
    Senior Member
    Join Date
    Feb 2000
    Posts
    1,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Sleep Function

    The improper use of Sleep() - those that are just plopped in to the code "to make this run work" - can cause no end of grief in test suites for time sensitive applications. And it can seriously add to the long term maintenance effort when the application or its environment change.

    As mentioned in John's example the Exists(value) method is far superior to a hard coded Sleep() that is followed by an action statement, particularly when the former is coded with a global constant to provides 'remote' single point control.

    Hardcoded Sleep/action sequences can also dramatically lengthen regression test runs resulting in much wasted time where nothing useful happens.

    In all cases where it is possible, a handshake method should be used instead of a time delay. This puts the greatest strain on the AUT and minimizes total test run time.

    That said, I've found it occasionally useful to code a Sleep(0) - zero, that is - to force the Silk Agent to "take a break".

    Another useful approach is to take control of the Exists() loop yourself by adding a fractional-second Sleep()increment with Error/Warning lines to indicate both a "expected window appeared in xx seconds" and a "window didn't appear within the alloted time". These are quite helpful in subsequent debug and performance analysis efforts. This code is best imbedded in the invoke or SetActive methods of a new class for the time-sensitive object.

    John

  3. #3
    AJ
    AJ is offline
    Moderator AJ's Avatar
    Join Date
    Jun 1999
    Location
    San Jose, CA
    Posts
    1,691
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Sleep Function

    Howabout using the WaitFor() and WaitForVital() functions in the download section?

    The functions were written for QAP a long time ago by Dave Reed, but they still work nicely for me on Browser pages.

    ------------------
    AJ Alhait
    BetaSoft Inc.
    AJ Alhait
    BetaSoft Inc.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin 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 02:21 PM.

Copyright BetaSoft Inc.