The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20130830

sahi - use "wait" ( _wait ) to make your scripts *faster*

yes it sounds odd, but using _wait appropriately can actually make your scripts run faster, without having to worry whether any script command got skipped because something happened too fast (e.g. maybe because of ajax?) :)

i've found that if i don't insert _wait calls in sahi scripts, then sometimes certain operations get skipped, so my code used to consist of some guesstimated wait periods for certain operations, like this:
    _setValue(_textbox("editTAParty:contact"), $email);
    _wait(500);
    _setSelected(_select("editTAParty:Party_languageIN"), $language);
    _wait(500);


but if you use the advanced _wait functionality, then nothing will get skipped and your scripts will run as fast as possible. here's an example:
    _setValue(_textbox("editTAParty:contact"), $email);
    _wait(10000, _textbox("editTAParty:contact").value == $email);
    _setSelected(_select("editTAParty:Party_languageIN"), $language);
    _wait(10000, _select("editTAParty:Party_languageIN").options.selectedIndex == $language);


basically, these wait calls mean to proceed with execution of the next step immediately as soon as the condition is fulfilled (or after 10 seconds--whichever comes first).

10000 means 10 seconds (10000 milliseconds). i set a high number since i don't anticipate any operation in the app that i'm testing to ever taking longer than 10 seconds.

UPDATE 20130902

just tested a full implementation of this on a script with 320 steps and reduced the run time from 7:30 to 1:47 :)

No comments:

Post a Comment