18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Is exact duration of a test action available in sahi?

grigoriogrigorio Members
edited November -1 in Sahi - Open Source
Hi,

consider sahi script fragment:

...
_setValue(_textarea("wysiwygcontent"), $request_name);
// here I need start a timer
_click(_submit("Save"));
// here I need stop a timer and output EXACT duration of '_click(_submit("Save"));' in test log
...

Can I measure exact time duration of a '_click(_submit("Save"));' action in the example above?

I suppose, I have to use Javascript's getDate ().getTime () method and have to calculate time difference in milliseconds.

But, as I refer to sahi's settings file, 'sahi.properties', I found a parameter in it:

#Time (in milliseconds) delay between steps
script.time_between_steps=200

so, will these 200 milliseconds be included in time difference obtained by Javascript's getDate ().getTime ()? or not?

or, general question,

can I measure exact time duration of an arbitrary test action (_click, _setSelected, etc.)? if corresponding DOM elements have event handlers, can I get their spent time too, in total duration? can I ommit any sahi's dalays between steps in the calculation?

Comments

  • narayannarayan Administrators
    Sahi executes steps only after a delay. That behaviour is necessary for automatic waits.

    For your purpose, you could wrap your _click inside another function, take the time diff, log it and then proceed.
    <browser>
    function mySahiClickFunction(obj){
      var d = new Date();
      _click(obj);
      var diff = new Date() - d;
      _log("diff = " + diff);
    }
    </browser>
    
    _call(mySahiClickFunction(_button("id")));
    

    Would that work for you?

    Regards,
    Narayan
Sign In or Register to comment.